From 17b98e0a3ee7939e3c64e73768ba72778944ea3b Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Mon, 29 May 2023 10:29:44 +0800 Subject: [PATCH 01/24] =?UTF-8?q?fix:=20=E8=AF=AD=E8=A8=80=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=E8=8B=B1=E6=96=87=E5=90=8E=EF=BC=8C=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=8C=89=E9=92=AE=E7=9A=84=E8=8B=B1=E6=96=87=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/en/project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/en/project.ts b/src/i18n/en/project.ts index 3b7d367b..6695cd5e 100644 --- a/src/i18n/en/project.ts +++ b/src/i18n/en/project.ts @@ -1,5 +1,5 @@ export default { - create_btn: 'Creat', + create_btn: 'Create', create_tip: 'Please select a content for development', project: 'Project', my: 'My', From 9384cd98a4eb77c3fe9bf624d48af9b6172d7719 Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:00:06 +0800 Subject: [PATCH 02/24] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E7=BB=84=E4=BB=B6=E6=9B=B4=E6=96=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useChartDataFetch.hook.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index c39cc34e..91271e8d 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -90,12 +90,12 @@ export const useChartDataFetch = ( // 普通初始化与组件交互处理监听 watch( - () => targetComponent.request, + () => targetComponent.request.requestParams, () => { fetchFn() }, { - immediate: true, + immediate: false, deep: true } ) @@ -105,7 +105,11 @@ export const useChartDataFetch = ( // 单位 const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value // 开启轮询 - if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit)) + if (time) { + fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit)) + } else { + fetchFn() + } } // eslint-disable-next-line no-empty } catch (error) { @@ -114,10 +118,11 @@ export const useChartDataFetch = ( } if (isPreview()) { - // 判断是否是数据池类型 targetComponent.request.requestDataType === RequestDataTypeEnum.Pond ? addGlobalDataInterface(targetComponent, useChartEditStore, updateCallback || echartsUpdateHandle) : requestIntervalFn() + } else { + requestIntervalFn() } return { vChartRef } } From 9b0136b92a2eb2f8e86d7e1a93911c197f6092ea Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:00:28 +0800 Subject: [PATCH 03/24] fix: declare module '@iconify/vue' --- types/shims-vue.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/shims-vue.d.ts b/types/shims-vue.d.ts index fbfc8922..fa19c5db 100644 --- a/types/shims-vue.d.ts +++ b/types/shims-vue.d.ts @@ -5,4 +5,5 @@ declare module '*.vue' { } declare module 'lodash/*' -declare module 'dom-helpers' \ No newline at end of file +declare module 'dom-helpers' +declare module '@iconify/vue' \ No newline at end of file From 2a32f2ab720b23e426aa54926cd71e27799c9259 Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:03:59 +0800 Subject: [PATCH 04/24] =?UTF-8?q?feat:=20=20=E6=9B=B4=E6=96=B0=E5=85=AC?= =?UTF-8?q?=E5=85=B1api=E5=AF=B9=E7=BB=84=E4=BB=B6=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useChartDataPondFetch.hook.ts | 39 +++++++++++++++++-------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/hooks/useChartDataPondFetch.hook.ts b/src/hooks/useChartDataPondFetch.hook.ts index 24ac7660..a506f274 100644 --- a/src/hooks/useChartDataPondFetch.hook.ts +++ b/src/hooks/useChartDataPondFetch.hook.ts @@ -1,4 +1,4 @@ -import { toRaw } from 'vue' +import { toRaw, watch, computed, ComputedRef } from 'vue' import { customizeHttp } from '@/api/http' import { CreateComponentType } from '@/packages/index.d' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' @@ -20,7 +20,7 @@ const mittDataPondMap = new Map<string, DataPondMapType[]>() // 创建单个数据项轮询接口 const newPondItemInterval = ( requestGlobalConfig: RequestGlobalConfigType, - requestDataPondItem: RequestDataPondItemType, + requestDataPondItem: ComputedRef<RequestDataPondItemType>, dataPondMapItem?: DataPondMapType[] ) => { if (!dataPondMapItem) return @@ -31,8 +31,7 @@ const newPondItemInterval = ( // 请求 const fetchFn = async () => { try { - const res = await customizeHttp(toRaw(requestDataPondItem.dataPondRequestConfig), toRaw(requestGlobalConfig)) - + const res = await customizeHttp(toRaw(requestDataPondItem.value.dataPondRequestConfig), toRaw(requestGlobalConfig)) if (res) { try { // 遍历更新回调函数 @@ -49,19 +48,32 @@ const newPondItemInterval = ( } } + watch( + () => requestDataPondItem.value.dataPondRequestConfig.requestParams.Params, + () => { + fetchFn() + }, + { + immediate: false, + deep: true + } + ) + + // 立即调用 fetchFn() - const targetInterval = requestDataPondItem.dataPondRequestConfig.requestInterval - const targetUnit = requestDataPondItem.dataPondRequestConfig.requestIntervalUnit + + const targetInterval = requestDataPondItem.value.dataPondRequestConfig.requestInterval + const targetUnit = requestDataPondItem.value.dataPondRequestConfig.requestIntervalUnit const globalRequestInterval = requestGlobalConfig.requestInterval const globalUnit = requestGlobalConfig.requestIntervalUnit // 定时时间 - const time = targetInterval ? targetInterval : globalRequestInterval + const time = targetInterval ? targetInterval : globalRequestInterval // 单位 - const unit = targetInterval ? targetUnit : globalUnit + const unit = targetInterval ? targetUnit : globalUnit // 开启轮询 if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit)) } @@ -96,13 +108,16 @@ export const useChartDataPondFetch = () => { } // 初始化数据池 - const initDataPond = (requestGlobalConfig: RequestGlobalConfigType) => { - const { requestDataPond } = requestGlobalConfig + const initDataPond = (useChartEditStore: ChartEditStoreType) => { + const { requestGlobalConfig } = useChartEditStore() + const chartEditStore = useChartEditStore() // 根据 mapId 查找对应的数据池配置 for (let pondKey of mittDataPondMap.keys()) { - const requestDataPondItem = requestDataPond.find(item => item.dataPondId === pondKey) + const requestDataPondItem = computed(() => { + return requestGlobalConfig.requestDataPond.find(item => item.dataPondId === pondKey) + }) as ComputedRef<RequestDataPondItemType> if (requestDataPondItem) { - newPondItemInterval(requestGlobalConfig, requestDataPondItem, mittDataPondMap.get(pondKey)) + newPondItemInterval(chartEditStore.requestGlobalConfig, requestDataPondItem, mittDataPondMap.get(pondKey)) } } } From 4b0b50ea3c262dfc59debbc31b75f6f81260d219 Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:06:51 +0800 Subject: [PATCH 05/24] =?UTF-8?q?feat:=20=20=E6=94=AF=E6=8C=81=E5=AF=B9?= =?UTF-8?q?=E5=85=AC=E5=85=B1api=E8=BF=9B=E8=A1=8C=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useChartInteract.hook.ts | 43 +++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/hooks/useChartInteract.hook.ts b/src/hooks/useChartInteract.hook.ts index efa2ae73..aa0b1ed6 100644 --- a/src/hooks/useChartInteract.hook.ts +++ b/src/hooks/useChartInteract.hook.ts @@ -1,4 +1,5 @@ import { toRefs } from 'vue' +import { isPreview } from '@/utils' import { CreateComponentType } from '@/packages/index.d' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' @@ -12,6 +13,7 @@ export const useChartInteract = ( param: { [T: string]: any }, interactEventOn: string ) => { + if (!isPreview()) return const chartEditStore = useChartEditStore() const { interactEvents } = chartConfig.events const fnOnEvent = interactEvents.filter(item => { @@ -20,20 +22,37 @@ export const useChartInteract = ( if (fnOnEvent.length === 0) return fnOnEvent.forEach(item => { - const index = chartEditStore.fetchTargetIndex(item.interactComponentId) - if (index === -1) return - const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams) - Object.keys(item.interactFn).forEach(key => { - if (Params.value[key]) { - Params.value[key] = param[item.interactFn[key]] - } - if (Header.value[key]) { - Header.value[key] = param[item.interactFn[key]] - } - }) + + const globalConfigPindAprndex = chartEditStore.requestGlobalConfig.requestDataPond.findIndex(cItem => + cItem.dataPondId === item.interactComponentId + ) + if (globalConfigPindAprndex !== -1) { + const { Params, Header } = toRefs(chartEditStore.requestGlobalConfig.requestDataPond[globalConfigPindAprndex].dataPondRequestConfig.requestParams) + + Object.keys(item.interactFn).forEach(key => { + if (Params.value[key]) { + Params.value[key] = param[item.interactFn[key]] + } + if (Header.value[key]) { + Header.value[key] = param[item.interactFn[key]] + } + }) + } else { + const index = chartEditStore.fetchTargetIndex(item.interactComponentId) + if (index === -1) return + const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams) + + Object.keys(item.interactFn).forEach(key => { + if (Params.value[key]) { + Params.value[key] = param[item.interactFn[key]] + } + if (Header.value[key]) { + Header.value[key] = param[item.interactFn[key]] + } + }) + } }) } - // 联动事件触发的 type 变更时,清除当前绑定内容 export const clearInteractEvent = (chartConfig: CreateComponentType) => { From cd1f8e259afdf7c857aa6c1f2333e459e40976b2 Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:08:52 +0800 Subject: [PATCH 06/24] =?UTF-8?q?fix:=20=E6=95=B0=E6=8D=AE=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/preview/components/PreviewRenderList/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/preview/components/PreviewRenderList/index.vue b/src/views/preview/components/PreviewRenderList/index.vue index f685f983..07675175 100644 --- a/src/views/preview/components/PreviewRenderList/index.vue +++ b/src/views/preview/components/PreviewRenderList/index.vue @@ -74,7 +74,7 @@ const themeColor = computed(() => { // 组件渲染结束初始化数据池 clearMittDataPondMap() onMounted(() => { - initDataPond(chartEditStore.requestGlobalConfig) + initDataPond(useChartEditStore) }) </script> From 71acbc61883fb9cf5ea141f374692074818f1368 Mon Sep 17 00:00:00 2001 From: Ming <739803697@qq.com> Date: Wed, 7 Jun 2023 15:13:48 +0800 Subject: [PATCH 07/24] =?UTF-8?q?feat:=20=E7=BB=84=E4=BB=B6=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E5=AF=B9=E5=85=AC=E5=85=B1api=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChartEventInteraction/index.vue | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventInteraction/index.vue b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventInteraction/index.vue index b5a74bd4..614b3d15 100644 --- a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventInteraction/index.vue +++ b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEventInteraction/index.vue @@ -58,7 +58,7 @@ <help-outline-icon></help-outline-icon> </n-icon> </template> - <n-text>不支持「静态组件」</n-text> + <n-text>不支持「静态组件」支持「组件」「公共APi」</n-text> </n-tooltip> </template> <n-select @@ -89,7 +89,7 @@ </n-table> </setting-item-box> - <n-tag :bordered="false" type="primary"> 关联目标组件请求参数 </n-tag> + <n-tag :bordered="false" type="primary"> 关联目标请求参数 </n-tag> <setting-item-box :name="requestParamsItem" @@ -125,7 +125,7 @@ import { VNodeChild, computed } from 'vue' import { SelectOption, SelectGroupOption } from 'naive-ui' import { SettingItemBox, SettingItem, CollapseItem } from '@/components/Pages/ChartItemSetting' import { CreateComponentType, CreateComponentGroupType, ChartFrameEnum } from '@/packages/index.d' -import { RequestParamsTypeEnum } from '@/enums/httpEnum' +import { RequestParamsTypeEnum, RequestDataTypeEnum } from '@/enums/httpEnum' import { InteractEventOn, COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum' import { icon } from '@/plugins' import noData from '@/assets/images/canvas/noData.png' @@ -154,6 +154,11 @@ const option = computed(() => { // 绑定组件数据 request const fnGetRequest = (id: string | undefined, key: RequestParamsTypeEnum) => { if (!id) return {} + const globalConfigPindApr = chartEditStore.requestGlobalConfig.requestDataPond.find(item => { + return item.dataPondId === id + })?.dataPondRequestConfig.requestParams + + if (globalConfigPindApr) return globalConfigPindApr[key] return chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]?.request.requestParams[key] } @@ -178,12 +183,10 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => { iter: Array<CreateComponentType | CreateComponentGroupType>, val: CreateComponentType | CreateComponentGroupType ) => { - if (val.groupList && val.groupList.length > 0) { - iter.push(val) - } else { + if (!val.groupList && val.request.requestDataType === RequestDataTypeEnum.AJAX && val.request.requestUrl) { iter.push(val) } - return val.groupList ? [...iter, ...fnFlattern(val.groupList)] : iter + return val.groupList && val.groupList.length > 0 ? [...iter, ...fnFlattern(val.groupList)] : iter }, [] ) @@ -203,18 +206,26 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => { const mapOptionList = filterOptionList.map(item => ({ id: item.id, title: item.chartConfig.title, - disabled: false + disabled: false, + type: 'componentList' })) + const requestDataPond = chartEditStore.requestGlobalConfig.requestDataPond.map(item => ({ + id: item.dataPondId, + title: item.dataPondName, + disabled: false, + type: 'requestDataPond' + })) + const tarArr = requestDataPond.concat(mapOptionList) targetData.value.events.interactEvents?.forEach(iaItem => { - mapOptionList.forEach(optionItem => { + tarArr.forEach(optionItem => { if (optionItem.id === iaItem.interactComponentId) { optionItem.disabled = true } }) }) - return mapOptionList + return tarArr } // 新增模块 From f294d40769e077129a0d18be65f8d31c4ded6931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Thu, 8 Jun 2023 16:39:18 +0800 Subject: [PATCH 08/24] =?UTF-8?q?style:=20=E5=88=A0=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/http.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/api/http.ts b/src/api/http.ts index 0588049d..5da44856 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -163,7 +163,6 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req params = translateStr(params) // form 类型处理 let formData: FormData = new FormData() - formData.set('default', 'defaultData') // 类型处理 switch (requestParamsBodyType) { From 7fb65ff24c05abd4b0878d46fc50ad690753369a Mon Sep 17 00:00:00 2001 From: tnt group <dodu@live.cn> Date: Tue, 13 Jun 2023 10:27:08 +0800 Subject: [PATCH 09/24] =?UTF-8?q?feat:=20=E7=8E=AF=E5=BD=A2=E9=A5=BC?= =?UTF-8?q?=E5=9B=BE=E5=A2=9E=E5=8A=A0=E8=BD=A8=E9=81=93=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Charts/Pies/PieCircle/config.vue | 45 ++++++++++++------- .../Charts/Pies/PieCircle/index.vue | 4 +- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/packages/components/Charts/Pies/PieCircle/config.vue b/src/packages/components/Charts/Pies/PieCircle/config.vue index a3206946..38329dbc 100644 --- a/src/packages/components/Charts/Pies/PieCircle/config.vue +++ b/src/packages/components/Charts/Pies/PieCircle/config.vue @@ -7,6 +7,22 @@ </n-input-number> </SettingItem> </SettingItemBox> + <!-- 中心标题 --> + <SettingItemBox v-if="config.title" name="标题"> + <SettingItem name="颜色"> + <n-color-picker size="small" :modes="['hex']" v-model:value="config.title.textStyle.color"></n-color-picker> + </SettingItem> + <SettingItem name="字体大小"> + <n-input-number + v-model:value="config.title.textStyle.fontSize" + :min="0" + :step="1" + size="small" + placeholder="字体大小" + > + </n-input-number> + </SettingItem> + </SettingItemBox> <!-- Echarts 全局设置 --> <SettingItemBox name="进度条"> <SettingItem name="颜色"> @@ -31,24 +47,8 @@ ></n-color-picker> </SettingItem> </SettingItemBox> - <!-- 中心标题 --> - <SettingItemBox v-if="config.title" name="标题"> - <SettingItem name="颜色"> - <n-color-picker size="small" :modes="['hex']" v-model:value="config.title.textStyle.color"></n-color-picker> - </SettingItem> - <SettingItem name="字体大小"> - <n-input-number - v-model:value="config.title.textStyle.fontSize" - :min="0" - :step="1" - size="small" - placeholder="字体大小" - > - </n-input-number> - </SettingItem> - </SettingItemBox> <!-- 其他样式 --> - <SettingItemBox name="轨道样式"> + <SettingItemBox name="轨道"> <SettingItem name="颜色"> <n-color-picker size="small" :modes="['hex']" v-model:value="item.data[1].itemStyle.color"></n-color-picker> </SettingItem> @@ -69,6 +69,17 @@ v-model:value="item.data[1].itemStyle.shadowColor" ></n-color-picker> </SettingItem> + <SettingItem name="轨道宽度"> + <n-select + v-model:value="item.radius[0]" + :options="[ + { label: '窄', value: '75%' }, + { label: '中', value: '60%' }, + { label: '宽', value: '45%' }, + { label: '更宽', value: '30%' } + ]" + /> + </SettingItem> </SettingItemBox> </CollapseItem> </template> diff --git a/src/packages/components/Charts/Pies/PieCircle/index.vue b/src/packages/components/Charts/Pies/PieCircle/index.vue index 26bda2a7..bf6250cd 100644 --- a/src/packages/components/Charts/Pies/PieCircle/index.vue +++ b/src/packages/components/Charts/Pies/PieCircle/index.vue @@ -41,7 +41,7 @@ const option = reactive({ const dataHandle = (newData: any) => { const d = parseFloat(`${newData}`) * 100 let config = props.chartConfig.option - config.title.text = d.toFixed(2) + '%' + config.title.text = `${+d.toFixed(2)}%` config.series[0].data[0].value[0] = d config.series[0].data[1].value[0] = 100 - d option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes) @@ -68,7 +68,7 @@ watch( useChartDataFetch(props.chartConfig, useChartEditStore, (resData: number) => { let d = parseFloat(`${resData}`) * 100 // @ts-ignore - option.value.title.text = d.toFixed(2) + '%' + option.value.title.text = `${+d.toFixed(2)}%` // @ts-ignore option.value.series[0].data[0].value[0] = d // @ts-ignore From d018d6babca09b5e3e53f78b5abfc367eabc96ac Mon Sep 17 00:00:00 2001 From: tnt group <dodu@live.cn> Date: Wed, 14 Jun 2023 07:54:36 +0800 Subject: [PATCH 10/24] =?UTF-8?q?chore:=20=E8=AE=BE=E7=BD=AE=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=A1=86size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/components/Charts/Pies/PieCircle/config.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/components/Charts/Pies/PieCircle/config.vue b/src/packages/components/Charts/Pies/PieCircle/config.vue index 38329dbc..f343aa23 100644 --- a/src/packages/components/Charts/Pies/PieCircle/config.vue +++ b/src/packages/components/Charts/Pies/PieCircle/config.vue @@ -72,6 +72,7 @@ <SettingItem name="轨道宽度"> <n-select v-model:value="item.radius[0]" + size="small" :options="[ { label: '窄', value: '75%' }, { label: '中', value: '60%' }, From d9264e5164fb46f5892eb05bee65ca8f857a4ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Thu, 15 Jun 2023 11:45:41 +0000 Subject: [PATCH 11/24] =?UTF-8?q?!171=20fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A7?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=B2=A1=E6=9C=89legend=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8A=A5settting=20color=E9=94=99=E8=AF=AF?= =?UTF-8?q?=20Merge=20pull=20request=20!171=20from=20h5coder/h5coder-fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Pages/ChartItemSetting/GlobalSetting.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Pages/ChartItemSetting/GlobalSetting.vue b/src/components/Pages/ChartItemSetting/GlobalSetting.vue index 81f9d3d7..68e3fb00 100644 --- a/src/components/Pages/ChartItemSetting/GlobalSetting.vue +++ b/src/components/Pages/ChartItemSetting/GlobalSetting.vue @@ -391,8 +391,12 @@ const visualMap = computed(() => { // 监听legend color颜色改变type = scroll的颜色 watch(() => legend.value && legend.value.textStyle.color, (newVal) => { if (legend.value && newVal) { - legend.value.pageTextStyle.color = newVal - } + if (!legend.value.pageTextStyle) { + legend.value.pageTextStyle = { color: newVal } + } else { + legend.value.pageTextStyle.color = newVal + } + } }, { immediate: true, deep: true, From a672aab0b912cd2a16b57d01ef589e9fef48764b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Thu, 15 Jun 2023 11:49:54 +0000 Subject: [PATCH 12/24] =?UTF-8?q?!169=20feat:=E6=A0=87=E7=AD=BE=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=80=BC?= =?UTF-8?q?=E9=80=89=E9=A1=B9=20Merge=20pull=20request=20!169=20from=20h5c?= =?UTF-8?q?oder/dev-h5coder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Informations/Inputs/InputsTab/config.vue | 5 ++++- .../components/Informations/Inputs/InputsTab/index.vue | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/packages/components/Informations/Inputs/InputsTab/config.vue b/src/packages/components/Informations/Inputs/InputsTab/config.vue index 39d9cad5..c6e8c7c9 100644 --- a/src/packages/components/Informations/Inputs/InputsTab/config.vue +++ b/src/packages/components/Informations/Inputs/InputsTab/config.vue @@ -1,8 +1,11 @@ <template> <collapse-item name="标签页配置" :expanded="true"> - <setting-item-box name="默认值" :alone="true"> + <setting-item-box name="标签类型" :alone="true"> <n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" /> </setting-item-box> + <setting-item-box name="默认值" :alone="true"> + <n-select size="small" v-model:value="optionData.tabLabel" value-field="label" :options="optionData.dataset" /> + </setting-item-box> </collapse-item> </template> diff --git a/src/packages/components/Informations/Inputs/InputsTab/index.vue b/src/packages/components/Informations/Inputs/InputsTab/index.vue index d75bde97..a02900b9 100644 --- a/src/packages/components/Informations/Inputs/InputsTab/index.vue +++ b/src/packages/components/Informations/Inputs/InputsTab/index.vue @@ -1,5 +1,5 @@ <template> - <n-tabs :type="option.value.tabType" @update:value="onChange"> + <n-tabs :type="option.value.tabType" @update:value="onChange" :default-value="option.value.tabLabel"> <n-tab v-for="(item, index) in option.value.dataset" :name="item.label" :key="index"> {{ item.label }} </n-tab> </n-tabs> </template> From 9e70e9ca093d751cb494a14440084df6523fe709 Mon Sep 17 00:00:00 2001 From: dingxs <dingronaldo@outlook.com> Date: Mon, 19 Jun 2023 14:35:17 +0800 Subject: [PATCH 13/24] =?UTF-8?q?feat:=E6=97=B6=E9=97=B4=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E5=80=BC=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Informations/Inputs/InputsDate/config.ts | 13 +- .../Informations/Inputs/InputsDate/config.vue | 135 ++++++++++++++++-- .../Informations/Inputs/InputsDate/index.vue | 135 ++++++++++++------ .../Inputs/InputsDate/interact.ts | 31 ++++ 4 files changed, 255 insertions(+), 59 deletions(-) mode change 100644 => 100755 src/packages/components/Informations/Inputs/InputsDate/config.ts mode change 100644 => 100755 src/packages/components/Informations/Inputs/InputsDate/config.vue mode change 100644 => 100755 src/packages/components/Informations/Inputs/InputsDate/index.vue mode change 100644 => 100755 src/packages/components/Informations/Inputs/InputsDate/interact.ts diff --git a/src/packages/components/Informations/Inputs/InputsDate/config.ts b/src/packages/components/Informations/Inputs/InputsDate/config.ts old mode 100644 new mode 100755 index e8f1d233..02b639c6 --- a/src/packages/components/Informations/Inputs/InputsDate/config.ts +++ b/src/packages/components/Informations/Inputs/InputsDate/config.ts @@ -4,7 +4,7 @@ import { PublicConfigClass } from '@/packages/public' import { CreateComponentType } from '@/packages/index.d' import { chartInitConfig } from '@/settings/designSetting' import { COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum' -import { interactActions, ComponentInteractEventEnum } from './interact' +import { interactActions, ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum } from './interact' import { InputsDateConfig } from './index' export const option = { @@ -12,9 +12,14 @@ export const option = { [COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATE, // 下拉展示 isPanel: 0, - dataset: dayjs().valueOf(), - differValue: 0 - + // 默认值 + dataset: dayjs().valueOf() as number | number[] | null, + // 默认值类型 + defaultType: DefaultTypeEnum.STATIC, + // 动态默认值偏移单位 + differUnit: [DifferUnitEnum.DAY, DifferUnitEnum.DAY], + // 动态默认值偏移值 + differValue: [0, 0] } export default class Config extends PublicConfigClass implements CreateComponentType { diff --git a/src/packages/components/Informations/Inputs/InputsDate/config.vue b/src/packages/components/Informations/Inputs/InputsDate/config.vue old mode 100644 new mode 100755 index 0d806518..8fa9adaf --- a/src/packages/components/Informations/Inputs/InputsDate/config.vue +++ b/src/packages/components/Informations/Inputs/InputsDate/config.vue @@ -8,39 +8,67 @@ <collapse-item name="时间配置" :expanded="true"> <setting-item-box name="基础"> <setting-item name="类型"> - <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions" /> + <n-select v-model:value="optionData.componentInteractEventKey" size="small" :options="datePickerTypeOptions" + @update:value="datePickerTypeUpdate"/> </setting-item> </setting-item-box> - <setting-item-box name="默认值" :alone="true"> - <n-date-picker size="small" v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" /> - </setting-item-box> + <setting-item-box name="默认值"> + <setting-item name="类型"> + <n-select v-model:value="optionData.defaultType" size="small" :options="defaultTypeOptions" + @update:value="defaultTypeUpdate" /> + </setting-item> - <setting-item-box :alone="true"> + </setting-item-box> + <setting-item-box v-if="optionData.defaultType == DefaultTypeEnum.STATIC" :alone="true"> + <setting-item name="静态默认值"> + <n-date-picker size="small" clearable v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" /> + </setting-item> + </setting-item-box> + <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.DYNAMIC" > <template #name> - <n-text>动态</n-text> + <n-text></n-text> <n-tooltip trigger="hover"> <template #trigger> <n-icon size="21" :depth="3"> <help-outline-icon></help-outline-icon> </n-icon> </template> - <n-text>动态值不为0时,默认值:取当天时间相加当前值</n-text> + <n-text>打开页面时浏览器操作系统的系统时间+偏移量(单位)</n-text> </n-tooltip> </template> - <n-input-number v-model:value="optionData.differValue" class="input-num-width" size="small" :min="-40" :max="40"> - <template #suffix> 天 </template> - </n-input-number> + <setting-item :name="differValueName"> + <n-input-number v-model:value="optionData.differValue[0]" class="input-num-width" size="small"> + <template #suffix> + {{DifferUnitObject[optionData.differUnit[0]]}} + </template> + </n-input-number> + </setting-item> + <setting-item :name="differUnitName"> + <n-select v-model:value="optionData.differUnit[0]" size="small" :options="differUnitOptions" /> + </setting-item> + <setting-item v-if="isRange" name="结束值动态偏移量"> + <n-input-number v-model:value="optionData.differValue[1]" class="input-num-width" size="small"> + <template #suffix> + {{DifferUnitObject[optionData.differUnit[1]]}} + </template> + </n-input-number> + </setting-item> + <setting-item v-if="isRange" name="结束值偏移单位"> + <n-select v-model:value="optionData.differUnit[1]" size="small" :options="differUnitOptions" /> + </setting-item> </setting-item-box> + </collapse-item> </template> <script lang="ts" setup> -import { PropType } from 'vue' +import { PropType, computed } from 'vue' import { icon } from '@/plugins' import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' import { option } from './config' -import { ComponentInteractEventEnum } from './interact' +import { ComponentInteractEventEnum, DefaultTypeEnum, DifferUnitEnum, DifferUnitObject } from './interact' +import dayjs from "dayjs"; const { HelpOutlineIcon } = icon.ionicons5 @@ -100,4 +128,87 @@ const datePickerTypeOptions = [ value: ComponentInteractEventEnum.QUARTER_RANGE } ] + +const defaultTypeOptions = [ + { + label: '静态', + value: DefaultTypeEnum.STATIC + }, + { + label: '动态', + value: DefaultTypeEnum.DYNAMIC + }, + { + label: '无', + value: DefaultTypeEnum.NONE + } +] + + +const differUnitOptions = [ + // ManipulateType + { + value: DifferUnitEnum.DAY, + label: DifferUnitObject[DifferUnitEnum.DAY] + }, + { + value: DifferUnitEnum.WEEK, + label: DifferUnitObject[DifferUnitEnum.WEEK] + }, + { + value: DifferUnitEnum.MONTH, + label: DifferUnitObject[DifferUnitEnum.MONTH] + }, + { + value: DifferUnitEnum.QUARTER, + label: DifferUnitObject[DifferUnitEnum.QUARTER] + }, + { + value: DifferUnitEnum.YEAR, + label: DifferUnitObject[DifferUnitEnum.YEAR] + }, + { + value: DifferUnitEnum.HOUR, + label: DifferUnitObject[DifferUnitEnum.HOUR] + }, + { + value: DifferUnitEnum.MINUTE, + label: DifferUnitObject[DifferUnitEnum.MINUTE] + }, + { + value: DifferUnitEnum.SECOND, + label: DifferUnitObject[DifferUnitEnum.SECOND] + }, + { + value: DifferUnitEnum.MILLISECOND, + label: DifferUnitObject[DifferUnitEnum.MILLISECOND] + } +] + + +const isRange = computed(() => { + return props.optionData.componentInteractEventKey.endsWith('range') +}) + +const differValueName = computed(() => { + return isRange.value ? '开始值动态偏移量' : '动态偏移量' +}) + +const differUnitName = computed(() => { + return isRange.value ? '开始值偏移单位' : '偏移单位' +}) + +const datePickerTypeUpdate = () => { + props.optionData.dataset = isRange.value ? [dayjs().valueOf(), dayjs().valueOf()] : dayjs().valueOf() +} + +const defaultTypeUpdate = (v: string) => { + if (v === DefaultTypeEnum.STATIC) { + datePickerTypeUpdate() + } else { + // DefaultTypeEnum. + props.optionData.dataset = null + } +} + </script> diff --git a/src/packages/components/Informations/Inputs/InputsDate/index.vue b/src/packages/components/Informations/Inputs/InputsDate/index.vue old mode 100644 new mode 100755 index 3800590f..a8e16bc1 --- a/src/packages/components/Informations/Inputs/InputsDate/index.vue +++ b/src/packages/components/Informations/Inputs/InputsDate/index.vue @@ -1,6 +1,7 @@ <template> <n-date-picker v-model:value="option.dataset" + clearable :panel="!!chartConfig.option.isPanel" :type="chartConfig.option.componentInteractEventKey" :style="`width:${w}px;`" @@ -9,13 +10,15 @@ </template> <script setup lang="ts"> -import { PropType, toRefs, ref, shallowReactive, watch } from 'vue' -import dayjs from 'dayjs' +import { computed, PropType, ref, shallowReactive, toRefs, watch } from 'vue' import { CreateComponentType } from '@/packages/index.d' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartInteract } from '@/hooks' import { InteractEventOn } from '@/enums/eventEnum' -import { ComponentInteractParamsEnum } from './interact' +import {ComponentInteractEventEnum, ComponentInteractParamsEnum, DefaultTypeEnum} from './interact' +import dayjs, {ManipulateType} from 'dayjs' +import quarterOfYear from 'dayjs/plugin/quarterOfYear'; + const props = defineProps({ chartConfig: { @@ -31,61 +34,107 @@ const option = shallowReactive({ dataset: props.chartConfig.option.dataset }) +const isRange = computed(() => { + return props.chartConfig.option.componentInteractEventKey.endsWith('range') +}) + // 监听事件改变 -const onChange = (v: number | number[]) => { - if (v instanceof Array) { +const onChange = (v: number | number[] | null) => { + if (isRange.value) { + let dateStart = null + let dateEnd = null + let daterange = null + if(v instanceof Array){ + dateStart = v[0] + dateEnd = v[1] + daterange = `${v[0]}-${v[1]}` + } // 存储到联动数据 useChartInteract( - props.chartConfig, - useChartEditStore, - { - [ComponentInteractParamsEnum.DATE_START]: v[0] || dayjs().valueOf(), - [ComponentInteractParamsEnum.DATE_END]: v[1] || dayjs().valueOf(), - [ComponentInteractParamsEnum.DATE_RANGE]: `${v[0] || dayjs().valueOf()}-${v[1] || dayjs().valueOf()}` - }, - InteractEventOn.CHANGE + props.chartConfig, + useChartEditStore, + { + [ComponentInteractParamsEnum.DATE_START]: dateStart, + [ComponentInteractParamsEnum.DATE_END]: dateEnd, + [ComponentInteractParamsEnum.DATE_RANGE]: daterange + }, + InteractEventOn.CHANGE ) } else { // 存储到联动数据 useChartInteract( - props.chartConfig, - useChartEditStore, - { [ComponentInteractParamsEnum.DATE]: v || dayjs().valueOf() }, - InteractEventOn.CHANGE + props.chartConfig, + useChartEditStore, + { [ComponentInteractParamsEnum.DATE]: v }, + InteractEventOn.CHANGE ) } } -watch( - () => props.chartConfig.option.dataset, - (newData: number | number[]) => { - option.dataset = newData - // 关联目标组件首次请求带上默认内容 - onChange(newData) - }, - { - immediate: true +const getDiffDate = (type: ComponentInteractEventEnum, date: dayjs.Dayjs) => { + // 注册 quarterOfYear 插件 + dayjs.extend(quarterOfYear) + switch (type) { + case ComponentInteractEventEnum.DATE: + case ComponentInteractEventEnum.DATE_RANGE: + date = date.startOf('day') + break + case ComponentInteractEventEnum.MONTH: + case ComponentInteractEventEnum.MONTH_RANGE: + date = date.startOf('month') + break + case ComponentInteractEventEnum.YEAR: + case ComponentInteractEventEnum.YEAR_RANGE: + date = date.startOf('year') + break + case ComponentInteractEventEnum.QUARTER: + case ComponentInteractEventEnum.QUARTER_RANGE: + date = date.startOf('quarter') + break + default: + break } -) + return date +} -// 手动更新 watch( - () => props.chartConfig.option.differValue, - (newData: number) => { - if (props.chartConfig.option.differValue === 0) return - if (typeof option.dataset === 'object') { - option.dataset[0] = dayjs().add(newData, 'day').valueOf() - option.dataset[1] = dayjs().add(newData, 'day').valueOf() - } else { - option.dataset = dayjs().add(newData, 'day').valueOf() + () => { + return { + type: props.chartConfig.option.componentInteractEventKey as ComponentInteractEventEnum, + defaultType: props.chartConfig.option.defaultType as string, + differValue: props.chartConfig.option.differValue as number[], + differUnit: props.chartConfig.option.differUnit as ManipulateType[], + dataset: props.chartConfig.option.dataset as number | number[] | null, + }; + }, + (newData, oldData) => { + const hasTypeChanged = newData.type !== oldData?.type; + const hasDefaultTypeChanged = newData.defaultType !== oldData?.defaultType; + const hasDifferValueChanged = newData.differValue !== oldData?.differValue; + const hasDifferUnitChanged = newData.differUnit !== oldData?.differUnit; + + if (hasTypeChanged || hasDefaultTypeChanged || hasDifferValueChanged || hasDifferUnitChanged) { + if (newData.defaultType === DefaultTypeEnum.NONE) { + props.chartConfig.option.dataset = null; + } else if (newData.defaultType === DefaultTypeEnum.DYNAMIC) { + let date = dayjs(); + if (isRange.value) { + props.chartConfig.option.dataset = [ + getDiffDate(newData.type,date.add(newData.differValue[0], newData.differUnit[0])).valueOf(), + getDiffDate(newData.type,date.add(newData.differValue[1], newData.differUnit[1])).valueOf(), + ]; + } else { + props.chartConfig.option.dataset = getDiffDate(newData.type,date.add(newData.differValue[0], newData.differUnit[0])).valueOf() + } + } + } + option.dataset = props.chartConfig.option.dataset; + onChange(option.dataset); + }, + { + immediate: true, } - // 关联目标组件首次请求带上默认内容 - onChange(newData) - }, - { - immediate: true - } -) +); </script> <style lang="scss" scoped> diff --git a/src/packages/components/Informations/Inputs/InputsDate/interact.ts b/src/packages/components/Informations/Inputs/InputsDate/interact.ts old mode 100644 new mode 100755 index a466c989..6690f0eb --- a/src/packages/components/Informations/Inputs/InputsDate/interact.ts +++ b/src/packages/components/Informations/Inputs/InputsDate/interact.ts @@ -22,6 +22,37 @@ export enum ComponentInteractParamsEnum { DATE_RANGE = 'daterange' } +export enum DefaultTypeEnum { + NONE = "none", + STATIC = "static", + DYNAMIC = "dynamic" +} + +export enum DifferUnitEnum { + DAY = 'd', + WEEK = 'w', + MONTH = 'M', + QUARTER = 'Q', + YEAR = 'y', + HOUR = 'h', + MINUTE = 'm', + SECOND = 's', + MILLISECOND = 'ms', +} + +export const DifferUnitObject = { + // https://day.js.org/docs/en/manipulate/add + [DifferUnitEnum.DAY]: '天', + [DifferUnitEnum.WEEK]: '周', + [DifferUnitEnum.MONTH]: '月', + [DifferUnitEnum.QUARTER]: '季度', + [DifferUnitEnum.YEAR]: '年', + [DifferUnitEnum.HOUR]: '小时', + [DifferUnitEnum.MINUTE]: '分钟', + [DifferUnitEnum.SECOND]: '秒', + [DifferUnitEnum.MILLISECOND]: '毫秒', +} + const time = [ { value: ComponentInteractParamsEnum.DATE, From 1a0bcd4443da76be4f4769a4d865a2529da8f5a4 Mon Sep 17 00:00:00 2001 From: dingxs <dingronaldo@outlook.com> Date: Mon, 19 Jun 2023 14:39:00 +0800 Subject: [PATCH 14/24] =?UTF-8?q?fix:=E7=94=A8in=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=98=AF=E5=90=A6=E5=85=B7=E6=9C=89=E6=9F=90?= =?UTF-8?q?=E4=B8=AA=E7=89=B9=E5=AE=9A=E7=9A=84key=EF=BC=8C=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AFvalue=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=BD=93valu?= =?UTF-8?q?e=E4=B8=BAnull=E6=97=B6=E6=B0=B8=E8=BF=9C=E5=BE=97=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useChartInteract.hook.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hooks/useChartInteract.hook.ts b/src/hooks/useChartInteract.hook.ts index aa0b1ed6..dce0d25b 100644 --- a/src/hooks/useChartInteract.hook.ts +++ b/src/hooks/useChartInteract.hook.ts @@ -30,10 +30,10 @@ export const useChartInteract = ( const { Params, Header } = toRefs(chartEditStore.requestGlobalConfig.requestDataPond[globalConfigPindAprndex].dataPondRequestConfig.requestParams) Object.keys(item.interactFn).forEach(key => { - if (Params.value[key]) { + if (key in Params.value) { Params.value[key] = param[item.interactFn[key]] } - if (Header.value[key]) { + if (key in Header.value) { Header.value[key] = param[item.interactFn[key]] } }) @@ -43,10 +43,10 @@ export const useChartInteract = ( const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams) Object.keys(item.interactFn).forEach(key => { - if (Params.value[key]) { + if (key in Params.value) { Params.value[key] = param[item.interactFn[key]] } - if (Header.value[key]) { + if (key in Header.value) { Header.value[key] = param[item.interactFn[key]] } }) From 11c6d04c65c956ec24d06d46da6f6888c3e696d3 Mon Sep 17 00:00:00 2001 From: tnt group <dodu@live.cn> Date: Fri, 23 Jun 2023 11:54:52 +0800 Subject: [PATCH 15/24] =?UTF-8?q?feat:=20=E4=B8=BA=20naive-ui=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E4=BE=9B=E6=84=9F=E7=9F=A5=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 07a4c65b..1c7ef341 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "esModuleInterop": true, "skipLibCheck": true, "lib": ["es6", "ESNext", "dom"], - "types": ["vite/client"], + "types": ["vite/client", "naive-ui/volar"], "paths": { "@/*": ["src/*"], "/#/*": ["types/*"] From adf70047278670b288ce64cf3dd53cce135cd82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 27 Jun 2023 17:48:08 +0800 Subject: [PATCH 16/24] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=20pr=5F173=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Informations/Inputs/InputsDate/config.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/components/Informations/Inputs/InputsDate/config.vue b/src/packages/components/Informations/Inputs/InputsDate/config.vue index 8fa9adaf..228fa494 100755 --- a/src/packages/components/Informations/Inputs/InputsDate/config.vue +++ b/src/packages/components/Informations/Inputs/InputsDate/config.vue @@ -20,7 +20,7 @@ </setting-item> </setting-item-box> - <setting-item-box v-if="optionData.defaultType == DefaultTypeEnum.STATIC" :alone="true"> + <setting-item-box v-if="optionData.defaultType === DefaultTypeEnum.STATIC" :alone="true"> <setting-item name="静态默认值"> <n-date-picker size="small" clearable v-model:value="optionData.dataset" :type="optionData.componentInteractEventKey" /> </setting-item> @@ -34,7 +34,7 @@ <help-outline-icon></help-outline-icon> </n-icon> </template> - <n-text>打开页面时浏览器操作系统的系统时间+偏移量(单位)</n-text> + <span>打开页面时浏览器操作系统的系统时间+偏移量(单位)</span> </n-tooltip> </template> <setting-item :name="differValueName"> From 952e61bbba03443cbb55e021ed51fe12f12454be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 27 Jun 2023 17:54:17 +0800 Subject: [PATCH 17/24] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20axios=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/axios.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/axios.ts b/src/api/axios.ts index 65ff033c..07860458 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -1,4 +1,4 @@ -import axios, { AxiosResponse, AxiosRequestConfig } from 'axios' +import axios, { AxiosResponse, InternalAxiosRequestConfig, AxiosError } from 'axios' import { ResultEnum } from "@/enums/httpEnum" import { ErrorPageNameMap } from "@/enums/pageEnum" import { redirectErrorPage } from '@/utils' @@ -9,10 +9,10 @@ const axiosInstance = axios.create({ }) axiosInstance.interceptors.request.use( - (config: AxiosRequestConfig) => { + (config: InternalAxiosRequestConfig) => { return config }, - (error: AxiosRequestConfig) => { + (error: AxiosError) => { Promise.reject(error) } ) From 9f3ca6b614fdd5f70ac52ee9544589d5c74b1e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Tue, 27 Jun 2023 18:11:37 +0800 Subject: [PATCH 18/24] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20TS=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/components/Decorates/Mores/FlipperNumber/index.vue | 2 +- tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/components/Decorates/Mores/FlipperNumber/index.vue b/src/packages/components/Decorates/Mores/FlipperNumber/index.vue index 9e5c0ca2..0c4ae010 100644 --- a/src/packages/components/Decorates/Mores/FlipperNumber/index.vue +++ b/src/packages/components/Decorates/Mores/FlipperNumber/index.vue @@ -63,7 +63,7 @@ watch( () => props.chartConfig.option, newVal => { try { - updateDatasetHandler((newVal as OptionType).dataset) + updateDatasetHandler((newVal as any as OptionType).dataset) } catch (error) { console.log(error) } diff --git a/tsconfig.json b/tsconfig.json index 1c7ef341..07a4c65b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "esModuleInterop": true, "skipLibCheck": true, "lib": ["es6", "ESNext", "dom"], - "types": ["vite/client", "naive-ui/volar"], + "types": ["vite/client"], "paths": { "@/*": ["src/*"], "/#/*": ["types/*"] From 1c0a57f5d965468f99e86b806a70bb77c266d43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E8=83=9C?= <857949055@qq.com> Date: Thu, 29 Jun 2023 17:39:17 +0800 Subject: [PATCH 19/24] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E7=BB=84=E4=BB=B6=E6=97=8B=E8=BD=AC=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=86=8D=E7=BB=84=E5=90=88=E5=88=86=E7=BB=84=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E4=BC=9A=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.解决单个组件旋转后,和其他组件组合分组后再次旋转,进行预览后该分组会错位的问题 2.解决TS类型报错 --- src/views/preview/components/PreviewRenderGroup/index.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/views/preview/components/PreviewRenderGroup/index.vue b/src/views/preview/components/PreviewRenderGroup/index.vue index 354fa29c..fd7b04c3 100644 --- a/src/views/preview/components/PreviewRenderGroup/index.vue +++ b/src/views/preview/components/PreviewRenderGroup/index.vue @@ -46,14 +46,11 @@ const props = defineProps({ required: true }, groupIndex: { - type: Number, + type: [String, Number], required: true } }) </script> <style lang="scss" scoped> -.chart-item { - position: absolute; -} </style> From d24daf5b1540abdc9440c10b2afe999d5d243071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E8=83=9C?= <857949055@qq.com> Date: Thu, 29 Jun 2023 18:45:59 +0800 Subject: [PATCH 20/24] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=A2=84?= =?UTF-8?q?=E8=AE=BE=E6=BB=A4=E9=95=9C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.滤镜变换:新增了快捷预设滤镜 --- .../Pages/ChartItemSetting/StylesSetting.vue | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/components/Pages/ChartItemSetting/StylesSetting.vue b/src/components/Pages/ChartItemSetting/StylesSetting.vue index 27275449..064f2fff 100644 --- a/src/components/Pages/ChartItemSetting/StylesSetting.vue +++ b/src/components/Pages/ChartItemSetting/StylesSetting.vue @@ -69,6 +69,22 @@ </setting-item> </setting-item-box> + <!-- 预设滤镜 --> + <div v-if="presetImageList.length" class="preset-filter"> + <n-image + v-for="(item, index) in presetImageList" + :key="index" + :class="{ 'active-preset': item.hueRotate === chartStyles.hueRotate }" + :style="{ filter: `hue-rotate(${item.hueRotate}deg)` }" + :src="item.src" + class="preset-img" + width="70" + height="50" + preview-disabled + object-fit="fill" + @click="() => (chartStyles.hueRotate = item.hueRotate)"></n-image> + </div> + <!-- 混合模式 --> <setting-item-box v-if="!isCanvas" :alone="true"> <template #name> @@ -149,10 +165,12 @@ </template> <script setup lang="ts"> -import { PropType } from 'vue' +import {ref, PropType} from 'vue' import { PickCreateComponentType, BlendModeEnumList } from '@/packages/index.d' import { SettingItemBox, SettingItem, CollapseItem } from '@/components/Pages/ChartItemSetting' import { icon } from '@/plugins' +import logoImg from '@/assets/logo.png' +import {presetFilterData} from "@/store/modules/chartEditStore/chartEditStore"; const props = defineProps({ isGroup: { @@ -179,6 +197,40 @@ const sliderFormatTooltip = (v: string) => { const degFormatTooltip = (v: string) => { return `${v}deg` } +// 预设滤镜 +interface presetImageData { + index: number, + src: string, + hueRotate: number +} +const presetImageList = ref([] as presetImageData[]) +for(let i = 1; i <= 12; i ++) { + presetImageList.value.push({ + index: i, + src: logoImg, + hueRotate: i * 30 + }) +} </script> -<style lang="scss" scoped></style> +<style lang="scss" scoped> +// 预设滤镜 +.preset-filter { + margin: 20px 0 10px 0; + display: flex; + flex-wrap: wrap; + justify-content: space-between; + .preset-img { + margin-bottom: 10px; + cursor: pointer; + border-radius: 6px; + transition: 0.2s all; + &:hover { + box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); + } + } + .active-preset { + box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); + } +} +</style> From 52c29298892d419b942f089cef2539f68fe457f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 8 Jul 2023 18:36:36 +0800 Subject: [PATCH 21/24] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=BB=A4?= =?UTF-8?q?=E9=95=9C=E9=A2=84=E8=AE=BE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/ChartItemSetting/StylesSetting.vue | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/components/Pages/ChartItemSetting/StylesSetting.vue b/src/components/Pages/ChartItemSetting/StylesSetting.vue index 064f2fff..efb1d653 100644 --- a/src/components/Pages/ChartItemSetting/StylesSetting.vue +++ b/src/components/Pages/ChartItemSetting/StylesSetting.vue @@ -72,17 +72,17 @@ <!-- 预设滤镜 --> <div v-if="presetImageList.length" class="preset-filter"> <n-image - v-for="(item, index) in presetImageList" - :key="index" - :class="{ 'active-preset': item.hueRotate === chartStyles.hueRotate }" - :style="{ filter: `hue-rotate(${item.hueRotate}deg)` }" - :src="item.src" - class="preset-img" - width="70" - height="50" - preview-disabled - object-fit="fill" - @click="() => (chartStyles.hueRotate = item.hueRotate)"></n-image> + class="preset-img" + width="46" + preview-disabled + object-fit="scale-down" + v-for="(item, index) in presetImageList" + :key="index" + :class="{ 'active-preset': item.hueRotate === chartStyles.hueRotate }" + :style="{ filter: `hue-rotate(${item.hueRotate}deg)` }" + :src="item.src" + @click="() => (chartStyles.hueRotate = item.hueRotate)" + ></n-image> </div> <!-- 混合模式 --> @@ -165,12 +165,12 @@ </template> <script setup lang="ts"> -import {ref, PropType} from 'vue' +import { ref, PropType } from 'vue' import { PickCreateComponentType, BlendModeEnumList } from '@/packages/index.d' import { SettingItemBox, SettingItem, CollapseItem } from '@/components/Pages/ChartItemSetting' import { icon } from '@/plugins' import logoImg from '@/assets/logo.png' -import {presetFilterData} from "@/store/modules/chartEditStore/chartEditStore"; +import { useDesignStore } from '@/store/modules/designStore/designStore' const props = defineProps({ isGroup: { @@ -193,18 +193,21 @@ const { HelpOutlineIcon } = icon.ionicons5 const sliderFormatTooltip = (v: string) => { return `${(parseFloat(v) * 100).toFixed(0)}%` } + // 角度格式化 const degFormatTooltip = (v: string) => { return `${v}deg` } + // 预设滤镜 interface presetImageData { - index: number, - src: string, + index: number + src: string hueRotate: number } + const presetImageList = ref([] as presetImageData[]) -for(let i = 1; i <= 12; i ++) { +for (let i = 1; i <= 12; i++) { presetImageList.value.push({ index: i, src: logoImg, @@ -222,15 +225,16 @@ for(let i = 1; i <= 12; i ++) { justify-content: space-between; .preset-img { margin-bottom: 10px; - cursor: pointer; + padding: 2px; border-radius: 6px; transition: 0.2s all; + cursor: pointer; &:hover { - box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); + box-shadow: 0 0 0 2px #66a9c9; } } .active-preset { - box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2); + box-shadow: 0 0 0 2px #66a9c9; } } </style> From 3e1477ee0de2615a2560e766c179b3a001c542dc Mon Sep 17 00:00:00 2001 From: xlys999 <xlys998@163.com> Date: Mon, 3 Jul 2023 14:10:00 +0000 Subject: [PATCH 22/24] =?UTF-8?q?update=20src/views/chart/ContentEdit/comp?= =?UTF-8?q?onents/EditRule/index.vue.=20=E5=9D=90=E6=A0=87=E5=B0=BA?= =?UTF-8?q?=E5=88=BB=E5=BA=A6=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xlys999 <xlys998@163.com> --- src/views/chart/ContentEdit/components/EditRule/index.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/chart/ContentEdit/components/EditRule/index.vue b/src/views/chart/ContentEdit/components/EditRule/index.vue index e200bee7..521ac009 100644 --- a/src/views/chart/ContentEdit/components/EditRule/index.vue +++ b/src/views/chart/ContentEdit/components/EditRule/index.vue @@ -159,9 +159,11 @@ const dragCanvas = (e: any) => { const canvasBox = () => { const layoutDom = document.getElementById('go-chart-edit-layout') if (layoutDom) { + // 此处减去滚动条的宽度和高度 + const scrollW = 20 return { - height: layoutDom.clientHeight - 25, - width: layoutDom.clientWidth + height: layoutDom.clientHeight - scrollW, + width: layoutDom.clientWidth - scrollW } } return { From 02a96387a40a95d64ee0f54254958f5d27cedf2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 8 Jul 2023 21:18:37 +0800 Subject: [PATCH 23/24] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=94=BE=E5=A4=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePreviewScale.hook.ts | 434 +++++++++++------------ src/views/preview/hooks/useScale.hook.ts | 166 +++++---- src/views/preview/suspenseIndex.vue | 5 +- src/views/preview/utils/index.ts | 5 +- src/views/preview/utils/keyboard.ts | 32 ++ 5 files changed, 355 insertions(+), 287 deletions(-) create mode 100644 src/views/preview/utils/keyboard.ts diff --git a/src/hooks/usePreviewScale.hook.ts b/src/hooks/usePreviewScale.hook.ts index 066f6b66..9d8bcb78 100644 --- a/src/hooks/usePreviewScale.hook.ts +++ b/src/hooks/usePreviewScale.hook.ts @@ -1,218 +1,218 @@ -import throttle from 'lodash/throttle' - -// 拆出来是为了更好的分离单独复用 - -// * 屏幕缩放适配(两边留白) -export const usePreviewFitScale = ( - width: number, - height: number, - scaleDom: HTMLElement | null, - callback?: (scale: { - width: number; - height: number; - }) => void -) => { - // * 画布尺寸(px) - const baseWidth = width - const baseHeight = height - - // * 默认缩放值 - const scale = { - width: 1, - height: 1, - } - - // * 需保持的比例 - const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) - const calcRate = () => { - // 当前屏幕宽高比 - const currentRate = parseFloat( - (window.innerWidth / window.innerHeight).toFixed(5) - ) - if (scaleDom) { - if (currentRate > baseProportion) { - // 表示更宽 - scale.width = parseFloat(((window.innerHeight * baseProportion) / baseWidth).toFixed(5)) - scale.height = parseFloat((window.innerHeight / baseHeight).toFixed(5)) - scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` - } else { - // 表示更高 - scale.height = parseFloat(((window.innerWidth / baseProportion) / baseHeight).toFixed(5)) - scale.width = parseFloat((window.innerWidth / baseWidth).toFixed(5)) - scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` - } - if (callback) callback(scale) - } - } - - const resize = throttle(() => { - calcRate() - }, 200) - - // * 改变窗口大小重新绘制 - const windowResize = () => { - window.addEventListener('resize', resize) - } - - // * 改变窗口大小重新绘制 - const unWindowResize = () => { - window.removeEventListener('resize', resize) - } - - return { - calcRate, - windowResize, - unWindowResize, - } -} - -// * X轴撑满,Y轴滚动条 -export const usePreviewScrollYScale = ( - width: number, - height: number, - scaleDom: HTMLElement | null, - callback?: (scale: { - width: number; - height: number; - }) => void -) => { - // * 画布尺寸(px) - const baseWidth = width - const baseHeight = height - - // * 默认缩放值 - const scale = { - width: 1, - height: 1, - } - - // * 需保持的比例 - const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) - const calcRate = () => { - if (scaleDom) { - scale.height = parseFloat(((window.innerWidth / baseProportion) / baseHeight).toFixed(5)) - scale.width = parseFloat((window.innerWidth / baseWidth).toFixed(5)) - scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` - if (callback) callback(scale) - } - } - - const resize = throttle(() => { - calcRate() - }, 200) - - // * 改变窗口大小重新绘制 - const windowResize = () => { - window.addEventListener('resize', resize) - } - - // * 改变窗口大小重新绘制 - const unWindowResize = () => { - window.removeEventListener('resize', resize) - } - - return { - calcRate, - windowResize, - unWindowResize, - } -} - -// * Y轴撑满,X轴滚动条 -export const usePreviewScrollXScale = ( - width: number, - height: number, - scaleDom: HTMLElement | null, - callback?: (scale: { - width: number; - height: number; - }) => void -) => { - // * 画布尺寸(px) - const baseWidth = width - const baseHeight = height - - // * 默认缩放值 - const scale = { - height: 1, - width: 1, - } - - // * 需保持的比例 - const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) - const calcRate = () => { - if (scaleDom) { - scale.width = parseFloat(((window.innerHeight * baseProportion) / baseWidth).toFixed(5)) - scale.height = parseFloat((window.innerHeight / baseHeight).toFixed(5)) - scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` - if (callback) callback(scale) - } - } - - const resize = throttle(() => { - calcRate() - }, 200) - - // * 改变窗口大小重新绘制 - const windowResize = () => { - window.addEventListener('resize', resize) - } - - // * 改变窗口大小重新绘制 - const unWindowResize = () => { - window.removeEventListener('resize', resize) - } - - return { - calcRate, - windowResize, - unWindowResize, - } -} - -// * 变形内容,宽高铺满 -export const usePreviewFullScale = ( - width: number, - height: number, - scaleDom: HTMLElement | null, - callback?: (scale: { - width: number; - height: number; - }) => void -) => { - - // * 默认缩放值 - const scale = { - width: 1, - height: 1, - } - - const calcRate = () => { - if (scaleDom) { - scale.width = parseFloat((window.innerWidth / width).toFixed(5)) - scale.height = parseFloat((window.innerHeight / height).toFixed(5)) - scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` - if (callback) callback(scale) - } - } - - const resize = throttle(() => { - calcRate() - }, 200) - - // * 改变窗口大小重新绘制 - const windowResize = () => { - window.addEventListener('resize', resize) - } - - // * 改变窗口大小重新绘制 - const unWindowResize = () => { - window.removeEventListener('resize', resize) - } - - return { - calcRate, - windowResize, - unWindowResize, - } +import throttle from 'lodash/throttle' + +// 拆出来是为了更好的分离单独复用 + +// * 屏幕缩放适配(两边留白) +export const usePreviewFitScale = ( + width: number, + height: number, + scaleDom: HTMLElement | null, + callback?: (scale: { + width: number; + height: number; + }) => void +) => { + // * 画布尺寸(px) + const baseWidth = width + const baseHeight = height + + // * 默认缩放值 + const scale = { + width: 1, + height: 1, + } + + // * 需保持的比例 + const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) + const calcRate = () => { + // 当前屏幕宽高比 + const currentRate = parseFloat( + (window.innerWidth / window.innerHeight).toFixed(5) + ) + if (scaleDom) { + if (currentRate > baseProportion) { + // 表示更宽 + scale.width = parseFloat(((window.innerHeight * baseProportion) / baseWidth).toFixed(5)) + scale.height = parseFloat((window.innerHeight / baseHeight).toFixed(5)) + scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` + } else { + // 表示更高 + scale.height = parseFloat(((window.innerWidth / baseProportion) / baseHeight).toFixed(5)) + scale.width = parseFloat((window.innerWidth / baseWidth).toFixed(5)) + scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` + } + if (callback) callback(scale) + } + } + + const resize = throttle(() => { + calcRate() + }, 200) + + // * 改变窗口大小重新绘制 + const windowResize = () => { + window.addEventListener('resize', resize) + } + + // * 卸载监听 + const unWindowResize = () => { + window.removeEventListener('resize', resize) + } + + return { + calcRate, + windowResize, + unWindowResize, + } +} + +// * X轴撑满,Y轴滚动条 +export const usePreviewScrollYScale = ( + width: number, + height: number, + scaleDom: HTMLElement | null, + callback?: (scale: { + width: number; + height: number; + }) => void +) => { + // * 画布尺寸(px) + const baseWidth = width + const baseHeight = height + + // * 默认缩放值 + const scale = { + width: 1, + height: 1, + } + + // * 需保持的比例 + const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) + const calcRate = () => { + if (scaleDom) { + scale.height = parseFloat(((window.innerWidth / baseProportion) / baseHeight).toFixed(5)) + scale.width = parseFloat((window.innerWidth / baseWidth).toFixed(5)) + scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` + if (callback) callback(scale) + } + } + + const resize = throttle(() => { + calcRate() + }, 200) + + // * 改变窗口大小重新绘制 + const windowResize = () => { + window.addEventListener('resize', resize) + } + + // * 卸载监听 + const unWindowResize = () => { + window.removeEventListener('resize', resize) + } + + return { + calcRate, + windowResize, + unWindowResize, + } +} + +// * Y轴撑满,X轴滚动条 +export const usePreviewScrollXScale = ( + width: number, + height: number, + scaleDom: HTMLElement | null, + callback?: (scale: { + width: number; + height: number; + }) => void +) => { + // * 画布尺寸(px) + const baseWidth = width + const baseHeight = height + + // * 默认缩放值 + const scale = { + height: 1, + width: 1, + } + + // * 需保持的比例 + const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) + const calcRate = () => { + if (scaleDom) { + scale.width = parseFloat(((window.innerHeight * baseProportion) / baseWidth).toFixed(5)) + scale.height = parseFloat((window.innerHeight / baseHeight).toFixed(5)) + scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` + if (callback) callback(scale) + } + } + + const resize = throttle(() => { + calcRate() + }, 200) + + // * 改变窗口大小重新绘制 + const windowResize = () => { + window.addEventListener('resize', resize) + } + + // * 卸载监听 + const unWindowResize = () => { + window.removeEventListener('resize', resize) + } + + return { + calcRate, + windowResize, + unWindowResize, + } +} + +// * 变形内容,宽高铺满 +export const usePreviewFullScale = ( + width: number, + height: number, + scaleDom: HTMLElement | null, + callback?: (scale: { + width: number; + height: number; + }) => void +) => { + + // * 默认缩放值 + const scale = { + width: 1, + height: 1, + } + + const calcRate = () => { + if (scaleDom) { + scale.width = parseFloat((window.innerWidth / width).toFixed(5)) + scale.height = parseFloat((window.innerHeight / height).toFixed(5)) + scaleDom.style.transform = `scale(${scale.width}, ${scale.height})` + if (callback) callback(scale) + } + } + + const resize = throttle(() => { + calcRate() + }, 200) + + // * 改变窗口大小重新绘制 + const windowResize = () => { + window.addEventListener('resize', resize) + } + + // * 卸载监听 + const unWindowResize = () => { + window.removeEventListener('resize', resize) + } + + return { + calcRate, + windowResize, + unWindowResize, + } } \ No newline at end of file diff --git a/src/views/preview/hooks/useScale.hook.ts b/src/views/preview/hooks/useScale.hook.ts index 3916c187..b0185383 100644 --- a/src/views/preview/hooks/useScale.hook.ts +++ b/src/views/preview/hooks/useScale.hook.ts @@ -12,7 +12,31 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => { const height = ref(localStorageInfo.editCanvasConfig.height) const scaleRef = ref({ width: 1, height: 1 }) - provide(SCALE_KEY, scaleRef); + provide(SCALE_KEY, scaleRef) + + // 监听鼠标滚轮 +ctrl 键 + const useAddWheelHandle = (removeEvent: Function) => { + addEventListener( + 'wheel', + (e: any) => { + if (window?.$KeyboardActive?.ctrl) { + e.preventDefault() + e.stopPropagation() + removeEvent() + const transform = previewRef.value.style.transform + // 使用正则解析 scale(1, 1) 中的两个数值 + const regRes = transform.match(/scale\((\d+\.?\d*)*/) as RegExpMatchArray + const width = regRes[1] + if (e.wheelDelta > 0) { + previewRef.value.style.transform = `scale(${parseFloat(Number(width).toFixed(2)) + 0.1})` + } else { + previewRef.value.style.transform = `scale(${parseFloat(Number(width).toFixed(2)) - 0.1})` + } + } + }, + { passive: false } + ) + } const updateScaleRef = (scale: { width: number; height: number }) => { // 这里需要解构,保证赋值给scaleRef的为一个新对象 @@ -23,74 +47,82 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => { // 屏幕适配 onMounted(() => { switch (localStorageInfo.editCanvasConfig.previewScaleType) { - case PreviewScaleEnum.FIT: (() => { - const { calcRate, windowResize, unWindowResize } = usePreviewFitScale( - width.value as number, - height.value as number, - previewRef.value, - updateScaleRef - ) - calcRate() - windowResize() - onUnmounted(() => { - unWindowResize() - }) - })() - break; - case PreviewScaleEnum.SCROLL_Y: (() => { - const { calcRate, windowResize, unWindowResize } = usePreviewScrollYScale( - width.value as number, - height.value as number, - previewRef.value, - (scale) => { - const dom = entityRef.value - dom.style.width = `${width.value * scale.width}px` - dom.style.height = `${height.value * scale.height}px` - updateScaleRef(scale) - } - ) - calcRate() - windowResize() - onUnmounted(() => { - unWindowResize() - }) - })() + case PreviewScaleEnum.FIT: + ;(() => { + const { calcRate, windowResize, unWindowResize } = usePreviewFitScale( + width.value as number, + height.value as number, + previewRef.value, + updateScaleRef + ) + calcRate() + windowResize() + useAddWheelHandle(unWindowResize) + onUnmounted(() => { + unWindowResize() + }) + })() + break + case PreviewScaleEnum.SCROLL_Y: + ;(() => { + const { calcRate, windowResize, unWindowResize } = usePreviewScrollYScale( + width.value as number, + height.value as number, + previewRef.value, + scale => { + const dom = entityRef.value + dom.style.width = `${width.value * scale.width}px` + dom.style.height = `${height.value * scale.height}px` + updateScaleRef(scale) + } + ) + calcRate() + windowResize() + useAddWheelHandle(unWindowResize) + onUnmounted(() => { + unWindowResize() + }) + })() - break; - case PreviewScaleEnum.SCROLL_X: (() => { - const { calcRate, windowResize, unWindowResize } = usePreviewScrollXScale( - width.value as number, - height.value as number, - previewRef.value, - (scale) => { - const dom = entityRef.value - dom.style.width = `${width.value * scale.width}px` - dom.style.height = `${height.value * scale.height}px` - updateScaleRef(scale) - } - ) - calcRate() - windowResize() - onUnmounted(() => { - unWindowResize() - }) - })() + break + case PreviewScaleEnum.SCROLL_X: + ;(() => { + const { calcRate, windowResize, unWindowResize } = usePreviewScrollXScale( + width.value as number, + height.value as number, + previewRef.value, + scale => { + const dom = entityRef.value + dom.style.width = `${width.value * scale.width}px` + dom.style.height = `${height.value * scale.height}px` + updateScaleRef(scale) + } + ) + calcRate() + windowResize() + useAddWheelHandle(unWindowResize) + onUnmounted(() => { + unWindowResize() + }) + })() - break; - case PreviewScaleEnum.FULL: (() => { - const { calcRate, windowResize, unWindowResize } = usePreviewFullScale( - width.value as number, - height.value as number, - previewRef.value, - updateScaleRef - ) - calcRate() - windowResize() - onUnmounted(() => { - unWindowResize() - }) - })() - break; + break + case PreviewScaleEnum.FULL: + ;(() => { + const { calcRate, windowResize, unWindowResize } = usePreviewFullScale( + width.value as number, + height.value as number, + previewRef.value, + updateScaleRef + ) + calcRate() + windowResize() + useAddWheelHandle(unWindowResize) + onUnmounted(() => { + unWindowResize() + }) + })() + break } }) diff --git a/src/views/preview/suspenseIndex.vue b/src/views/preview/suspenseIndex.vue index fdc3fdf6..1a1932b9 100644 --- a/src/views/preview/suspenseIndex.vue +++ b/src/views/preview/suspenseIndex.vue @@ -30,7 +30,7 @@ import { computed } from 'vue' import { PreviewRenderList } from './components/PreviewRenderList' import { getFilterStyle, setTitle } from '@/utils' -import { getEditCanvasConfigStyle, getSessionStorageInfo } from './utils' +import { getEditCanvasConfigStyle, getSessionStorageInfo, keyRecordHandle } from './utils' import { useComInstall } from './hooks/useComInstall.hook' import { useScale } from './hooks/useScale.hook' import { useStore } from './hooks/useStore.hook' @@ -60,6 +60,9 @@ const showEntity = computed(() => { useStore(chartEditStore) const { entityRef, previewRef } = useScale(chartEditStore) const { show } = useComInstall(chartEditStore) + +// 开启键盘监听 +keyRecordHandle() </script> <style lang="scss" scoped> diff --git a/src/views/preview/utils/index.ts b/src/views/preview/utils/index.ts index f0f79cfa..1d0be713 100644 --- a/src/views/preview/utils/index.ts +++ b/src/views/preview/utils/index.ts @@ -1,2 +1,3 @@ -export * from './style' -export * from './storage' \ No newline at end of file +export * from './style' +export * from './storage' +export * from './keyboard' \ No newline at end of file diff --git a/src/views/preview/utils/keyboard.ts b/src/views/preview/utils/keyboard.ts new file mode 100644 index 00000000..0b895ab4 --- /dev/null +++ b/src/views/preview/utils/keyboard.ts @@ -0,0 +1,32 @@ +// 处理键盘记录 +export const keyRecordHandle = () => { + // 默认赋值 + window.$KeyboardActive = { + ctrl: false, + space: false + } + + document.onkeydown = (e: KeyboardEvent) => { + const { keyCode } = e + if (keyCode == 32 && e.target == document.body) e.preventDefault() + + if ([17, 32].includes(keyCode) && window.$KeyboardActive) { + switch (keyCode) { + case 17: window.$KeyboardActive.ctrl = true; break + case 32: window.$KeyboardActive.space = true; break + } + } + } + + document.onkeyup = (e: KeyboardEvent) => { + const { keyCode } = e + if (keyCode == 32 && e.target == document.body) e.preventDefault() + + if ([17, 32].includes(keyCode) && window.$KeyboardActive) { + switch (keyCode) { + case 17: window.$KeyboardActive.ctrl = false; break + case 32: window.$KeyboardActive.space = false; break + } + } + } +} \ No newline at end of file From 06e54ae1323791fcff03626fcc4e645b8d98e892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Sat, 8 Jul 2023 21:33:50 +0800 Subject: [PATCH 24/24] =?UTF-8?q?feat:=20=E8=BF=98=E5=8E=9F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=BB=84=E6=97=8B=E8=BD=AC=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=BC=98=E5=8C=96=E9=A2=84=E8=A7=88=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E7=9A=84=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/preview/components/PreviewRenderGroup/index.vue | 5 ++++- src/views/preview/hooks/useScale.hook.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/views/preview/components/PreviewRenderGroup/index.vue b/src/views/preview/components/PreviewRenderGroup/index.vue index fd7b04c3..354fa29c 100644 --- a/src/views/preview/components/PreviewRenderGroup/index.vue +++ b/src/views/preview/components/PreviewRenderGroup/index.vue @@ -46,11 +46,14 @@ const props = defineProps({ required: true }, groupIndex: { - type: [String, Number], + type: Number, required: true } }) </script> <style lang="scss" scoped> +.chart-item { + position: absolute; +} </style> diff --git a/src/views/preview/hooks/useScale.hook.ts b/src/views/preview/hooks/useScale.hook.ts index b0185383..e4c57f97 100644 --- a/src/views/preview/hooks/useScale.hook.ts +++ b/src/views/preview/hooks/useScale.hook.ts @@ -23,6 +23,8 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => { e.preventDefault() e.stopPropagation() removeEvent() + const fitDom = document.querySelector(".go-preview.fit") as HTMLElement + if (fitDom) fitDom.style.overflow = 'auto' const transform = previewRef.value.style.transform // 使用正则解析 scale(1, 1) 中的两个数值 const regRes = transform.match(/scale\((\d+\.?\d*)*/) as RegExpMatchArray