UNPKG

epic-designer-dev

Version:

基于vue3的设计器,可视化开发页面表单。在epic-designer的基础上新增了字典选择器

207 lines (206 loc) 5 kB
import { ref as G } from "vue"; import { loadAsyncComponent as Z } from "../common/component.js"; import "@vueuse/core"; import "../../../hooks/src/store/index.js"; import { useFormSchema as _ } from "../../../hooks/src/plugin/useFormSchema.js"; import { usePanel as $ } from "../../../hooks/src/plugin/usePanel.js"; function ee() { let f = []; const o = {}; let p = {}; const c = {}, d = G([]), { formSchema: N, setFormSchema: b } = _(); let a = []; const h = G(!1), l = { // 示例数据 // publicTest: { // description: '测试函数', // handler: (e) => { // console.log(e); // // alert("测试函数弹出"); // }, // name: 'test', // }, }; let u = ["表单", "布局"]; const { getActivitybars: x, getRightSidebars: w, hideActivitybar: A, hideRightSidebar: B, registerActivitybar: E, registerRightSidebar: I, showActivitybar: P, showRightSidebar: R, viewsContainers: O } = $(); function T(e) { f.push(e); } function z(e) { e.methodName && console.warn( "[Epic:公共函数]注册配置'methodName'属性已弃用,请使用'name'代替" ), e.method && console.warn( "[Epic:公共函数]注册配置'method'属性已弃用,请使用'handler'代替" ), e.describe && console.warn( "[Epic:公共函数]注册配置'describe'属性已弃用,请使用'description'代替" ); const t = e.methodName ?? e.name, i = e.method ?? e.handler, n = e.describe ?? e.description; l[t] = { description: n, handler: i, name: t }; } function F() { p = {}; } function V() { u = [], r(); } function g(e, t) { typeof t == "function" && (t = Z(t)), c[e] = t; } function r() { const e = []; Object.values(o).forEach((t) => { if (!a.includes(t.defaultSchema.type) && t.groupName) { const i = p[t.groupName] ?? t.groupName; let n = e.findIndex( (m) => m.title === i ); n === -1 && (e.push({ title: i, list: [] }), n = e.length - 1); const s = e[n].list.findIndex( (m) => m.type === t.defaultSchema.type ); s === -1 ? e[n].list.push(t.defaultSchema) : e[n].list[s] = t.defaultSchema; } }), e.sort((t, i) => { const n = u.indexOf(t.title), s = u.indexOf(i.title); return n === -1 ? 1 : s === -1 ? -1 : n - s; }), e.forEach((t) => { t.list.sort((i, n) => { var C, v; const s = ((C = o[i.type]) == null ? void 0 : C.sort) ?? 1e3, m = ((v = o[n.type]) == null ? void 0 : v.sort) ?? 1e3; return s - m; }); }), d.value = e; } function j(e) { return c[e]; } function H(e) { return o[e]; } function k() { return o; } function q() { return c; } function D() { return d; } function J(e) { a.push(e), r(); } function K(e) { g(e.defaultSchema.type, e.component), e.defaultSchema.input && (e.config.action || (e.config.action = []), e.config.action.unshift( { // 参数配置 argsConfigs: [ { ...e.defaultSchema, field: "0", label: "设置数据" } ], description: "设置值", type: "setValue" }, { description: "获取值", type: "getValue" } )), o[e.defaultSchema.type] = e, r(); } function L() { f.forEach((e) => { S(e); }), y([]), r(); } function S(e) { delete o[e], delete c[e]; } function M(e) { delete l[e]; } function y(e) { f = e; } function Q(e, t) { p[e] = t; } function U(e) { a = e, r(); } function W(e) { h.value = e; } function X(e) { u = e, r(); } function Y(e) { a = a.filter((t) => t !== e), r(); } return { addBaseComponentTypes: T, addPublicMethod: z, baseComponentTypes: f, clearComponentGroupNameMap: F, clearSortedGroups: V, component: g, componentConfigs: o, componentGroupNameMap: p, components: c, componentSchemaGroups: d, formSchema: N, getActivitybars: x, getComponent: j, getComponentConfingByType: H, getComponentConfings: k, getComponents: q, getComponentSchemaGroups: D, getRightSidebars: w, hiddenComponents: a, hideActivitybar: A, hideComponent: J, hideRightSidebar: B, initialized: h, publicMethods: l, registerActivitybar: E, registerComponent: K, registerRightSidebar: I, removeBaseComponents: L, removeComponent: S, removePublicMethod: M, setBaseComponentTypes: y, setComponentGroupNameMap: Q, setFormSchema: b, setHideComponents: U, setInitialized: W, setSortedGroups: X, showActivitybar: P, showComponent: Y, showRightSidebar: R, sortedGroups: u, viewsContainers: O }; } const ae = ee(); export { ae as pluginManager, ee as usePluginManager };