|
@@ -1,3 +1,4 @@
|
|
|
+<!-- eslint-disable @typescript-eslint/ban-ts-comment -->
|
|
|
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
|
|
<script setup lang="ts">
|
|
|
import { ref, onMounted } from 'vue'
|
|
@@ -10,7 +11,7 @@ import { RcRadio } from './plugins/components/rc-radio.config.ts'
|
|
|
import { RcCheckbox } from './plugins/components/rc-checkbox.config.ts'
|
|
|
// 菜单
|
|
|
import { MenuOptions } from './plugins/menu/options.ts'
|
|
|
-
|
|
|
+// @ts-expect-error
|
|
|
import type { FcDesignerInstance } from '@form-create/designer' // 注册组件
|
|
|
import type { Options, Rule } from '@form-create/element-ui'
|
|
|
import type { Option } from './components/rc-options/createOptions.ts'
|
|
@@ -23,6 +24,7 @@ declare global {
|
|
|
__QIANKUN__EVENT__: {
|
|
|
on: (name: string, fn: (...arg: any[]) => void) => void
|
|
|
emit: (name: string, ...arg: any[]) => boolean
|
|
|
+ off: (name: string, fn?: (...arg: any[]) => void) => void
|
|
|
} // 事件中心
|
|
|
__QIANKUN__REQUSET__: any // 请求API接口
|
|
|
__QIANKUN__GUID__: () => string // 获取唯一标识
|
|
@@ -57,37 +59,34 @@ const onSave = async (config: { options: string; rule: string }) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-window.__QIANKUN__EVENT__.on('formCoverChange', (cover: string) => {
|
|
|
- const newRule = designer.value!.getRule() as Rule[]
|
|
|
- if (!cover) {
|
|
|
- newRule.shift()
|
|
|
- designer.value?.setRule(newRule)
|
|
|
- return
|
|
|
- }
|
|
|
- const firstType = newRule[0]?.type
|
|
|
- if (firstType === 'rc-image') {
|
|
|
- newRule[0]!.props!.cover = cover
|
|
|
- } else {
|
|
|
- newRule.unshift({
|
|
|
- type: 'rc-image',
|
|
|
- props: {
|
|
|
- cover,
|
|
|
- },
|
|
|
- } as Rule)
|
|
|
- }
|
|
|
-
|
|
|
- designer.value?.setRule(JSON.stringify(newRule)) // 重新赋值
|
|
|
-})
|
|
|
-
|
|
|
onMounted(async () => {
|
|
|
- console.log(window.__QIANKUN__EVENT__)
|
|
|
-
|
|
|
// 注册拖拽规则
|
|
|
designer.value?.addMenu(MenuOptions)
|
|
|
designer.value?.addComponent(RcSelect)
|
|
|
designer.value?.addComponent(RcRadio)
|
|
|
designer.value?.addComponent(RcCheckbox)
|
|
|
+ const des = designer.value
|
|
|
+ window.__QIANKUN__EVENT__.on('formCoverChange', (cover: string) => {
|
|
|
+ const newRule = des?.getRule() as Rule[]
|
|
|
+ if (!cover) {
|
|
|
+ newRule.shift()
|
|
|
+ des?.setRule(newRule)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const firstType = newRule[0]?.type
|
|
|
+ if (firstType === 'rc-image') {
|
|
|
+ newRule[0]!.props!.cover = cover
|
|
|
+ } else {
|
|
|
+ newRule.unshift({
|
|
|
+ type: 'rc-image',
|
|
|
+ props: {
|
|
|
+ cover,
|
|
|
+ },
|
|
|
+ } as Rule)
|
|
|
+ }
|
|
|
|
|
|
+ des?.setRule(JSON.stringify(newRule)) // 重新赋值
|
|
|
+ })
|
|
|
id = location.search?.substring(1).split('=')[1] || ''
|
|
|
if (!id) return
|
|
|
|