From aecba9c95e91f822c5e5c654cddcfdf209c99240 Mon Sep 17 00:00:00 2001 From: tnt group Date: Thu, 18 May 2023 09:45:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A9=E5=B1=95=20ConfigType?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=A6=81=E7=94=A8=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=8C=89=E9=92=AE=E7=BB=84=E4=BB=B6=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E3=80=81=E5=8F=8C=E5=87=BB=E3=80=81=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A8=A1=E5=BC=8F=E8=AE=A9=E9=85=8D=E7=BD=AE=E4=BA=86?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E9=A1=B9=E7=9A=84=E7=BB=84=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/components/Photos/My/index.ts | 13 ++++++++++++- src/packages/index.d.ts | 4 ++++ .../components/ChartsItemBox/index.vue | 6 ++++-- .../ContentCharts/components/ChartsSearch/index.vue | 5 ++++- src/views/chart/ContentEdit/hooks/useDrag.hook.ts | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/packages/components/Photos/My/index.ts b/src/packages/components/Photos/My/index.ts index bdde588d..460a90ad 100644 --- a/src/packages/components/Photos/My/index.ts +++ b/src/packages/components/Photos/My/index.ts @@ -13,4 +13,15 @@ const photoConfig = { virtualComponent: './components/Informations/Mores/Image' // 虚拟组件路径,尾部不跟 ‘/’,相对于 /packages/index.ts 文件的位置 } -export default [photoConfig, photoConfig, photoConfig, photoConfig, photoConfig] +const addConfig = { + ...ImageConfig, + category: ChatCategoryEnum.MY, + categoryName: ChatCategoryEnumName.MY, + package: PackagesCategoryEnum.PHOTOS, + title: '增加新项', + image: 'https://img.51miz.com/Element/00/62/75/91/d5453102_E627591_3bbace6f.png', + virtualComponent: './components/Informations/Mores/Image', // 虚拟组件路径,尾部不跟 ‘/’,相对于 /packages/index.ts 文件的位置 + disabled: true +} + +export default [photoConfig, photoConfig, photoConfig, photoConfig, photoConfig, addConfig] diff --git a/src/packages/index.d.ts b/src/packages/index.d.ts index 2a10bfa5..affdb1d2 100644 --- a/src/packages/index.d.ts +++ b/src/packages/index.d.ts @@ -26,6 +26,7 @@ export type ConfigType = { image: string virtualComponent?: string // 虚拟组件Path,指定后创建该组件时,从指定路径创建 dataset?: any // 组件预设的 dataset 值 + disabled?: boolean // 禁用的 } // 数据请求 @@ -158,6 +159,7 @@ export enum PackagesCategoryEnum { CHARTS = 'Charts', TABLES = 'Tables', INFORMATIONS = 'Informations', + PHOTOS = 'Photos', DECORATES = 'Decorates' } @@ -166,6 +168,7 @@ export enum PackagesCategoryName { CHARTS = '图表', TABLES = '列表', INFORMATIONS = '信息', + PHOTOS = '图片', DECORATES = '小组件' } @@ -180,5 +183,6 @@ export type PackagesType = { [PackagesCategoryEnum.CHARTS]: ConfigType[] [PackagesCategoryEnum.INFORMATIONS]: ConfigType[] [PackagesCategoryEnum.TABLES]: ConfigType[] + [PackagesCategoryEnum.PHOTOS]: ConfigType[] [PackagesCategoryEnum.DECORATES]: ConfigType[] } diff --git a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue index 981e4464..1dfcbee1 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue @@ -11,8 +11,8 @@ v-for="(item, index) in menuOptions" :key="index" draggable - @dragstart="dragStartHandle($event, item)" - @dragend="dragendHandle" + @dragstart="!item.disabled && dragStartHandle($event, item)" + @dragend="!item.disabled && dragendHandle" @dblclick="dblclickHandle(item)" >
@@ -69,6 +69,7 @@ const chartMode: Ref = computed(() => { // 拖拽处理 const dragStartHandle = (e: DragEvent, item: ConfigType) => { + if (item.disabled) return // 动态注册图表组件 componentInstall(item.chartKey, fetchChartComponent(item)) componentInstall(item.conKey, fetchConfigComponent(item)) @@ -85,6 +86,7 @@ const dragendHandle = () => { // 双击添加 const dblclickHandle = async (item: ConfigType) => { + if (item.disabled) return try { loadingStart() // 动态注册图表组件 diff --git a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue index 6b285625..dd8466d3 100644 --- a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue @@ -129,7 +129,9 @@ const searchHandle = (key: string | null) => { } loading.value = true showPopover.value = true - searchRes.value = List.filter((e: ConfigType) => !key || e.title.toLowerCase().includes(key.toLowerCase())) + searchRes.value = List.filter( + (e: ConfigType) => !e.disabled && (!key || e.title.toLowerCase().includes(key.toLowerCase())) + ) setTimeout(() => { loading.value = undefined }, 500) @@ -146,6 +148,7 @@ const listenerCloseHandle = (e: Event) => { // 选择处理 const selectChartHandle = async (item: ConfigType) => { + if (item.disabled) return try { loadingStart() // 动态注册图表组件 diff --git a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts index fab672c8..f8d90293 100644 --- a/src/views/chart/ContentEdit/hooks/useDrag.hook.ts +++ b/src/views/chart/ContentEdit/hooks/useDrag.hook.ts @@ -29,6 +29,7 @@ export const dragHandle = async (e: DragEvent) => { // 修改状态 chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_CREATE, false) const dropData: Exclude = JSONParse(drayDataString) + if (dropData.disabled) return // 创建新图表组件 let newComponent: CreateComponentType = await createComponent(dropData)