perf: 修改事件文件位置,修改图标

This commit is contained in:
奔跑的面条 2022-10-16 10:41:12 +08:00
parent 3ac7b574c4
commit f8674167ab
8 changed files with 53 additions and 53 deletions

View File

@ -16,7 +16,5 @@ import PositionSetting from './PositionSetting.vue'
import SizeSetting from './SizeSetting.vue' import SizeSetting from './SizeSetting.vue'
// 样式 // 样式
import StylesSetting from './StylesSetting.vue' import StylesSetting from './StylesSetting.vue'
// 事件配置
import EventSetting from './EventSetting.vue'
export { CollapseItem, SettingItemBox, SettingItem, GlobalSetting, GlobalSettingPosition, NameSetting, PositionSetting, SizeSetting, StylesSetting, EventSetting } export { CollapseItem, SettingItemBox, SettingItem, GlobalSetting, GlobalSettingPosition, NameSetting, PositionSetting, SizeSetting, StylesSetting }

View File

@ -2,47 +2,47 @@ import { CreateComponentType, EventLife } from '@/packages/index.d'
import * as echarts from 'echarts' import * as echarts from 'echarts'
// 所有图表组件集合对象 // 所有图表组件集合对象
const components: {[K in string]?: any} = {}; const components: { [K in string]?: any } = {}
// 项目提供的npm 包变量 // 项目提供的npm 包变量
export const npmPkgs = { echarts } export const npmPkgs = { echarts }
export const useLifeHandler = (chartConfig: CreateComponentType) => { export const useLifeHandler = (chartConfig: CreateComponentType) => {
const events = chartConfig.events || {} const events = chartConfig.events || {}
// 生成生命周期事件 // 生成生命周期事件
const lifeEvents = { const lifeEvents = {
[EventLife.BEFORE_MOUNT] (e:any) { [EventLife.BEFORE_MOUNT](e: any) {
// 存储组件 // 存储组件
components[chartConfig.id] = e.component components[chartConfig.id] = e.component
const fnStr = (events[EventLife.BEFORE_MOUNT] || '').trim() const fnStr = (events[EventLife.BEFORE_MOUNT] || '').trim()
generateFunc(fnStr, e) generateFunc(fnStr, e)
}, },
[EventLife.MOUNTED] (e:any){ [EventLife.MOUNTED](e: any) {
const fnStr = (events[EventLife.MOUNTED] || '').trim() const fnStr = (events[EventLife.MOUNTED] || '').trim()
generateFunc(fnStr, e) generateFunc(fnStr, e)
},
} }
return lifeEvents }
return lifeEvents
} }
/** /**
* *
* @param fnStr * @param fnStr
* @param e * @param e
*/ */
function generateFunc(fnStr: string, e: any){ function generateFunc(fnStr: string, e: any) {
try { try {
Function(` Function(`
"use strict"; "use strict";
return ( return (
async function(e, components, node_modules){ async function(e, components, node_modules){
const {${Object.keys(npmPkgs).join()}} = node_modules; const {${Object.keys(npmPkgs).join()}} = node_modules;
${fnStr} ${fnStr}
} }
)`)().bind(e?.component) )`)().bind(e?.component)
// 便于拷贝echarts示例时设置option 的formatter等相关内容 // 便于拷贝echarts示例时设置option 的formatter等相关内容
(e, components, npmPkgs); e, components, npmPkgs
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }
} }

View File

@ -90,6 +90,12 @@ export const BlendModeEnumList = [
{ label: '亮度', value: 'luminosity' } { label: '亮度', value: 'luminosity' }
] ]
// vue3 生命周期事件
export enum EventLife {
BEFORE_MOUNT = 'vnodeBeforeMount',
MOUNTED = 'vnodeMounted'
}
// 组件实例类 // 组件实例类
export interface PublicConfigType { export interface PublicConfigType {
id: string id: string
@ -120,12 +126,6 @@ export interface PublicConfigType {
} }
} }
// vue3 生命周期事件
export enum EventLife {
BEFORE_MOUNT = 'vnodeBeforeMount',
MOUNTED = 'vnodeMounted'
}
export interface CreateComponentType extends PublicConfigType, requestConfig { export interface CreateComponentType extends PublicConfigType, requestConfig {
key: string key: string
chartConfig: ConfigType chartConfig: ConfigType

View File

@ -11,7 +11,6 @@ export const animations = [
{ label: '放大晃动缩小', value: 'tada' }, { label: '放大晃动缩小', value: 'tada' },
{ label: '扇形摇摆', value: 'wobble' }, { label: '扇形摇摆', value: 'wobble' },
{ label: '左右上下晃动', value: 'jello' }, { label: '左右上下晃动', value: 'jello' },
{ label: 'Y轴旋转', value: 'flip' }
] ]
}, },
{ {

View File

@ -1,26 +1,29 @@
<template> <template>
<!-- 事件配置 --> <!-- 事件配置 -->
<n-collapse class="go-mt-3" arrow-placement="right" default-expanded-names="1" accordion> <n-collapse class="go-mt-3" arrow-placement="right" default-expanded-names="1" accordion>
<n-text depth="3">组件 id <n-text>{{targetData.id}}</n-text></n-text> <n-text depth="3">
组件 id
<n-text>{{ targetData.id }}</n-text>
</n-text>
<n-collapse-item title="事件配置" name="1"> <n-collapse-item title="事件配置" name="1">
<n-space class="go-event go-mt-3" :size="18" vertical> <n-space class="go-event go-mt-3" :size="18" vertical>
<chart-event-monaco-editor></chart-event-monaco-editor> <chart-event-monaco-editor></chart-event-monaco-editor>
</n-space> </n-space>
</n-collapse-item> </n-collapse-item>
</n-collapse> </n-collapse>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ChartEventMonacoEditor } from '@/views/chart/ContentConfigurations/components/ChartData/components/ChartEventMonacoEditor' import { ChartEventMonacoEditor } from './components/ChartEventMonacoEditor'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook' import { useTargetData } from '../hooks/useTargetData.hook'
const { targetData } = useTargetData() const { targetData } = useTargetData()
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@include deep() { @include deep() {
.go-event .n-card__content{ .go-event .n-card__content {
max-height:60vh; max-height: 60vh;
overflow-y:auto; overflow-y: auto;
} }
} }
</style> </style>

View File

@ -75,13 +75,13 @@ const { getDetails } = toRefs(useChartLayoutStore())
const { setItem } = useChartLayoutStore() const { setItem } = useChartLayoutStore()
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, CodeSlashIcon } = icon.ionicons5 const { ConstructIcon, FlashIcon, DesktopOutlineIcon, LeafIcon, RocketIcon } = icon.ionicons5
const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue')) const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
const CanvasPage = loadAsyncComponent(() => import('./components/CanvasPage/index.vue')) const CanvasPage = loadAsyncComponent(() => import('./components/CanvasPage/index.vue'))
const ChartSetting = loadAsyncComponent(() => import('./components/ChartSetting/index.vue')) const ChartSetting = loadAsyncComponent(() => import('./components/ChartSetting/index.vue'))
const ChartData = loadAsyncComponent(() => import('./components/ChartData/index.vue')) const ChartData = loadAsyncComponent(() => import('./components/ChartData/index.vue'))
const ChartEvent = loadAsyncComponent(() => import('@/components/Pages/ChartItemSetting/EventSetting.vue')) const ChartEvent = loadAsyncComponent(() => import('./components/ChartEvent/index.vue'))
const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue')) const ChartAnimation = loadAsyncComponent(() => import('./components/ChartAnimation/index.vue'))
const collapsed = ref<boolean>(getDetails.value) const collapsed = ref<boolean>(getDetails.value)
@ -153,7 +153,7 @@ const chartsTabList = [
{ {
key: TabsEnum.CHART_EVENT, key: TabsEnum.CHART_EVENT,
title: '事件', title: '事件',
icon: CodeSlashIcon, icon: RocketIcon,
render: ChartEvent render: ChartEvent
} }
] ]