UNPKG

snowy-designer

Version:

基于Epic-Designer-Pro版本的设计器,可视化开发页面表单

86 lines (85 loc) 2.24 kB
import { effectScope as N, ref as i } from "vue"; /* empty css */ import "radix-vue"; import "clsx"; import "tailwind-merge"; import "lucide-vue-next"; import "../../../ui-kit/base-ui/src/shadch-ui/button/index.js"; import "@vueuse/core"; import "../../../ui-kit/base-ui/src/shadch-ui/toast/index.js"; import "vuedraggable"; import { deepCompareAndModify as y, findSchemaById as E } from "../common/data.js"; import "../../../hooks/src/store/index.js"; import "lodash"; import "./pluginManager.js"; import "monaco-editor"; import "../request/index.js"; function q(l, d, v) { const f = N(), o = i([]), u = i([]), t = i(null), m = 60, h = 150; let c = 0; const s = (e) => { try { const r = JSON.parse(e.pageSchema); y(l, r); const n = e.selectedId ? E(l.schemas, e.selectedId) : void 0; v(n ?? void 0); } catch (r) { console.error("解析历史记录失败:", r); } }, a = (e) => { var r; return { pageSchema: JSON.stringify(l), selectedId: (r = d.selectedNode) == null ? void 0 : r.id, type: e }; }; function g(e = "插入组件") { var n; if (e === "加载数据" && ((n = t.value) == null ? void 0 : n.type) === "初始化") { t.value = a(e); return; } const r = Date.now(); c + h > r || (c = r, t.value !== null && (o.value.push(t.value), u.value = []), t.value = a(e), o.value.length > m && o.value.shift()); } function R() { if (o.value.length === 0) return !1; const e = o.value.pop(); return t.value !== null && u.value.push(t.value), t.value = e, s(e), !0; } function O() { if (u.value.length === 0) return !1; const e = u.value.pop(); return t.value !== null && o.value.push(t.value), t.value = e, s(e), !0; } function p() { o.value = [], u.value = [], t.value = null; } function S() { return o.value.length; } function C() { return u.value.length; } function I() { f.stop(), p(); } return { currentRecord: t, dispose: I, getRedoCount: C, getUndoCount: S, push: g, recordList: o, redo: O, reset: p, undo: R, undoList: u }; } export { q as useRevoke };