feat:【antd】【mall】diy-editor 代码风格统一 & 逐个测试 20%

This commit is contained in:
YunaiV
2025-11-10 19:13:25 +08:00
parent a3356a0a5e
commit fadad35b20
47 changed files with 195 additions and 263 deletions

View File

@@ -0,0 +1 @@
export { default as ProductCategorySelect } from './select.vue';

View File

@@ -11,26 +11,25 @@ import { getCategoryList } from '#/api/mall/product/category';
defineOptions({ name: 'ProductCategorySelect' }); defineOptions({ name: 'ProductCategorySelect' });
const props = defineProps({ const props = defineProps({
// ID
modelValue: { modelValue: {
type: [Number, Array<Number>], type: [Number, Array<Number>],
default: undefined, default: undefined,
}, }, // ID
//
multiple: { multiple: {
type: Boolean, type: Boolean,
default: false, default: false,
}, }, //
//
parentId: { parentId: {
type: Number, type: Number,
default: undefined, default: undefined,
}, }, //
}); });
/** 分类选择 */ /** 分类选择 */
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const categoryList = ref<any[]>([]); //
/** 选中的分类 ID */ /** 选中的分类 ID */
const selectCategoryId = computed({ const selectCategoryId = computed({
get: () => { get: () => {
@@ -42,7 +41,6 @@ const selectCategoryId = computed({
}); });
/** 初始化 */ /** 初始化 */
const categoryList = ref<any[]>([]); //
onMounted(async () => { onMounted(async () => {
const data = await getCategoryList({ const data = await getCategoryList({
parentId: props.parentId, parentId: props.parentId,

View File

@@ -3,7 +3,7 @@ import { ref, watch } from 'vue';
import { Button, Input } from 'ant-design-vue'; import { Button, Input } from 'ant-design-vue';
import AppLinkSelectDialog from './app-link-select-dialog.vue'; import AppLinkSelectDialog from './select-dialog.vue';
/** APP 链接输入框 */ /** APP 链接输入框 */
defineOptions({ name: 'AppLinkInput' }); defineOptions({ name: 'AppLinkInput' });
@@ -56,5 +56,6 @@ watch(
</Button> </Button>
</template> </template>
</Input> </Input>
<AppLinkSelectDialog ref="dialogRef" @change="handleLinkSelected" /> <AppLinkSelectDialog ref="dialogRef" @change="handleLinkSelected" />
</template> </template>

View File

@@ -3,11 +3,12 @@ import type { AppLink } from './data';
import { nextTick, ref } from 'vue'; import { nextTick, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { getUrlNumberValue } from '@vben/utils'; import { getUrlNumberValue } from '@vben/utils';
import { Button, Form, FormItem, Modal, Tooltip } from 'ant-design-vue'; import { Button, Form, FormItem, Tooltip } from 'ant-design-vue';
import ProductCategorySelect from '#/views/mall/product/category/components/product-category-select.vue'; import { ProductCategorySelect } from '#/views/mall/product/category/components/';
import { APP_LINK_GROUP_LIST, APP_LINK_TYPE_ENUM } from './data'; import { APP_LINK_GROUP_LIST, APP_LINK_TYPE_ENUM } from './data';
@@ -30,21 +31,31 @@ const groupBtnRefs = ref<HTMLButtonElement[]>([]); // 分组引用列表
const detailSelectDialog = ref<{ const detailSelectDialog = ref<{
id?: number; id?: number;
type?: APP_LINK_TYPE_ENUM; type?: APP_LINK_TYPE_ENUM;
visible: boolean;
}>({ }>({
visible: false,
id: undefined, id: undefined,
type: undefined, type: undefined,
}); // }); //
const dialogVisible = ref(false); const [Modal, modalApi] = useVbenModal({
onConfirm() {
emit('change', activeAppLink.value.path);
emit('appLinkChange', activeAppLink.value);
modalApi.close();
},
});
const [DetailSelectModal, detailSelectModalApi] = useVbenModal({
onConfirm() {
detailSelectModalApi.close();
},
});
defineExpose({ open }); defineExpose({ open });
/** 打开弹窗 */ /** 打开弹窗 */
async function open(link: string) { async function open(link: string) {
activeAppLink.value.path = link; activeAppLink.value.path = link;
dialogVisible.value = true; modalApi.open();
// //
const group = APP_LINK_GROUP_LIST.find((group) => const group = APP_LINK_GROUP_LIST.find((group) =>
group.links.some((linkItem) => { group.links.some((linkItem) => {
@@ -76,7 +87,7 @@ function handleAppLinkSelected(appLink: AppLink) {
'id', 'id',
`http://127.0.0.1${activeAppLink.value.path}`, `http://127.0.0.1${activeAppLink.value.path}`,
) || undefined; ) || undefined;
detailSelectDialog.value.visible = true; detailSelectModalApi.open();
break; break;
} }
default: { default: {
@@ -85,13 +96,6 @@ function handleAppLinkSelected(appLink: AppLink) {
} }
} }
/** 处理确认提交 */
function handleSubmit() {
emit('change', activeAppLink.value.path);
emit('appLinkChange', activeAppLink.value);
dialogVisible.value = false;
}
/** /**
* 处理右侧链接列表滚动 * 处理右侧链接列表滚动
* *
@@ -138,7 +142,7 @@ function scrollToGroupBtn(group: string) {
/** 是否为相同的链接(不比较参数,只比较链接) */ /** 是否为相同的链接(不比较参数,只比较链接) */
function isSameLink(link1: string, link2: string) { function isSameLink(link1: string, link2: string) {
return link2 ? link1.split('?')[0] === link2.split('?')[0] : false; return link2 ? link1?.split('?')[0] === link2.split('?')[0] : false;
} }
/** 处理详情选择 */ /** 处理详情选择 */
@@ -149,17 +153,12 @@ function handleProductCategorySelected(id: number) {
activeAppLink.value.path = `${url.pathname}${url.search}`; activeAppLink.value.path = `${url.pathname}${url.search}`;
// id // id
detailSelectDialog.value.visible = false; detailSelectModalApi.close();
detailSelectDialog.value.id = undefined; detailSelectDialog.value.id = undefined;
} }
</script> </script>
<template> <template>
<Modal <Modal title="选择链接" class="w-[65%]">
v-model:open="dialogVisible"
title="选择链接"
width="65%"
@ok="handleSubmit"
>
<div class="flex h-[500px] gap-2"> <div class="flex h-[500px] gap-2">
<!-- 左侧分组列表 --> <!-- 左侧分组列表 -->
<div <div
@@ -218,7 +217,7 @@ function handleProductCategorySelected(id: number) {
</div> </div>
</Modal> </Modal>
<Modal v-model:open="detailSelectDialog.visible" title="选择分类" width="65%"> <DetailSelectModal title="选择分类" class="w-[65%]">
<Form class="min-h-[200px]"> <Form class="min-h-[200px]">
<FormItem <FormItem
label="选择分类" label="选择分类"
@@ -233,11 +232,5 @@ function handleProductCategorySelected(id: number) {
/> />
</FormItem> </FormItem>
</Form> </Form>
</Modal> </DetailSelectModal>
</template> </template>
<style lang="scss" scoped>
:deep(.ant-btn + .ant-btn) {
margin-left: 0 !important;
}
</style>

View File

@@ -1,53 +0,0 @@
<script setup lang="ts">
import type { CarouselProperty } from './config';
import { ref } from 'vue';
import { IconifyIcon } from '@vben/icons';
import { Carousel, Image } from 'ant-design-vue';
/** 轮播图 */
defineOptions({ name: 'Carousel' });
defineProps<{ property: CarouselProperty }>();
const currentIndex = ref(0);
const handleIndexChange = (index: number) => {
currentIndex.value = index + 1;
};
</script>
<template>
<div>
<!-- 无图片 -->
<div
class="bg-card flex h-64 items-center justify-center"
v-if="property.items.length === 0"
>
<IconifyIcon icon="tdesign:image" class="size-6 text-gray-800" />
</div>
<div v-else class="relative">
<Carousel
:autoplay="property.autoplay"
:autoplay-speed="property.interval * 1000"
:dots="property.indicator !== 'number'"
@change="handleIndexChange"
class="h-44"
>
<div v-for="(item, index) in property.items" :key="index">
<Image
class="h-full w-full object-cover"
:src="item.imgUrl"
:preview="false"
/>
</div>
</Carousel>
<div
v-if="property.indicator === 'number'"
class="absolute bottom-2.5 right-2.5 rounded-xl bg-black px-2 py-1 text-xs text-white opacity-40"
>
{{ currentIndex }} / {{ property.items.length }}
</div>
</div>
</div>
</template>

View File

@@ -0,0 +1,53 @@
<script setup lang="ts">
import type { CarouselProperty } from './config';
import { ref } from 'vue';
import { IconifyIcon } from '@vben/icons';
import { Carousel, Image } from 'ant-design-vue';
/** 轮播图 */
defineOptions({ name: 'Carousel' });
defineProps<{ property: CarouselProperty }>();
const currentIndex = ref(0); // 当前索引
/** 处理索引变化 */
const handleIndexChange = (index: number) => {
currentIndex.value = index + 1;
};
</script>
<template>
<!-- 无图片 -->
<div
class="bg-card flex h-64 items-center justify-center"
v-if="property.items.length === 0"
>
<IconifyIcon icon="tdesign:image" class="size-6 text-gray-800" />
</div>
<div v-else class="relative">
<Carousel
:autoplay="property.autoplay"
:autoplay-speed="property.interval * 1000"
:dots="property.indicator !== 'number'"
@change="handleIndexChange"
class="h-44"
>
<div v-for="(item, index) in property.items" :key="index">
<Image
class="h-full w-full object-cover"
:src="item.imgUrl"
:preview="false"
/>
</div>
</Carousel>
<div
v-if="property.indicator === 'number'"
class="absolute bottom-2.5 right-2.5 rounded-xl bg-black px-2 py-1 text-xs text-white opacity-40"
>
{{ currentIndex }} / {{ property.items.length }}
</div>
</div>
</template>

View File

@@ -21,11 +21,13 @@ import { AppLinkInput, Draggable } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// /** 轮播图属性面板 */
defineOptions({ name: 'CarouselProperty' }); defineOptions({ name: 'CarouselProperty' });
const props = defineProps<{ modelValue: CarouselProperty }>(); const props = defineProps<{ modelValue: CarouselProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>

View File

@@ -8,21 +8,17 @@ import { Image } from 'ant-design-vue';
/** 菜单导航 */ /** 菜单导航 */
defineOptions({ name: 'MenuSwiper' }); defineOptions({ name: 'MenuSwiper' });
const props = defineProps<{ property: MenuSwiperProperty }>(); const props = defineProps<{ property: MenuSwiperProperty }>();
// 标题的高度
const TITLE_HEIGHT = 20;
// 图标的高度
const ICON_SIZE = 32;
// 垂直间距:一行上下的间距
const SPACE_Y = 16;
// 分页 const TITLE_HEIGHT = 20; // 标题的高度
const pages = ref<MenuSwiperItemProperty[][]>([]); const ICON_SIZE = 32; // 图标的高度
// 轮播图高度 const SPACE_Y = 16; // 垂直间距:一行上下的间距
const carouselHeight = ref(0);
// 行高 const pages = ref<MenuSwiperItemProperty[][]>([]); // 分页
const rowHeight = ref(0); const carouselHeight = ref(0); // 轮播图高度
// 列宽
const columnWidth = ref(''); const rowHeight = ref(0); // 行高
const columnWidth = ref(''); // 列宽
watch( watch(
() => props.property, () => props.property,
() => { () => {

View File

@@ -13,10 +13,11 @@ import { getSpuDetailList } from '#/api/mall/product/spu';
/** 商品栏 */ /** 商品栏 */
defineOptions({ name: 'ProductList' }); defineOptions({ name: 'ProductList' });
// 定义属性
const props = defineProps<{ property: ProductListProperty }>(); const props = defineProps<{ property: ProductListProperty }>();
// 商品列表
const spuList = ref<MallSpuApi.Spu[]>([]); const spuList = ref<MallSpuApi.Spu[]>([]);
watch( watch(
() => props.property.spuIds, () => props.property.spuIds,
async () => { async () => {
@@ -27,19 +28,15 @@ watch(
deep: true, deep: true,
}, },
); );
// 手机宽度
const phoneWidth = ref(384); const phoneWidth = ref(375); // 手机宽度
// 容器 const containerRef = ref(); // 容器
const containerRef = ref(); const columns = ref(2); // 商品的列数
// 商品的列数 const scrollbarWidth = ref('100%'); // 滚动条宽度
const columns = ref(2); const imageSize = ref('0'); // 商品图大小
// 滚动条宽度 const gridTemplateColumns = ref(''); // 商品网络列数
const scrollbarWidth = ref('100%');
// 商品图大小 /** 计算布局参数 */
const imageSize = ref('0');
// 商品网络列数
const gridTemplateColumns = ref('');
// 计算布局参数
watch( watch(
() => [props.property, phoneWidth, spuList.value.length], () => [props.property, phoneWidth, spuList.value.length],
() => { () => {
@@ -69,9 +66,10 @@ watch(
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },
); );
/** 初始化 */
onMounted(() => { onMounted(() => {
// 提取手机宽度 phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 375;
phoneWidth.value = containerRef.value?.wrapRef?.offsetWidth || 384;
}); });
</script> </script>
<template> <template>
@@ -146,5 +144,3 @@ onMounted(() => {
</div> </div>
</div> </div>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -17,17 +17,18 @@ import {
} from 'ant-design-vue'; } from 'ant-design-vue';
import UploadImg from '#/components/upload/image-upload.vue'; import UploadImg from '#/components/upload/image-upload.vue';
import { InputWithColor as ColorInput } from '#/views/mall/promotion/components'; import SpuShowcase from '#/views/mall/product/spu/components/spu-showcase.vue';
import { ColorInput } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// TODO: 添加组件
// import SpuShowcase from '#/views/mall/product/spu/components/spu-showcase.vue';
// 商品栏属性面板 /** 商品栏属性面板 */
defineOptions({ name: 'ProductListProperty' }); defineOptions({ name: 'ProductListProperty' });
const props = defineProps<{ modelValue: ProductListProperty }>(); const props = defineProps<{ modelValue: ProductListProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>
@@ -39,7 +40,7 @@ const formData = useVModel(props, 'modelValue', emit);
:model="formData" :model="formData"
> >
<Card title="商品列表" class="property-group" :bordered="false"> <Card title="商品列表" class="property-group" :bordered="false">
<!-- <SpuShowcase v-model="formData.spuIds" /> --> <SpuShowcase v-model="formData.spuIds" />
</Card> </Card>
<Card title="商品样式" class="property-group" :bordered="false"> <Card title="商品样式" class="property-group" :bordered="false">
<FormItem label="布局" prop="type"> <FormItem label="布局" prop="type">
@@ -117,5 +118,3 @@ const formData = useVModel(props, 'modelValue', emit);
</Form> </Form>
</ComponentContainerProperty> </ComponentContainerProperty>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -5,19 +5,19 @@ import { IconifyIcon } from '@vben/icons';
/** 搜索框 */ /** 搜索框 */
defineOptions({ name: 'SearchBar' }); defineOptions({ name: 'SearchBar' });
defineProps<{ property: SearchProperty }>(); defineProps<{ property: SearchProperty }>();
</script> </script>
<template> <template>
<div <div
class="search-bar"
:style="{ :style="{
color: property.textColor, color: property.textColor,
}" }"
> >
<!-- 搜索框 --> <!-- 搜索框 -->
<div <div
class="inner" class="relative flex min-h-7 items-center text-sm"
:style="{ :style="{
height: `${property.height}px`, height: `${property.height}px`,
background: property.backgroundColor, background: property.backgroundColor,
@@ -25,7 +25,7 @@ defineProps<{ property: SearchProperty }>();
}" }"
> >
<div <div
class="placeholder" class="flex w-full items-center gap-0.5 overflow-hidden text-ellipsis whitespace-nowrap break-all px-2"
:style="{ :style="{
justifyContent: property.placeholderPosition, justifyContent: property.placeholderPosition,
}" }"
@@ -33,7 +33,7 @@ defineProps<{ property: SearchProperty }>();
<IconifyIcon icon="lucide:search" /> <IconifyIcon icon="lucide:search" />
<span>{{ property.placeholder || '搜索商品' }}</span> <span>{{ property.placeholder || '搜索商品' }}</span>
</div> </div>
<div class="right"> <div class="absolute right-2 flex items-center justify-center gap-2">
<!-- 搜索热词 --> <!-- 搜索热词 -->
<span v-for="(keyword, index) in property.hotKeywords" :key="index"> <span v-for="(keyword, index) in property.hotKeywords" :key="index">
{{ keyword }} {{ keyword }}
@@ -44,37 +44,3 @@ defineProps<{ property: SearchProperty }>();
</div> </div>
</div> </div>
</template> </template>
<style scoped lang="scss">
.search-bar {
/* 搜索框 */
.inner {
position: relative;
display: flex;
align-items: center;
min-height: 28px;
font-size: 14px;
.placeholder {
display: flex;
gap: 2px;
align-items: center;
width: 100%;
padding: 0 8px;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
}
.right {
position: absolute;
right: 8px;
display: flex;
gap: 8px;
align-items: center;
justify-content: center;
}
}
}
</style>

View File

@@ -11,9 +11,9 @@ defineOptions({ name: 'TabBar' });
defineProps<{ property: TabBarProperty }>(); defineProps<{ property: TabBarProperty }>();
</script> </script>
<template> <template>
<div class="tab-bar"> <div class="z-[2] w-full">
<div <div
class="tab-bar-bg" class="flex flex-row items-center justify-around py-2"
:style="{ :style="{
background: background:
property.style.bgType === 'color' property.style.bgType === 'color'
@@ -26,12 +26,18 @@ defineProps<{ property: TabBarProperty }>();
<div <div
v-for="(item, index) in property.items" v-for="(item, index) in property.items"
:key="index" :key="index"
class="tab-bar-item" class="flex w-full flex-col items-center justify-center text-xs"
> >
<Image :src="index === 0 ? item.activeIconUrl : item.iconUrl"> <Image
:src="index === 0 ? item.activeIconUrl : item.iconUrl"
class="!h-[26px] w-[26px] rounded"
>
<template #error> <template #error>
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<IconifyIcon icon="lucide:image" /> <IconifyIcon
icon="lucide:image"
class="h-[26px] w-[26px] rounded"
/>
</div> </div>
</template> </template>
</Image> </Image>
@@ -47,33 +53,3 @@ defineProps<{ property: TabBarProperty }>();
</div> </div>
</div> </div>
</template> </template>
<style lang="scss" scoped>
.tab-bar {
z-index: 2;
width: 100%;
.tab-bar-bg {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
padding: 8px 0;
.tab-bar-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
font-size: 12px;
:deep(img),
.el-icon {
width: 26px;
height: 26px;
border-radius: 4px;
}
}
}
}
</style>

View File

@@ -22,7 +22,8 @@ import {
} from '#/views/mall/promotion/components'; } from '#/views/mall/promotion/components';
import { component, THEME_LIST } from './config'; import { component, THEME_LIST } from './config';
// 底部导航栏
/** 底部导航栏 */
defineOptions({ name: 'TabBarProperty' }); defineOptions({ name: 'TabBarProperty' });
const props = defineProps<{ modelValue: TabBarProperty }>(); const props = defineProps<{ modelValue: TabBarProperty }>();
@@ -32,7 +33,7 @@ const formData = useVModel(props, 'modelValue', emit);
// 将数据库的值更新到右侧属性栏 // 将数据库的值更新到右侧属性栏
component.property.items = formData.value.items; component.property.items = formData.value.items;
// 要的主题 /** 处理主题变更 */
const handleThemeChange = () => { const handleThemeChange = () => {
const theme = THEME_LIST.find((theme) => theme.id === formData.value.theme); const theme = THEME_LIST.find((theme) => theme.id === formData.value.theme);
if (theme?.color) { if (theme?.color) {
@@ -42,7 +43,7 @@ const handleThemeChange = () => {
</script> </script>
<template> <template>
<div class="tab-bar"> <div>
<!-- 表单 --> <!-- 表单 -->
<Form <Form
:model="formData" :model="formData"
@@ -142,5 +143,3 @@ const handleThemeChange = () => {
</Form> </Form>
</div> </div>
</template> </template>
<style lang="scss" scoped></style>

View File

@@ -5,11 +5,13 @@ import { useVModel } from '@vueuse/core';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 用户卡片属性面板 /** 用户卡片属性面板 */
defineOptions({ name: 'UserCardProperty' }); defineOptions({ name: 'UserCardProperty' });
const props = defineProps<{ modelValue: UserCardProperty }>(); const props = defineProps<{ modelValue: UserCardProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>

View File

@@ -2,11 +2,10 @@ import type { ComponentStyle, DiyComponent } from '../../../util';
/** 用户卡券属性 */ /** 用户卡券属性 */
export interface UserCouponProperty { export interface UserCouponProperty {
// 组件样式 style: ComponentStyle; // 组件样式
style: ComponentStyle;
} }
// 定义组件 /** 定义组件 */
export const component = { export const component = {
id: 'UserCoupon', id: 'UserCoupon',
name: '用户卡券', name: '用户卡券',

View File

@@ -5,7 +5,8 @@ import { Image } from 'ant-design-vue';
/** 用户订单 */ /** 用户订单 */
defineOptions({ name: 'UserOrder' }); defineOptions({ name: 'UserOrder' });
// 定义属性
/** 定义属性 */
defineProps<{ property: UserOrderProperty }>(); defineProps<{ property: UserOrderProperty }>();
</script> </script>
<template> <template>

View File

@@ -5,11 +5,13 @@ import { useVModel } from '@vueuse/core';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 用户订单属性面板 /** 用户订单属性面板 */
defineOptions({ name: 'UserOrderProperty' }); defineOptions({ name: 'UserOrderProperty' });
const props = defineProps<{ modelValue: UserOrderProperty }>(); const props = defineProps<{ modelValue: UserOrderProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>

View File

@@ -5,7 +5,8 @@ import { Image } from 'ant-design-vue';
/** 用户资产 */ /** 用户资产 */
defineOptions({ name: 'UserWallet' }); defineOptions({ name: 'UserWallet' });
// 定义属性
/** 定义属性 */
defineProps<{ property: UserWalletProperty }>(); defineProps<{ property: UserWalletProperty }>();
</script> </script>
<template> <template>

View File

@@ -5,11 +5,13 @@ import { useVModel } from '@vueuse/core';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 用户资产属性面板 /** 用户资产属性面板 */
defineOptions({ name: 'UserWalletProperty' }); defineOptions({ name: 'UserWalletProperty' });
const props = defineProps<{ modelValue: UserWalletProperty }>(); const props = defineProps<{ modelValue: UserWalletProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>

View File

@@ -9,11 +9,13 @@ import UploadImg from '#/components/upload/image-upload.vue';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 视频播放属性面板 /** 视频播放属性面板 */
defineOptions({ name: 'VideoPlayerProperty' }); defineOptions({ name: 'VideoPlayerProperty' });
const props = defineProps<{ modelValue: VideoPlayerProperty }>(); const props = defineProps<{ modelValue: VideoPlayerProperty }>();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const formData = useVModel(props, 'modelValue', emit); const formData = useVModel(props, 'modelValue', emit);
</script> </script>

View File

@@ -38,6 +38,12 @@ const props = defineProps({
const emits = defineEmits(['reset', 'save', 'update:modelValue']); // 工具栏操作 const emits = defineEmits(['reset', 'save', 'update:modelValue']); // 工具栏操作
// TODO @xingyu要不要加这个
// const qrcode = useQRCode(props.previewUrl, {
// errorCorrectionLevel: 'H',
// margin: 4,
// }); // 预览二维码
const componentLibrary = ref(); // 左侧组件库 const componentLibrary = ref(); // 左侧组件库
const pageConfigComponent = ref<DiyComponent<any>>( const pageConfigComponent = ref<DiyComponent<any>>(
cloneDeep(PAGE_CONFIG_COMPONENT), cloneDeep(PAGE_CONFIG_COMPONENT),
@@ -169,6 +175,7 @@ function handleComponentSelected(
index: number = -1, index: number = -1,
) { ) {
// 使用深拷贝避免响应式追踪循环警告 // 使用深拷贝避免响应式追踪循环警告
// TODO @xingyu这个是必须的么ele 没有哈。
selectedComponent.value = cloneDeep(component); selectedComponent.value = cloneDeep(component);
selectedComponentIndex.value = index; selectedComponentIndex.value = index;
} }
@@ -501,4 +508,5 @@ onMounted(() => {
</div> </div>
</PreviewModal> </PreviewModal>
</Page> </Page>
<!-- TODO @xingyu这里改造完后类似 web-ele/src/views/mall/promotion/components/diy-editor/index.vue 里的全局样式递推到子组件里的就没没了类似 property-group -->
</template> </template>

View File

@@ -66,10 +66,11 @@ const handleDelete = function (index: number) {
class="drag-icon cursor-move text-gray-500" class="drag-icon cursor-move text-gray-500"
/> />
</Tooltip> </Tooltip>
<Tooltip v-if="formData.length > min" title="删除"> <Tooltip title="删除">
<IconifyIcon <IconifyIcon
icon="lucide:trash-2" icon="ep:delete"
class="cursor-pointer text-red-500 hover:text-red-600" class="cursor-pointer text-red-500"
v-if="formData.length > min"
@click="handleDelete(index)" @click="handleDelete(index)"
/> />
</Tooltip> </Tooltip>
@@ -79,11 +80,7 @@ const handleDelete = function (index: number) {
</div> </div>
</template> </template>
</VueDraggable> </VueDraggable>
<Tooltip <Tooltip :title="limit < Number.MAX_VALUE ? `最多添加${limit}个` : undefined">
:title="
limit > 0 && limit < Number.MAX_VALUE ? `最多添加${limit}个` : undefined
"
>
<Button <Button
type="primary" type="primary"
ghost ghost
@@ -98,5 +95,3 @@ const handleDelete = function (index: number) {
</Button> </Button>
</Tooltip> </Tooltip>
</template> </template>
<style scoped lang="scss"></style>

View File

@@ -29,7 +29,6 @@ const props = defineProps({
type: Number, type: Number,
default: 4, default: 4,
}, // 行数,默认 4 行 }, // 行数,默认 4 行
cols: { cols: {
type: Number, type: Number,
default: 4, default: 4,
@@ -167,9 +166,7 @@ function handleHotAreaSelected(hotArea: Rect, index: number) {
emit('hotAreaSelected', hotArea, index); emit('hotAreaSelected', hotArea, index);
} }
/** /** 结束热区选择模式 */
* 结束热区选择模式
*/
function exitHotAreaSelectMode() { function exitHotAreaSelectMode() {
// 移除方块激活标记 // 移除方块激活标记
eachCube((_, __, cube) => { eachCube((_, __, cube) => {

View File

@@ -1,8 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { Space } from 'ant-design-vue'; import { Space } from 'ant-design-vue';
// TODO @芋艿、@xingyu貌似上下移动的按钮被遮住了
/** /**
* 垂直按钮组 * 垂直按钮组
* Ant Design Vue 的按钮组只支持水平显示,通过重写样式实现垂直布局 * Ant Design Vue 的按钮组,通过 Space 实现垂直布局
*/ */
defineOptions({ name: 'VerticalButtonGroup' }); defineOptions({ name: 'VerticalButtonGroup' });
</script> </script>

View File

@@ -1 +1 @@
export { default as ProductCategorySelect } from './category-select.vue'; export { default as ProductCategorySelect } from './select.vue';

View File

@@ -1,5 +1,4 @@
<script lang="ts" setup> <script lang="ts" setup>
// TODO @AI一些 modal 是否使用 Modal 组件,而不是 el-modal
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import { ElButton, ElInput } from 'element-plus'; import { ElButton, ElInput } from 'element-plus';

View File

@@ -24,7 +24,7 @@ import { AppLinkInput, Draggable } from '#/views/mall/promotion/components';
import ComponentContainerProperty from '../../component-container-property.vue'; import ComponentContainerProperty from '../../component-container-property.vue';
// 轮播图属性面板 /** 轮播图属性面板 */
defineOptions({ name: 'CarouselProperty' }); defineOptions({ name: 'CarouselProperty' });
const props = defineProps<{ modelValue: CarouselProperty }>(); const props = defineProps<{ modelValue: CarouselProperty }>();

View File

@@ -39,7 +39,7 @@ export interface ProductCardFieldProperty {
export const component = { export const component = {
id: 'ProductCard', id: 'ProductCard',
name: '商品卡片', name: '商品卡片',
icon: 'fluent:text-column-two-left-24-filled', icon: 'lucide:grid-3x3',
property: { property: {
layoutType: 'oneColBigImg', layoutType: 'oneColBigImg',
fields: { fields: {

View File

@@ -9,7 +9,7 @@ import { fenToYuan } from '@vben/utils';
import { ElImage, ElScrollbar } from 'element-plus'; import { ElImage, ElScrollbar } from 'element-plus';
import * as ProductSpuApi from '#/api/mall/product/spu'; import { getSpuDetailList } from '#/api/mall/product/spu';
/** 商品栏 */ /** 商品栏 */
defineOptions({ name: 'ProductList' }); defineOptions({ name: 'ProductList' });
@@ -21,7 +21,7 @@ const spuList = ref<MallSpuApi.Spu[]>([]);
watch( watch(
() => props.property.spuIds, () => props.property.spuIds,
async () => { async () => {
spuList.value = await ProductSpuApi.getSpuDetailList(props.property.spuIds); spuList.value = await getSpuDetailList(props.property.spuIds);
}, },
{ {
immediate: true, immediate: true,

View File

@@ -20,7 +20,7 @@ export type PlaceholderPosition = 'center' | 'left';
export const component = { export const component = {
id: 'SearchBar', id: 'SearchBar',
name: '搜索框', name: '搜索框',
icon: 'ep:search', icon: 'lucide:search',
property: { property: {
height: 28, height: 28,
showScan: false, showScan: false,

View File

@@ -30,7 +30,7 @@ defineProps<{ property: SearchProperty }>();
justifyContent: property.placeholderPosition, justifyContent: property.placeholderPosition,
}" }"
> >
<IconifyIcon icon="ep:search" /> <IconifyIcon icon="lucide:search" />
<span>{{ property.placeholder || '搜索商品' }}</span> <span>{{ property.placeholder || '搜索商品' }}</span>
</div> </div>
<div class="absolute right-2 flex items-center justify-center gap-2"> <div class="absolute right-2 flex items-center justify-center gap-2">
@@ -39,10 +39,7 @@ defineProps<{ property: SearchProperty }>();
{{ keyword }} {{ keyword }}
</span> </span>
<!-- 扫一扫 --> <!-- 扫一扫 -->
<IconifyIcon <IconifyIcon icon="lucide:scan-barcode" v-show="property.showScan" />
icon="ant-design:scan-outlined"
v-show="property.showScan"
/>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -5,7 +5,7 @@ import { IconifyIcon } from '@vben/icons';
import { ElImage } from 'element-plus'; import { ElImage } from 'element-plus';
/** 底部导航 */ /** 页面底部导航 */
defineOptions({ name: 'TabBar' }); defineOptions({ name: 'TabBar' });
defineProps<{ property: TabBarProperty }>(); defineProps<{ property: TabBarProperty }>();
@@ -26,7 +26,7 @@ defineProps<{ property: TabBarProperty }>();
<div <div
v-for="(item, index) in property.items" v-for="(item, index) in property.items"
:key="index" :key="index"
class="tab-bar-item flex w-full flex-col items-center justify-center text-xs" class="flex w-full flex-col items-center justify-center text-xs"
> >
<ElImage <ElImage
:src="index === 0 ? item.activeIconUrl : item.iconUrl" :src="index === 0 ? item.activeIconUrl : item.iconUrl"
@@ -35,7 +35,7 @@ defineProps<{ property: TabBarProperty }>();
<template #error> <template #error>
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<IconifyIcon <IconifyIcon
icon="ep:picture" icon="lucide:image"
class="h-[26px] w-[26px] rounded" class="h-[26px] w-[26px] rounded"
/> />
</div> </div>

View File

@@ -44,7 +44,7 @@ const handleThemeChange = () => {
</script> </script>
<template> <template>
<div class="tab-bar"> <div>
<ElForm :model="formData" label-width="80px"> <ElForm :model="formData" label-width="80px">
<ElFormItem label="主题" prop="theme"> <ElFormItem label="主题" prop="theme">
<ElSelect v-model="formData!.theme" @change="handleThemeChange"> <ElSelect v-model="formData!.theme" @change="handleThemeChange">

View File

@@ -2,15 +2,14 @@ import type { ComponentStyle, DiyComponent } from '../../../util';
/** 用户卡券属性 */ /** 用户卡券属性 */
export interface UserCouponProperty { export interface UserCouponProperty {
// 组件样式 style: ComponentStyle; // 组件样式
style: ComponentStyle;
} }
// 定义组件 /** 定义组件 */
export const component = { export const component = {
id: 'UserCoupon', id: 'UserCoupon',
name: '用户卡券', name: '用户卡券',
icon: 'ep:ticket', icon: 'lucide:ticket',
property: { property: {
style: { style: {
bgType: 'color', bgType: 'color',

View File

@@ -9,7 +9,7 @@ export interface UserOrderProperty {
export const component = { export const component = {
id: 'UserOrder', id: 'UserOrder',
name: '用户订单', name: '用户订单',
icon: 'ep:list', icon: 'lucide:clipboard-list',
property: { property: {
style: { style: {
bgType: 'color', bgType: 'color',

View File

@@ -9,7 +9,7 @@ export interface UserWalletProperty {
export const component = { export const component = {
id: 'UserWallet', id: 'UserWallet',
name: '用户资产', name: '用户资产',
icon: 'ep:wallet-filled', icon: 'lucide:wallet',
property: { property: {
style: { style: {
bgType: 'color', bgType: 'color',

View File

@@ -17,7 +17,7 @@ export interface VideoPlayerStyle extends ComponentStyle {
export const component = { export const component = {
id: 'VideoPlayer', id: 'VideoPlayer',
name: '视频播放', name: '视频播放',
icon: 'ep:video-play', icon: 'lucide:video',
property: { property: {
videoUrl: '', videoUrl: '',
posterUrl: '', posterUrl: '',

View File

@@ -63,9 +63,8 @@ const handleDelete = function (index: number) {
> >
<ElTooltip content="拖动排序"> <ElTooltip content="拖动排序">
<IconifyIcon <IconifyIcon
icon="ic:round-drag-indicator" icon="lucide:move"
class="drag-icon cursor-move" class="drag-icon cursor-move text-gray-500"
style="color: #8a909c"
/> />
</ElTooltip> </ElTooltip>
<ElTooltip content="删除"> <ElTooltip content="删除">
@@ -90,7 +89,7 @@ const handleDelete = function (index: number) {
:disabled="limit > 0 && formData.length >= limit" :disabled="limit > 0 && formData.length >= limit"
@click="handleAdd" @click="handleAdd"
> >
<IconifyIcon icon="ep:plus" /><span>添加</span> <IconifyIcon icon="lucide:plus" /><span>添加</span>
</ElButton> </ElButton>
</ElTooltip> </ElTooltip>
</template> </template>

View File

@@ -183,7 +183,7 @@ function exitHotAreaSelectMode() {
* 迭代魔方矩阵 * 迭代魔方矩阵
* @param callback 回调 * @param callback 回调
*/ */
const eachCube = (callback: (x: number, y: number, cube: Cube) => void) => { function eachCube(callback: (x: number, y: number, cube: Cube) => void) {
for (const [x, row] of cubes.value.entries()) { for (const [x, row] of cubes.value.entries()) {
if (!row) continue; if (!row) continue;
for (const [y, cube] of row.entries()) { for (const [y, cube] of row.entries()) {
@@ -192,7 +192,7 @@ const eachCube = (callback: (x: number, y: number, cube: Cube) => void) => {
} }
} }
} }
}; }
</script> </script>
<template> <template>
<div class="relative"> <div class="relative">