From cf8b1120b157328e9828061880fee53b95915591 Mon Sep 17 00:00:00 2001 From: yangmi Date: Wed, 20 Jul 2022 18:27:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20eslint=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E8=A7=A3=E5=86=B3vue3=E5=AE=8F=E7=BC=96?= =?UTF-8?q?=E7=A8=8Bvscode=E6=8F=90=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 1 + .gitignore | 1 + .husky/commit-msg | 4 ---- 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 .husky/commit-msg diff --git a/.eslintrc.js b/.eslintrc.js index 2b737770..3786b486 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,7 @@ module.exports = { }, }, env: { + 'vue/setup-compiler-macros': true, node: true, }, extends: ["plugin:vue/vue3-essential", "eslint:recommended"], diff --git a/.gitignore b/.gitignore index 60a4aff1..e8de8f67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +.husky .DS_Store dist dist-ssr diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100644 index 42cdacde..00000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no-install commitlint -e From c2f9f449e8c920a8ba0cfcbec5ece572a63a18f9 Mon Sep 17 00:00:00 2001 From: yangmi Date: Wed, 20 Jul 2022 18:30:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?build:=20=E4=BE=9D=E8=B5=96=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a2becb4b..a483412b 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ "postinstall": "husky install" }, "dependencies": { - "@types/color": "^3.0.3", - "@types/crypto-js": "^4.1.1", - "@types/keymaster": "^1.6.30", "animate.css": "^4.1.1", "axios": "0.23.0", "color": "^4.2.3", @@ -30,30 +27,34 @@ "vue-router": "4.0.12", "vue3-lazyload": "^0.2.5-beta", "vue3-sketch-ruler": "^1.3.3", - "vuedraggable": "^4.1.0" + "vuedraggable": "^4.1.0", + "@vueuse/core": "^7.7.1", + "@vicons/carbon": "^0.12.0", + "@vicons/ionicons5": "~0.11.0", + "echarts": "^5.3.2", + "vue-echarts": "^6.0.2", + "lodash": "~4.17.21" }, "devDependencies": { + "@types/color": "^3.0.3", + "@types/crypto-js": "^4.1.1", + "@types/keymaster": "^1.6.30", "@commitlint/cli": "^17.0.2", "@commitlint/config-conventional": "^17.0.2", "@types/node": "^16.11.26", "@typescript-eslint/eslint-plugin": "^5.18.0", "@typescript-eslint/parser": "^5.18.0", - "@vicons/carbon": "^0.12.0", - "@vicons/ionicons5": "~0.11.0", "@vitejs/plugin-vue": "^1.10.2", "@vitejs/plugin-vue-jsx": "^1.3.9", "@vue/compiler-sfc": "^3.2.31", - "@vueuse/core": "^7.7.1", "commitlint": "^17.0.2", "default-passive-events": "^2.0.0", - "echarts": "^5.3.2", "eslint": "^8.12.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-vue": "^8.5.0", "husky": "^8.0.1", - "lodash": "~4.17.21", "mockjs": "^1.1.0", "plop": "^3.0.5", "prettier": "^2.6.2", @@ -65,7 +66,6 @@ "vite-plugin-importer": "^0.2.5", "vite-plugin-mock": "^2.9.6", "vite-plugin-monaco-editor": "^1.1.0", - "vue-echarts": "^6.0.2", "vue-tsc": "^0.28.10" } } \ No newline at end of file From e33bded469dd0dee119aac0d8288bf8729993494 Mon Sep 17 00:00:00 2001 From: yangmi Date: Thu, 21 Jul 2022 10:33:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 17 +- src/enums/eventEnum.ts | 38 +++ src/hooks/index.ts | 3 +- src/hooks/useEventBus.hook.ts | 67 +++++ .../components/Charts/Bars/BarCommon/index.ts | 7 +- .../Informations/Texts/TextCommon/config.vue | 4 +- .../Informations/Texts/TextCommon/enum.ts | 16 ++ .../Informations/Texts/TextCommon/index.ts | 13 +- .../Informations/Texts/TextCommon/index.vue | 13 +- src/packages/index.d.ts | 32 +++ src/plugins/icon.ts | 11 +- .../chartEditStore/chartEditStore.d.ts | 1 + .../modules/chartEditStore/chartEditStore.ts | 1 - src/utils/componets.ts | 10 + src/utils/data.ts | 6 + src/utils/index.ts | 1 + .../components/ChartEvent/index.vue | 272 +++++++++++++++++- .../chart/ContentConfigurations/index.vue | 12 +- .../components/LayersListItem/index.vue | 7 +- .../PreviewRenderList/PreViewRenderItem.vue | 90 ++++++ .../components/PreviewRenderList/index.vue | 13 +- 21 files changed, 597 insertions(+), 37 deletions(-) create mode 100644 src/enums/eventEnum.ts create mode 100644 src/hooks/useEventBus.hook.ts create mode 100644 src/packages/components/Informations/Texts/TextCommon/enum.ts create mode 100644 src/utils/data.ts create mode 100644 src/views/preview/components/PreviewRenderList/PreViewRenderItem.vue diff --git a/package.json b/package.json index a483412b..43b3f9c0 100644 --- a/package.json +++ b/package.json @@ -9,31 +9,32 @@ "postinstall": "husky install" }, "dependencies": { + "@vicons/carbon": "^0.12.0", + "@vicons/ionicons5": "~0.11.0", + "@vueuse/core": "^7.7.1", "animate.css": "^4.1.1", "axios": "0.23.0", "color": "^4.2.3", "crypto-js": "^4.1.1", + "echarts": "^5.3.2", "echarts-liquidfill": "^3.1.0", "highlight.js": "^11.5.0", "html2canvas": "^1.4.1", "keymaster": "^1.6.2", + "lodash": "~4.17.21", "monaco-editor": "^0.33.0", "naive-ui": "2.30.3", "pinia": "^2.0.13", "screenfull": "^6.0.1", + "tiny-emitter": "^2.1.0", "vue": "^3.2.31", "vue-demi": "^0.13.1", + "vue-echarts": "^6.0.2", "vue-i18n": "9.1.9", "vue-router": "4.0.12", "vue3-lazyload": "^0.2.5-beta", "vue3-sketch-ruler": "^1.3.3", - "vuedraggable": "^4.1.0", - "@vueuse/core": "^7.7.1", - "@vicons/carbon": "^0.12.0", - "@vicons/ionicons5": "~0.11.0", - "echarts": "^5.3.2", - "vue-echarts": "^6.0.2", - "lodash": "~4.17.21" + "vuedraggable": "^4.1.0" }, "devDependencies": { "@types/color": "^3.0.3", @@ -68,4 +69,4 @@ "vite-plugin-monaco-editor": "^1.1.0", "vue-tsc": "^0.28.10" } -} \ No newline at end of file +} diff --git a/src/enums/eventEnum.ts b/src/enums/eventEnum.ts new file mode 100644 index 00000000..2b61ca88 --- /dev/null +++ b/src/enums/eventEnum.ts @@ -0,0 +1,38 @@ +export enum EventType { + CLICK = 'click', + DBCLICK = 'dblclick', + CHANGE = 'change', + // MOUSE_ENTER = 'mouseenter', + // MOUSE_LEAVE = 'mouseleave', + MOUNTED = 'vnodeMounted', + // OTHER = 'other' +} + +export const EventTypeTitle = { + [EventType.CLICK]: '点击', + [EventType.DBCLICK]: '双击', + [EventType.CHANGE]: '值变化', + // [EventType.MOUSE_ENTER]: '鼠标进入', + // [EventType.MOUSE_LEAVE]: '鼠标移开', + [EventType.MOUNTED]: '渲染完成', + // [EventType.OTHER]: '其它', +} + +export enum EventTriggerType { + COMPONENT = 'component', + JAVASCRIPT = 'javascript' +} + +export const EventTriggerTypeMap = new Map( + [ + [EventTriggerType.COMPONENT, '组件联动'], + [EventTriggerType.JAVASCRIPT, '自定义js'], + ] +) + +export const CommonEventMap = new Map( + [ + ['forceUpdate', '强制更新'], + ] +) + diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 16b0bb69..338bde00 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,4 +1,5 @@ export * from '@/hooks/useTheme.hook' export * from '@/hooks/usePreviewScale.hook' export * from '@/hooks/useCode.hook' -export * from '@/hooks/useChartDataFetch.hook' \ No newline at end of file +export * from '@/hooks/useChartDataFetch.hook' +export * from '@/hooks/useEventBus.hook' \ No newline at end of file diff --git a/src/hooks/useEventBus.hook.ts b/src/hooks/useEventBus.hook.ts new file mode 100644 index 00000000..ece04e5c --- /dev/null +++ b/src/hooks/useEventBus.hook.ts @@ -0,0 +1,67 @@ +import Emitter from 'tiny-emitter' +import { onBeforeUnmount } from 'vue' + + +/** + * { + * on: { + * [event]: [] + * }, + * } + */ + +type EventBusListeners = { + [key: string]: () => any +}; + +export type EventBusOptions = { + on?: EventBusListeners + once?: EventBusListeners +} + + +//@ts-ignore +const bus = new Emitter() + +const addListeners = (listeners: EventBusListeners | undefined, isOnce = false): void => { + if(!listeners) return + Object.keys(listeners).forEach(key => { + console.info('监听事件:', key) + bus[isOnce ? 'once' : 'on'](key, listeners[key]) + onBeforeUnmount(() => { + bus.off(key, listeners[key]) + }) + }) +} + + +// 转换事件名 +const convertListeners = (listeners: EventBusListeners, dst: object, prefix = 'prefix'): void => { + Object.keys(listeners).forEach((key: string) => { + // @ts-ignore + dst[`${prefix}:${key}`] = listeners[key] + }) +} + +export const convertEventBusListeners = (listeners: EventBusOptions, prefix: string): EventBusOptions => { + const res = { + on: {}, + once: {}, + } + + if(listeners.on) { + convertListeners(listeners.on, res.on, prefix) + } + + if(listeners.once) { + convertListeners(listeners.once, res.once, prefix) + } + + return res +} + +export const useEventBus = (listeners: EventBusOptions = {}) => { + addListeners(listeners.on); + addListeners(listeners.once, true) + return bus +} diff --git a/src/packages/components/Charts/Bars/BarCommon/index.ts b/src/packages/components/Charts/Bars/BarCommon/index.ts index a4247970..46bd0e28 100644 --- a/src/packages/components/Charts/Bars/BarCommon/index.ts +++ b/src/packages/components/Charts/Bars/BarCommon/index.ts @@ -1,15 +1,14 @@ import image from '@/assets/images/chart/charts/bar_x.png' import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' +import { getComponentConfig } from '@/utils' import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d' -export const BarCommonConfig: ConfigType = { +export const BarCommonConfig: ConfigType = getComponentConfig({ key: 'BarCommon', - chartKey: 'VBarCommon', - conKey: 'VCBarCommon', title: '柱状图', category: ChatCategoryEnum.BAR, categoryName: ChatCategoryEnumName.BAR, package: PackagesCategoryEnum.CHARTS, chartFrame: ChartFrameEnum.ECHARTS, image -} +}) diff --git a/src/packages/components/Informations/Texts/TextCommon/config.vue b/src/packages/components/Informations/Texts/TextCommon/config.vue index 4988e9c4..447d82b2 100644 --- a/src/packages/components/Informations/Texts/TextCommon/config.vue +++ b/src/packages/components/Informations/Texts/TextCommon/config.vue @@ -62,7 +62,7 @@ \ No newline at end of file diff --git a/src/views/chart/ContentConfigurations/index.vue b/src/views/chart/ContentConfigurations/index.vue index 92ba612d..bb040a54 100644 --- a/src/views/chart/ContentConfigurations/index.vue +++ b/src/views/chart/ContentConfigurations/index.vue @@ -92,7 +92,8 @@ const { ConstructIcon, FlashIcon, DesktopOutlineIcon, - LeafIcon + LeafIcon, + RocketIcon } = icon.ionicons5 const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue')) @@ -108,6 +109,9 @@ const ChartData = loadAsyncComponent(() => const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue') ) +const ChartEvent = loadAsyncComponent(() => + import('./components/ChartEvent/index.vue') +) const collapsed = ref(getDetails.value) @@ -164,6 +168,12 @@ const canvasTabList = [ title: '数据', icon: FlashIcon, render: ChartData + }, + { + key: 'eventData', + title: '事件', + icon: RocketIcon, + render: ChartEvent } ] diff --git a/src/views/chart/ContentLayers/components/LayersListItem/index.vue b/src/views/chart/ContentLayers/components/LayersListItem/index.vue index 97c09028..6a366c8b 100644 --- a/src/views/chart/ContentLayers/components/LayersListItem/index.vue +++ b/src/views/chart/ContentLayers/components/LayersListItem/index.vue @@ -22,7 +22,7 @@ + + \ No newline at end of file diff --git a/src/views/preview/components/PreviewRenderList/index.vue b/src/views/preview/components/PreviewRenderList/index.vue index 665ba487..f92a229f 100644 --- a/src/views/preview/components/PreviewRenderList/index.vue +++ b/src/views/preview/components/PreviewRenderList/index.vue @@ -10,13 +10,12 @@ ...getTransformStyle(item.styles) }" > - + :themeColor="themeColor"> + @@ -26,6 +25,8 @@ import { ChartEditStorageType } from '../../index.d' import { chartColors } from '@/settings/chartThemes/index' import { animationsClass, getFilterStyle, getTransformStyle } from '@/utils' import { getSizeStyle, getComponentAttrStyle } from '../../utils' +import PreViewRenderItem from './PreViewRenderItem.vue' + const props = defineProps({ localStorageInfo: {