fx-epic-designer
Version:
基于vue3的设计器,可视化开发页面表单
65 lines (64 loc) • 1.78 kB
JavaScript
import { ref as n } from "vue";
/* empty css */
import "vuedraggable";
import { deepCompareAndModify as g, findSchemaById as y } from "../common/data.js";
import "@vueuse/core";
import "../../../hooks/src/store/index.js";
import "./pluginManager.js";
function w(o, i, f) {
const l = n([]), t = n([]), e = n(null);
let a = 0;
const s = (u) => {
try {
g(o, JSON.parse(u.pageSchema));
const r = u.selectedId ? y(o.schemas, u.selectedId) : void 0;
f(r || void 0);
} catch (r) {
console.error("解析历史记录失败:", r);
}
};
function p(u = "插入组件") {
var c, d, v;
if (u === "加载数据" && ((c = e.value) == null ? void 0 : c.type) === "初始化") {
e.value = {
pageSchema: JSON.stringify(o),
selectedId: (d = i.selectedNode) == null ? void 0 : d.id,
type: u
};
return;
}
const r = Date.now();
a + 150 > r || (a = r, e.value !== null && (l.value.push(e.value), t.value = []), e.value = {
pageSchema: JSON.stringify(o),
selectedId: (v = i.selectedNode) == null ? void 0 : v.id,
type: u
}, l.value.length > 60 && l.value.shift());
}
function m() {
if (l.value.length === 0)
return !1;
const u = l.value.pop();
return e.value !== null && t.value.push(e.value), e.value = u, s(u), !0;
}
function h() {
if (t.value.length === 0)
return !1;
const u = t.value.pop();
return e.value !== null && l.value.push(e.value), e.value = u, s(u), !0;
}
function N() {
l.value = [], t.value = [], e.value = null;
}
return {
currentRecord: e,
push: p,
recordList: l,
redo: h,
reset: N,
undo: m,
undoList: t
};
}
export {
w as useRevoke
};