From 50e9e994b1ce462ac162bcc742e85c98cff535d0 Mon Sep 17 00:00:00 2001 From: ly-chn <3293232930@qq.com> Date: Thu, 17 Aug 2023 09:38:30 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5=E6=97=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=89=B9=E6=AE=8Akey=E6=97=B6,=20=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=BF=9B=E5=BA=A6=E5=A7=8B=E7=BB=88=E6=98=BE=E7=A4=BA?= =?UTF-8?q?,=20=E4=B8=94=E6=97=A0=E6=B3=95=E7=BB=A7=E7=BB=AD=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=90=8E=E7=BB=AD=E5=86=85=E5=AE=B9=20perf:=20?= =?UTF-8?q?=E5=A4=A7=E9=87=8F=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=90=8C=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=97=B6,=20=E6=8F=90=E5=8D=87createComponent?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ src/packages/index.ts | 35 ++++++++++++++++++--------- src/views/chart/hooks/useSync.hook.ts | 4 +-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 60a4aff1..e0f420b7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ node_modules dist dist-ssr *.local +pnpm-lock.yaml .vscode +.idea diff --git a/src/packages/index.ts b/src/packages/index.ts index 20bc8535..5653bd23 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -1,9 +1,9 @@ -import { ChartList } from '@/packages/components/Charts/index' -import { DecorateList } from '@/packages/components/Decorates/index' -import { InformationList } from '@/packages/components/Informations/index' -import { TableList } from '@/packages/components/Tables/index' -import { PhotoList } from '@/packages/components/Photos/index' -import { IconList } from '@/packages/components/Icons/index' +import {ChartList} from '@/packages/components/Charts/index' +import {DecorateList} from '@/packages/components/Decorates/index' +import {InformationList} from '@/packages/components/Informations/index' +import {TableList} from '@/packages/components/Tables/index' +import {PhotoList} from '@/packages/components/Photos/index' +import {IconList} from '@/packages/components/Icons/index' import { PackagesCategoryEnum, PackagesType, ConfigType, FetchComFlagType } from '@/packages/index.d' const configModules: Record = import.meta.glob('./components/**/config.vue', { @@ -26,6 +26,16 @@ export let packagesList: PackagesType = { [PackagesCategoryEnum.ICONS]: IconList } +// 组件缓存, 可以大幅度提升组件加载速度 +const componentCacheMap = new Map() +const loadConfig = (packageName: string, categoryName: string, keyName: string) => { + const key = packageName + categoryName + keyName + if (!componentCacheMap.has(key)) { + componentCacheMap.set(key, import(`./components/${packageName}/${categoryName}/${keyName}/config.ts`)) + } + return componentCacheMap.get(key) +} + /** * * 获取目标组件配置信息 * @param targetData @@ -35,10 +45,10 @@ export const createComponent = async (targetData: ConfigType) => { // redirectComponent 是给图片组件库和图标组件库使用的 if (redirectComponent) { const [packageName, categoryName, keyName] = redirectComponent.split('/') - const redirectChart = await import(`./components/${packageName}/${categoryName}/${keyName}/config.ts`) + const redirectChart = await loadConfig(packageName, categoryName, keyName) return new redirectChart.default() } - const chart = await import(`./components/${targetData.package}/${category}/${key}/config.ts`) + const chart = await loadConfig(targetData.package, category, key) return new chart.default() } @@ -62,7 +72,7 @@ const fetchComponent = (chartName: string, flag: FetchComFlagType) => { * @param {ConfigType} dropData 配置项 */ export const fetchChartComponent = (dropData: ConfigType) => { - const { key } = dropData + const {key} = dropData return fetchComponent(key, FetchComFlagType.VIEW)?.default } @@ -71,7 +81,7 @@ export const fetchChartComponent = (dropData: ConfigType) => { * @param {ConfigType} dropData 配置项 */ export const fetchConfigComponent = (dropData: ConfigType) => { - const { key } = dropData + const {key} = dropData return fetchComponent(key, FetchComFlagType.CONFIG)?.default } @@ -84,7 +94,10 @@ export const fetchImages = async (targetData?: ConfigType) => { // 正则判断图片是否为 url,是则直接返回该 url if (/^(http|https):\/\/([\w.]+\/?)\S*/.test(targetData.image)) return targetData.image // 新数据动态处理 - const { image, package: targetDataPackage } = targetData + const { + image, + package: targetDataPackage + } = targetData // 兼容旧数据 if (image.includes('@') || image.includes('base64')) return image diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index b97fd4e5..0d27fc99 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -196,9 +196,7 @@ export const useSync = () => { chartHistoryStore.clearForwardStack() } } - } else { - // 非组件(顺便排除脏数据) - if (key !== 'editCanvasConfig' && key !== 'requestGlobalConfig') return + } else if (key === ChartEditStoreEnum.EDIT_CANVAS_CONFIG || key === ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG) { componentMerge(chartEditStore[key], projectData[key], true) } } From 73d8889bc49e2d5b87663886b0546323304e44cb Mon Sep 17 00:00:00 2001 From: QuietlyChan <1013893148@qq.com> Date: Wed, 30 Aug 2023 15:23:41 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E5=9B=BE=E5=8A=9B=E5=BC=95=E5=AF=BC=E5=B8=83=E5=B1=80=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Charts/Mores/Graph/config.ts | 86 +++++++++++-------- .../components/Charts/Mores/Graph/config.vue | 73 +++++++++++++--- .../components/Charts/Mores/Graph/index.vue | 9 +- src/packages/components/Charts/Mores/index.ts | 12 ++- 4 files changed, 131 insertions(+), 49 deletions(-) diff --git a/src/packages/components/Charts/Mores/Graph/config.ts b/src/packages/components/Charts/Mores/Graph/config.ts index 0dfb0dc8..7ba6b00c 100644 --- a/src/packages/components/Charts/Mores/Graph/config.ts +++ b/src/packages/components/Charts/Mores/Graph/config.ts @@ -9,13 +9,14 @@ export const includes = [] // 关系图布局 export const GraphLayout = [ { label: '无', value: 'none' }, - { label: '环形', value: 'circular' } + { label: '环形', value: 'circular' }, + { label: '力引导', value: 'force' } ] // 标签开关 export const LabelSwitch = [ - { label: '开启', value: 1 }, - { label: '关闭', value: 0 } + { label: '开启', value: true }, + { label: '关闭', value: false } ] // 标签位置 @@ -24,44 +25,57 @@ export const LabelPosition = [ { label: '右侧', value: 'right' }, { label: '顶部', value: 'top' }, { label: '底部', value: 'bottom' }, - { label: '内部', value: 'inside' }, + { label: '内部', value: 'inside' } +] + +// 图-迭代动画 +export const LayoutAnimation = [ + { label: '开启', value: true }, + { label: '关闭', value: false } ] export const option = { - dataset: { ...dataJson }, - tooltip: {}, - legend:{ - show:true, - textStyle:{ - color:"#eee", - fontSize: 14 , - }, - data: dataJson.categories.map(function (a) { - return a.name; - }) + dataset: { ...dataJson }, + tooltip: {}, + legend: { + show: true, + textStyle: { + color: '#eee', + fontSize: 14 }, - series: [ - { - type: 'graph', - layout: 'none', // none circular环形布局 - data: dataJson.nodes, - links: dataJson.links, - categories: dataJson.categories, - label: { // 标签 - show: 1, - position: 'right', - formatter: '{b}' - }, - labelLayout: { - hideOverlap: true - }, - lineStyle: { - color: 'source', // 线条颜色 - curveness: 0.2 // 线条卷曲程度 - } + data: dataJson.categories.map(function (a) { + return a.name + }) + }, + series: [ + { + type: 'graph', + layout: 'none', // none circular环形布局 + data: dataJson.nodes, + links: dataJson.links, + categories: dataJson.categories, + label: { + show: true, + position: 'right', + formatter: '{b}' + }, + labelLayout: { + hideOverlap: true + }, + lineStyle: { + color: 'source', // 线条颜色 + curveness: 0.2 // 线条卷曲程度 + }, + force: { + repulsion: 100, + gravity: 0.1, + edgeLength: 30, + layoutAnimation: true, + friction: 0.6 } - ] - }; + } + ] +} export default class Config extends PublicConfigClass implements CreateComponentType { public key = GraphConfig.key diff --git a/src/packages/components/Charts/Mores/Graph/config.vue b/src/packages/components/Charts/Mores/Graph/config.vue index 07319fde..81ce82f0 100644 --- a/src/packages/components/Charts/Mores/Graph/config.vue +++ b/src/packages/components/Charts/Mores/Graph/config.vue @@ -16,14 +16,14 @@ - + + v-model:value="optionData.series[0].lineStyle.curveness" + :min="0" + :step="0.01" + placeholder="弯曲程度" + size="small" + > @@ -32,10 +32,61 @@ size="small" :modes="['hex']" v-model:value="optionData.legend.textStyle.color" - > + > - + + + + + + + + + + + + + + + + + + + + + + @@ -46,7 +97,7 @@ diff --git a/src/packages/components/Charts/Mores/Graph/index.vue b/src/packages/components/Charts/Mores/Graph/index.vue index 40c2b0e1..378c968e 100644 --- a/src/packages/components/Charts/Mores/Graph/index.vue +++ b/src/packages/components/Charts/Mores/Graph/index.vue @@ -1,5 +1,12 @@ + + + + +