|
@@ -10,13 +10,15 @@
|
|
|
编辑
|
|
编辑
|
|
|
</n-button>
|
|
</n-button>
|
|
|
</template>
|
|
</template>
|
|
|
- <n-card>
|
|
|
|
|
|
|
+ <n-card class="collapse-show-box">
|
|
|
<!-- 函数体 -->
|
|
<!-- 函数体 -->
|
|
|
<div v-for="eventName in EventLife" :key="eventName">
|
|
<div v-for="eventName in EventLife" :key="eventName">
|
|
|
<p>
|
|
<p>
|
|
|
|
|
+ <span class="func-annotate">// {{ EventLifeName[eventName] }}</span>
|
|
|
|
|
+ <br />
|
|
|
<span class="func-keyword">async {{ eventName }}</span> (e, components, echarts, node_modules) {
|
|
<span class="func-keyword">async {{ eventName }}</span> (e, components, echarts, node_modules) {
|
|
|
</p>
|
|
</p>
|
|
|
- <p class="go-ml-4"><n-code :code="(targetData.events || {})[eventName]" language="typescript"></n-code></p>
|
|
|
|
|
|
|
+ <p class="go-ml-4"><n-code :code="(targetData.events.advancedEvents || {})[eventName]" language="typescript"></n-code></p>
|
|
|
<p>}<span>,</span></p>
|
|
<p>}<span>,</span></p>
|
|
|
</div>
|
|
</div>
|
|
|
</n-card>
|
|
</n-card>
|
|
@@ -30,13 +32,15 @@
|
|
|
<n-text>高级事件编辑器(配合源码使用)</n-text>
|
|
<n-text>高级事件编辑器(配合源码使用)</n-text>
|
|
|
</n-space>
|
|
</n-space>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+
|
|
|
<template #header-extra> </template>
|
|
<template #header-extra> </template>
|
|
|
|
|
+
|
|
|
<n-layout has-sider sider-placement="right">
|
|
<n-layout has-sider sider-placement="right">
|
|
|
<n-layout style="height: 580px; padding-right: 20px">
|
|
<n-layout style="height: 580px; padding-right: 20px">
|
|
|
<n-tabs v-model:value="editTab" type="card" tab-style="min-width: 100px;">
|
|
<n-tabs v-model:value="editTab" type="card" tab-style="min-width: 100px;">
|
|
|
<!-- 提示 -->
|
|
<!-- 提示 -->
|
|
|
<template #suffix>
|
|
<template #suffix>
|
|
|
- <n-text class="tab-tip" type="warning">tips: {{ EventLifeTip[editTab] }}</n-text>
|
|
|
|
|
|
|
+ <n-text class="tab-tip" type="warning">提示: {{ EventLifeTip[editTab] }}</n-text>
|
|
|
</template>
|
|
</template>
|
|
|
<n-tab-pane
|
|
<n-tab-pane
|
|
|
v-for="(eventName, index) in EventLife"
|
|
v-for="(eventName, index) in EventLife"
|
|
@@ -50,7 +54,7 @@
|
|
|
<span class="func-keyNameWord">{{ eventName }}(e, components, echarts, node_modules) {</span>
|
|
<span class="func-keyNameWord">{{ eventName }}(e, components, echarts, node_modules) {</span>
|
|
|
</p>
|
|
</p>
|
|
|
<!-- 编辑主体 -->
|
|
<!-- 编辑主体 -->
|
|
|
- <monaco-editor v-model:modelValue="events[eventName]" height="480px" language="javascript" />
|
|
|
|
|
|
|
+ <monaco-editor v-model:modelValue="advancedEvents[eventName]" height="480px" language="javascript" />
|
|
|
<!-- 函数结束 -->
|
|
<!-- 函数结束 -->
|
|
|
<p class="go-pl-3 func-keyNameWord">}</p>
|
|
<p class="go-pl-3 func-keyNameWord">}</p>
|
|
|
</n-tab-pane>
|
|
</n-tab-pane>
|
|
@@ -136,7 +140,7 @@
|
|
|
<template #icon>
|
|
<template #icon>
|
|
|
<n-icon :component="DocumentTextIcon" />
|
|
<n-icon :component="DocumentTextIcon" />
|
|
|
</template>
|
|
</template>
|
|
|
- 提示
|
|
|
|
|
|
|
+ 说明
|
|
|
</n-tag>
|
|
</n-tag>
|
|
|
<n-text class="go-ml-2" depth="2">通过提供的参数可为图表增加定制化的tooltip、交互事件等等</n-text>
|
|
<n-text class="go-ml-2" depth="2">通过提供的参数可为图表增加定制化的tooltip、交互事件等等</n-text>
|
|
|
</div>
|
|
</div>
|
|
@@ -158,29 +162,27 @@ import { useTargetData } from '../../../hooks/useTargetData.hook'
|
|
|
import { templateList } from './importTemplate'
|
|
import { templateList } from './importTemplate'
|
|
|
import { npmPkgs } from '@/hooks'
|
|
import { npmPkgs } from '@/hooks'
|
|
|
import { icon } from '@/plugins'
|
|
import { icon } from '@/plugins'
|
|
|
-import { goDialog, toString } from '@/utils'
|
|
|
|
|
import { CreateComponentType, EventLife } from '@/packages/index.d'
|
|
import { CreateComponentType, EventLife } from '@/packages/index.d'
|
|
|
-import { Script } from 'vm'
|
|
|
|
|
|
|
|
|
|
const { targetData, chartEditStore } = useTargetData()
|
|
const { targetData, chartEditStore } = useTargetData()
|
|
|
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
|
|
const { DocumentTextIcon, ChevronDownIcon, PencilIcon } = icon.ionicons5
|
|
|
|
|
|
|
|
const EventLifeName = {
|
|
const EventLifeName = {
|
|
|
- [EventLife.BEFORE_MOUNT]: '渲染之前',
|
|
|
|
|
- [EventLife.MOUNTED]: '渲染之后'
|
|
|
|
|
|
|
+ [EventLife.VNODE_BEFORE_MOUNT]: '渲染之前',
|
|
|
|
|
+ [EventLife.VNODE_MOUNTED]: '渲染之后'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const EventLifeTip = {
|
|
const EventLifeTip = {
|
|
|
- [EventLife.BEFORE_MOUNT]: '此时组件 DOM 还未存在',
|
|
|
|
|
- [EventLife.MOUNTED]: '此时组件 DOM 已经存在'
|
|
|
|
|
|
|
+ [EventLife.VNODE_BEFORE_MOUNT]: '此时组件 DOM 还未存在',
|
|
|
|
|
+ [EventLife.VNODE_MOUNTED]: '此时组件 DOM 已经存在'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 受控弹窗
|
|
// 受控弹窗
|
|
|
const showModal = ref(false)
|
|
const showModal = ref(false)
|
|
|
// 编辑区域控制
|
|
// 编辑区域控制
|
|
|
-const editTab = ref(EventLife.MOUNTED)
|
|
|
|
|
|
|
+const editTab = ref(EventLife.VNODE_MOUNTED)
|
|
|
// events 函数模板
|
|
// events 函数模板
|
|
|
-let events = ref({ ...targetData.value.events })
|
|
|
|
|
|
|
+let advancedEvents = ref({ ...targetData.value.events.advancedEvents })
|
|
|
// 事件错误标识
|
|
// 事件错误标识
|
|
|
const errorFlag = ref(false)
|
|
const errorFlag = ref(false)
|
|
|
|
|
|
|
@@ -190,7 +192,7 @@ const validEvents = () => {
|
|
|
let message = ''
|
|
let message = ''
|
|
|
let name = ''
|
|
let name = ''
|
|
|
|
|
|
|
|
- errorFlag.value = Object.entries(events.value).every(([eventName, str]) => {
|
|
|
|
|
|
|
+ errorFlag.value = Object.entries(advancedEvents.value).every(([eventName, str]) => {
|
|
|
try {
|
|
try {
|
|
|
// 支持await,验证语法
|
|
// 支持await,验证语法
|
|
|
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
|
|
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
|
|
@@ -221,11 +223,14 @@ const saveEvents = () => {
|
|
|
window['$message'].error('事件函数错误,无法进行保存')
|
|
window['$message'].error('事件函数错误,无法进行保存')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (Object.values(events.value).join('').trim() === '') {
|
|
|
|
|
|
|
+ if (Object.values(advancedEvents.value).join('').trim() === '') {
|
|
|
// 清空事件
|
|
// 清空事件
|
|
|
- targetData.value.events = undefined
|
|
|
|
|
|
|
+ targetData.value.events.advancedEvents = {
|
|
|
|
|
+ vnodeBeforeMount: undefined,
|
|
|
|
|
+ vnodeMounted: undefined,
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- targetData.value.events = { ...events.value }
|
|
|
|
|
|
|
+ targetData.value.events.advancedEvents = { ...advancedEvents.value }
|
|
|
}
|
|
}
|
|
|
closeEvents()
|
|
closeEvents()
|
|
|
}
|
|
}
|
|
@@ -234,52 +239,12 @@ watch(
|
|
|
() => showModal.value,
|
|
() => showModal.value,
|
|
|
(newData: boolean) => {
|
|
(newData: boolean) => {
|
|
|
if (newData) {
|
|
if (newData) {
|
|
|
- events.value = { ...targetData.value.events }
|
|
|
|
|
|
|
+ advancedEvents.value = { ...targetData.value.events.advancedEvents }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
-/* 外层也要使用 */
|
|
|
|
|
-.func-keyword {
|
|
|
|
|
- color: #b478cf;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-@include go('chart-data-monaco-editor') {
|
|
|
|
|
- .func-keyNameWord {
|
|
|
|
|
- color: #70c0e8;
|
|
|
|
|
- }
|
|
|
|
|
- .tab-tip {
|
|
|
|
|
- font-size: 12px;
|
|
|
|
|
- }
|
|
|
|
|
- &.n-card.n-modal,
|
|
|
|
|
- .n-card {
|
|
|
|
|
- @extend .go-background-filter;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-@include deep() {
|
|
|
|
|
- .n-layout,
|
|
|
|
|
- .n-layout-sider {
|
|
|
|
|
- background-color: transparent;
|
|
|
|
|
- }
|
|
|
|
|
- .go-editor-area {
|
|
|
|
|
- max-height: 530px;
|
|
|
|
|
- }
|
|
|
|
|
- .checkbox--hidden:checked {
|
|
|
|
|
- & + label {
|
|
|
|
|
- .n-icon {
|
|
|
|
|
- transition: all 0.3s;
|
|
|
|
|
- transform: rotate(180deg);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- & ~ .go-editor-area {
|
|
|
|
|
- display: none;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 优化代码换行
|
|
|
|
|
- .n-code > pre {
|
|
|
|
|
- white-space: break-spaces;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+@import '../index.scss';
|
|
|
</style>
|
|
</style>
|