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
diff --git a/package.json b/package.json
index 11f3580e..290d0829 100644
--- a/package.json
+++ b/package.json
@@ -9,23 +9,27 @@
"postinstall": "husky install"
},
"dependencies": {
- "@types/color": "^3.0.3",
- "@types/crypto-js": "^4.1.1",
- "@types/keymaster": "^1.6.30",
+ "@vicons/carbon": "^0.12.0",
+ "@vicons/ionicons5": "~0.11.0",
+ "@vueuse/core": "^7.7.1",
"animate.css": "^4.1.1",
"axios": "^0.27.2",
"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",
@@ -33,27 +37,25 @@
"vuedraggable": "^4.1.0"
},
"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 +67,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
+}
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: {