From d457e97a8ae1192fdc65b821de6371622c6227e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=A6=8D?= <1455167345@qq.com> Date: Tue, 25 Feb 2025 13:14:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A4=9A=E7=BB=84=E4=BB=B6=E7=BB=84?= =?UTF-8?q?=E5=90=88=E4=B8=8A=E4=BC=A0=E9=A2=84=E8=A7=88=E5=9B=BE=EF=BC=8C?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E6=B5=8B=E8=AF=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/components/Pages/ChartGlobImage/index.vue | 42 +-- src/packages/index.ts | 12 +- .../modules/chartEditStore/chartEditStore.ts | 13 +- .../components/ChartsItemBox/index.vue | 68 +++-- .../components/ChartsOptionContent/index.vue | 247 +++++++++--------- src/views/chart/hooks/useContextMenu.hook.ts | 6 +- src/views/chart/index.vue | 96 ++++++- 8 files changed, 319 insertions(+), 167 deletions(-) diff --git a/.env.development b/.env.development index a184ae2..93f701d 100644 --- a/.env.development +++ b/.env.development @@ -6,7 +6,7 @@ VITE_PUBLIC_PATH = / # Basic interface address SPA #基础框架 -VITE_GLOB_API_URL = http://192.168.10.125:9620 +VITE_GLOB_API_URL = http://192.168.10.163:9620 # File upload address, optional # It can be forwarded by nginx or write the actual address directly VITE_GLOB_UPLOAD_URL=http://60.213.14.14:6070 diff --git a/src/components/Pages/ChartGlobImage/index.vue b/src/components/Pages/ChartGlobImage/index.vue index efd6bf4..daa2042 100644 --- a/src/components/Pages/ChartGlobImage/index.vue +++ b/src/components/Pages/ChartGlobImage/index.vue @@ -3,29 +3,29 @@ diff --git a/src/packages/index.ts b/src/packages/index.ts index 5ba1205..084d642 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -13,6 +13,9 @@ import { ConfigType, FetchComFlagType, } from '@/packages/index.d'; +import { useGlobSetting } from '@/hooks/setting'; + +const { apiUrl } = useGlobSetting(); const configModules: Record = import.meta.glob( './components/**/config.vue', @@ -116,9 +119,14 @@ export const fetchImages = async (targetData?: ConfigType) => { // 正则判断图片是否为 url,是则直接返回该 url if (/^(http|https):\/\/([\w.]+\/?)\S*/.test(targetData.image)) return targetData.image; // 新数据动态处理 - const { image } = targetData; + const { image, key } = targetData; // 兼容旧数据 - if (image.includes('@') || image.includes('base64')) return image; + if (image.includes('@') || image.includes('base64')) { + return image; + } else if (key == 'GroupItem') { + // 兼容多组件保存成自定义组件 + return apiUrl + '/' + image; + } const imageName = image.substring(image.lastIndexOf('/') + 1); for (const key in imagesModules) { diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index 7c716c0..6b999e8 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -73,6 +73,8 @@ export const useChartEditStore = defineStore({ }, // 右键菜单 rightMenuShow: false, + // 多组合组件预览图 + groupImgShow: false, // 鼠标定位 mousePosition: { startX: 0, @@ -160,6 +162,9 @@ export const useChartEditStore = defineStore({ getRightMenuShow(): boolean { return this.rightMenuShow; }, + getSaveGroupImgShow(): boolean { + return this.groupImgShow; + }, getEditCanvas(): EditCanvasType { return this.editCanvas; }, @@ -231,6 +236,10 @@ export const useChartEditStore = defineStore({ setRightMenuShow(value: boolean) { this.rightMenuShow = value; }, + // 设置多组合组件预览图 + setSaveGroupImgShow(value: boolean) { + this.groupImgShow = value; + }, // * 设置目标数据 hover setTargetHoverChart(hoverId?: TargetChartType['hoverId']) { this.targetChart.hoverId = hoverId; @@ -1042,7 +1051,7 @@ export const useChartEditStore = defineStore({ } }, // 保存至分组 - saveToGroup() { + saveToGroup(img: string) { if (this.getTargetChart.selectId.length > 1) { window['$message'].warning('多个组件,请先创建分组后保存'); return; @@ -1052,7 +1061,7 @@ export const useChartEditStore = defineStore({ if (item.id == this.getTargetChart.selectId[0]) { obj = { title: item.chartConfig.title, - image: 'upload.png', + image: img, key: 'GroupItem', json: { charts: item, diff --git a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue index 32f5543..a6ef580 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue @@ -5,10 +5,13 @@ class="go-content-charts-item-box" :class="[chartMode === ChartModeEnum.DOUBLE ? 'double' : 'single']" > +
+ +
[], }, }); + const menuOptionsList = ref(props.menuOptions); + const reloadShow = ref(false); + if (props.menuOptions.length > 0 && props.menuOptions[0].key === 'GroupItem') { + reloadShow.value = true; + } const chartLayoutStore = useChartLayoutStore(); const contentChartsItemBoxRef = ref(); @@ -150,11 +158,9 @@ // 双击添加 const dblclickHandle = async (item: ConfigType) => { - console.log('双击添加', item); if (item.disabled) return; // 保存的分组,进行使用 if (item.key == 'GroupItem') { - console.log('分组'); try { loadingStart(); const recordCharts = item.json; @@ -265,20 +271,52 @@ }, ); const deleteComponent = (item: ConfigType, index: number) => { - props.menuOptions.splice(index, 1); - customComponentSaveDelete({ - ids: item.id, - }).then((res) => { - if (res) { - window['$message'].success(`删除成功`); - } else { - window['$message'].success(`删除失败`); - } + Modal.confirm({ + title: '是否确认删除?', + onCancel() {}, + async onOk() { + await customComponentSaveDelete({ + ids: item.id, + }).then((res) => { + if (res) { + props.menuOptions.splice(index, 1); + window['$message'].success(`删除成功`); + } else { + window['$message'].success(`删除失败`); + } + }); + }, + }); + }; + const getCustomComponentList = async () => { + const data = await customComponentList({ + page: 1, + limit: 999, + }); + let list = []; + data.items.forEach((item) => { + let obj = JSON.parse(item.content); + list.push({ + ...obj, + id: item.id, + }); + }); + return list; + }; + const reloadBtn = () => { + getCustomComponentList().then((res) => { + menuOptionsList.value = res; }); }; diff --git a/src/views/chart/hooks/useContextMenu.hook.ts b/src/views/chart/hooks/useContextMenu.hook.ts index 8aaeaea..a675dce 100644 --- a/src/views/chart/hooks/useContextMenu.hook.ts +++ b/src/views/chart/hooks/useContextMenu.hook.ts @@ -36,6 +36,9 @@ export const divider = (n: number = 3) => { key: `d${n}`, }; }; +const saveGroup = () => { + chartEditStore.setSaveGroupImgShow(true); +}; // * 默认单组件选项 export const defaultOptions: MenuOptionsItemType[] = [ @@ -133,7 +136,8 @@ export const defaultOptions: MenuOptionsItemType[] = [ label: '保存至分组', key: MenuEnum.SAVETOGROUP, icon: renderIcon(GridIcon), - fnHandle: chartEditStore.saveToGroup, + // fnHandle: chartEditStore.saveToGroup, + fnHandle: saveGroup, }, ]; diff --git a/src/views/chart/index.vue b/src/views/chart/index.vue index 7424b3e..64de446 100644 --- a/src/views/chart/index.vue +++ b/src/views/chart/index.vue @@ -37,6 +37,59 @@ > + + + + + + + + + + 上传多组合组件预览图 + + + + + + @@ -46,10 +99,18 @@ import { useContextMenu } from './hooks/useContextMenu.hook'; import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'; import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'; - import { useDarkThemeHook, useThemeOverridesHook, useCode, useLang } from '@/hooks' - import { NConfigProvider } from 'naive-ui' + import { useDarkThemeHook, useThemeOverridesHook, useCode, useLang } from '@/hooks'; + import { NConfigProvider } from 'naive-ui'; + import { icon } from '@/plugins'; + import { ref } from 'vue'; + import { useGlobSetting } from '@/hooks/setting'; + import { uploadFile } from '@/api/demo/files'; + + const { apiUrl } = useGlobSetting(); + const uploadFileUrl = apiUrl + '/api/Files/Upload'; + const { DocumentTextIcon } = icon.ionicons5; // 暗黑主题 - const darkNTheme = useDarkThemeHook() + const darkNTheme = useDarkThemeHook(); const chartHistoryStoreStore = useChartHistoryStore(); const chartEditStore = useChartEditStore(); @@ -85,6 +146,35 @@ }, { passive: false }, ); + const previewFileList = ref([]); + // 关闭弹窗 + const closeModel = () => { + chartEditStore.setSaveGroupImgShow(false); + }; + const filePath = ref(); + // 保存多组合组件 + const saveCopyData = () => { + if (!filePath.value) { + window['$message'].warning('预览图不能为空'); + return; + } + chartEditStore.saveToGroup(filePath.value); + closeModel(); + }; + const beforeUpload = async (options) => { + const Loading = window['$loading']; + Loading && Loading.start(); + let uploadParams = new FormData(); + uploadParams.append('files', options.file.file); + const uploadRes = await uploadFile(uploadParams); + if (uploadRes.length > 0) { + window['$message'].success('上传成功!'); + filePath.value = uploadRes[0].filePath; + Loading && Loading.finish(); + } else { + window['$message'].error('上传失败!'); + } + }; diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.ts b/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.ts index 5a5ff2c..1d31e7c 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.ts +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.ts @@ -40,23 +40,6 @@ export const option = { bottomComponentColor1: '#6FEF94', bottomComponentColor2: '#A8F8C6', }, - dataStyleClone: { - iconColor1: '#B8FDB4', - iconColor2: '#60EC8D', - rectStrokeColor: '#00611A', - rectFillColor: '#0A251E', - gFillColor: '#4FE985', - - bottomFontColor1: '#A4F9AB', - bottomFontColor2: '#FFFFFF', - lineColor: '#A4F9AB', - bottomFontColor3: '#FFFFFF', - - bottomComponentColor1: '#337D4E', - bottomComponentColor2: '#2D593B', - bottomLineColor1: '#6FEF94', - bottomLineColor2: '#A8F8C6', - } } export default class Config extends PublicConfigClass implements CreateComponentType { diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.vue b/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.vue index fde4193..48f0a84 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.vue +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiFeiXingShuJu/config.vue @@ -54,10 +54,7 @@ > - + 恢复默认 @@ -69,10 +66,7 @@ > - + 恢复默认 @@ -134,9 +128,7 @@ 恢复默认 @@ -151,9 +143,7 @@ 恢复默认 @@ -166,10 +156,7 @@ > - + 恢复默认 @@ -183,9 +170,7 @@ 恢复默认 @@ -225,9 +210,7 @@ 恢复默认 @@ -242,9 +225,7 @@ 恢复默认 @@ -260,10 +241,7 @@ 恢复默认 @@ -278,10 +256,7 @@ 恢复默认 @@ -320,6 +295,24 @@ }, }); + const dataStyleClone = { + iconColor1: '#B8FDB4', + iconColor2: '#60EC8D', + rectStrokeColor: '#00611A', + rectFillColor: '#0A251E', + gFillColor: '#4FE985', + + bottomFontColor1: '#A4F9AB', + bottomFontColor2: '#FFFFFF', + lineColor: '#A4F9AB', + bottomFontColor3: '#FFFFFF', + + bottomComponentColor1: '#337D4E', + bottomComponentColor2: '#2D593B', + bottomLineColor1: '#6FEF94', + bottomLineColor2: '#A8F8C6', + }; + // 适应类型 const fitList = [ { diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.ts b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.ts index e6df4ad..4b01592 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.ts +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.ts @@ -20,7 +20,7 @@ export const option = { titleWidth: 181, titleHeight: 30, - videoloop: true, // 视频-循环播放 + videoloop: false, // 视频-循环播放 videomuted: true, // 视频-静音 videofit: 'fill', // 视频-适应方式 videowidth: 181, @@ -40,17 +40,6 @@ export const option = { iconFillColor: '#0A251E', iconBottomColor: '#0E4030', }, - dataStyleClone:{ - borderColor: '#008000', - titleColorStop1: '#1F6B55', - titleColorStop2: '#0A392A', - titleRightrColor: '#00611A', - iconColorStop1: '#73F095', - iconColorStop2: '#BBFDB5', - iconStrokeColor: '#00611A', - iconFillColor: '#0A251E', - iconBottomColor: '#0E4030', - } } export default class Config extends PublicConfigClass implements CreateComponentType { diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.vue b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.vue index 74f9172..d58b02b 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.vue +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/config.vue @@ -25,7 +25,7 @@ /> - + 编辑页面修改视频数据配置后,请在预览页面查看效果 @@ -69,7 +69,7 @@ 恢复默认 @@ -101,7 +101,7 @@ 恢复默认 @@ -116,7 +116,7 @@ 恢复默认 @@ -131,9 +131,7 @@ 恢复默认 @@ -148,7 +146,7 @@ 恢复默认 @@ -163,7 +161,7 @@ 恢复默认 @@ -178,7 +176,7 @@ 恢复默认 @@ -193,7 +191,7 @@ 恢复默认 @@ -208,7 +206,7 @@ 恢复默认 @@ -294,4 +292,16 @@ label: 'none', }, ]; + + const dataStyleClone = { + borderColor: '#008000', + titleColorStop1: '#1F6B55', + titleColorStop2: '#0A392A', + titleRightrColor: '#00611A', + iconColorStop1: '#73F095', + iconColorStop2: '#BBFDB5', + iconStrokeColor: '#00611A', + iconFillColor: '#0A251E', + iconBottomColor: '#0E4030', + }; diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/data.json b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/data.json index e02ba44..e3c702e 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/data.json +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/data.json @@ -2,27 +2,27 @@ "source": [ { "title":"DJA-72无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" }, { "title":"DJ-057无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" }, { "title":"DJA-20无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" }, { "title":"DJA-035无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" }, { "title":"DJA-11无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" }, { "title":"DJ-021无人机监控画面", - "videoUrl": "/src/assets/videos/earth.mp4" + "videoUrl": "http://221.2.83.254:7012/live/37130100181328000001.m3u8" } ] } diff --git a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/index.vue b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/index.vue index 7e9a85e..b08228b 100644 --- a/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/index.vue +++ b/src/packages/components/Zhigan/Zhigan/WuRenJiShiShiHuaMian/index.vue @@ -1,24 +1,40 @@