@opentiny/tiny-engine-toolbar-save 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +74 -74
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import { reactive as
|
|
2
|
+
import { reactive as B, ref as P, onUnmounted as N, resolveComponent as m, openBlock as x, createElementBlock as h, createVNode as c, withCtx as r, createTextVNode as k, createBlock as O, createCommentVNode as M, createElementVNode as g } from "vue";
|
|
3
3
|
import { VueMonaco as U, ToolbarBase as D } from "@opentiny/tiny-engine-common";
|
|
4
4
|
import { Button as L, Popover as G, DialogBox as R, Checkbox as j, Select as J } from "@opentiny/vue";
|
|
5
|
-
import { usePage as q, useCanvas as
|
|
5
|
+
import { usePage as q, useCanvas as C, getOptions as z, useNotify as T, useLayout as F, getMetaApi as H, META_APP as K, useBlock as Q } from "@opentiny/tiny-engine-meta-register";
|
|
6
6
|
import { constants as W } from "@opentiny/tiny-engine-utils";
|
|
7
7
|
import { handlePageUpdate as X } from "@opentiny/tiny-engine-common/js/http";
|
|
8
|
-
const
|
|
8
|
+
const V = {
|
|
9
9
|
id: "engine.toolbars.save",
|
|
10
10
|
type: "toolbars",
|
|
11
11
|
title: "save",
|
|
@@ -15,78 +15,78 @@ const A = {
|
|
|
15
15
|
},
|
|
16
16
|
renderType: "button"
|
|
17
17
|
}
|
|
18
|
-
}, { PAGE_STATUS: u } = W,
|
|
18
|
+
}, { PAGE_STATUS: u } = W, _ = B({
|
|
19
19
|
visible: !1,
|
|
20
20
|
code: "",
|
|
21
21
|
originalCode: "",
|
|
22
22
|
disabled: !1
|
|
23
|
-
}),
|
|
24
|
-
var
|
|
23
|
+
}), y = P(!1), Y = async (n) => {
|
|
24
|
+
var i;
|
|
25
25
|
const e = H(K.BlockManage), { getCurrentBlock: t } = Q(), o = t();
|
|
26
|
-
o.label = n.fileName, o.content = n,
|
|
26
|
+
o.label = n.fileName, o.content = n, y.value = !0, o.screenshot = await e.getBlockBase64(), await ((i = e.saveBlock) == null ? void 0 : i.call(e, o)), y.value = !1;
|
|
27
27
|
}, Z = async (n) => {
|
|
28
|
-
const { currentPage: e } =
|
|
28
|
+
const { currentPage: e } = C().pageState, t = {
|
|
29
29
|
page_content: n
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
const { pageSettingState: e, isTemporaryPage: t } = q(), { isBlock: o, canvasApi:
|
|
34
|
-
if (s
|
|
31
|
+
y.value = !0, await X(e.id, { ...e, ...t }, !1, !0), y.value = !1;
|
|
32
|
+
}, S = (n) => {
|
|
33
|
+
const { pageSettingState: e, isTemporaryPage: t } = q(), { isBlock: o, canvasApi: i, pageState: s, resetBlockCanvasState: d, resetPageCanvasState: l } = C(), a = JSON.parse(n), { selectNode: v } = i.value;
|
|
34
|
+
if (o() ? d({ ...s, pageSchema: a }) : l({ ...s, pageSchema: a }), e != null && e.isAIPage) {
|
|
35
35
|
t.saved && (t.saved = !1), t.saved = !0;
|
|
36
|
-
const
|
|
37
|
-
return e.currentPageData[
|
|
36
|
+
const p = "page_content";
|
|
37
|
+
return e.currentPageData[p] = a, Promise.resolve();
|
|
38
38
|
}
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
var
|
|
42
|
-
const { isSaved: n,
|
|
43
|
-
if (n() ||
|
|
39
|
+
return v(null), o() ? Y(a) : Z(a);
|
|
40
|
+
}, A = async () => {
|
|
41
|
+
var p;
|
|
42
|
+
const { isSaved: n, getSchema: e } = C();
|
|
43
|
+
if (n() || _.disabled)
|
|
44
44
|
return;
|
|
45
|
-
const { beforeSave: t, saveMethod: o, saved:
|
|
45
|
+
const { beforeSave: t, saveMethod: o, saved: i } = z(V.id);
|
|
46
46
|
try {
|
|
47
47
|
if (typeof t == "function" && await t(), typeof o == "function" && await o())
|
|
48
48
|
return;
|
|
49
|
-
} catch (
|
|
50
|
-
|
|
49
|
+
} catch (f) {
|
|
50
|
+
T({
|
|
51
51
|
type: "error",
|
|
52
|
-
message: `Error in saving: ${
|
|
52
|
+
message: `Error in saving: ${f}`
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
const s = (
|
|
55
|
+
const s = (p = F().layoutState) == null ? void 0 : p.pageStatus, d = s == null ? void 0 : s.state, l = s == null ? void 0 : s.data, a = {
|
|
56
56
|
[u.Release]: "当前页面未锁定,请先锁定再保存",
|
|
57
57
|
[u.Empty]: "当前应用无页面,请先新建页面再保存",
|
|
58
58
|
[u.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
|
|
59
59
|
[u.Lock]: `当前页面被 ${l == null ? void 0 : l.username} ${l == null ? void 0 : l.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
|
|
60
60
|
};
|
|
61
|
-
if ([u.Release, u.Empty, u.Guest, u.Lock].includes(
|
|
62
|
-
|
|
61
|
+
if ([u.Release, u.Empty, u.Guest, u.Lock].includes(d)) {
|
|
62
|
+
T({
|
|
63
63
|
type: "error",
|
|
64
64
|
title: "保存失败",
|
|
65
|
-
message:
|
|
65
|
+
message: a[d]
|
|
66
66
|
});
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
if (
|
|
69
|
+
_.disabled = !0;
|
|
70
|
+
const v = e();
|
|
71
|
+
_.code = JSON.stringify(v || {}, null, 2), S(_.code).finally(() => {
|
|
72
|
+
if (_.disabled = !1, typeof i == "function")
|
|
73
73
|
try {
|
|
74
|
-
|
|
75
|
-
} catch (
|
|
76
|
-
|
|
74
|
+
i();
|
|
75
|
+
} catch (f) {
|
|
76
|
+
T({
|
|
77
77
|
type: "error",
|
|
78
|
-
message: `Error in saved: ${
|
|
78
|
+
message: `Error in saved: ${f}`
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}, I = (n, e) => {
|
|
83
83
|
const t = n.__vccOpts || n;
|
|
84
|
-
for (const [o,
|
|
85
|
-
t[o] =
|
|
84
|
+
for (const [o, i] of e)
|
|
85
|
+
t[o] = i;
|
|
86
86
|
return t;
|
|
87
87
|
}, $ = {
|
|
88
|
-
saveCommon:
|
|
89
|
-
openCommon:
|
|
88
|
+
saveCommon: S,
|
|
89
|
+
openCommon: A
|
|
90
90
|
}, ee = {
|
|
91
91
|
components: {
|
|
92
92
|
VueMonaco: U,
|
|
@@ -108,11 +108,11 @@ const A = {
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
setup() {
|
|
111
|
-
const { isSaved: n } =
|
|
111
|
+
const { isSaved: n } = C(), e = [
|
|
112
112
|
{ value: 5, label: "5分钟" },
|
|
113
113
|
{ value: 10, label: "10分钟" },
|
|
114
114
|
{ value: 15, label: "15分钟" }
|
|
115
|
-
], t =
|
|
115
|
+
], t = B({
|
|
116
116
|
visible: !1,
|
|
117
117
|
code: "",
|
|
118
118
|
originalCode: "",
|
|
@@ -120,77 +120,77 @@ const A = {
|
|
|
120
120
|
timeValue: 5,
|
|
121
121
|
checked: !1,
|
|
122
122
|
preservationTime: null
|
|
123
|
-
}), o =
|
|
123
|
+
}), o = P(null), i = () => {
|
|
124
124
|
t.visible = !1, t.originalCode = "";
|
|
125
125
|
}, s = () => {
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
|
|
126
|
+
y.value || A();
|
|
127
|
+
}, d = () => {
|
|
128
|
+
S();
|
|
129
129
|
}, l = {
|
|
130
130
|
language: "json",
|
|
131
131
|
lineNumbers: !0,
|
|
132
132
|
minimap: {
|
|
133
133
|
enabled: !1
|
|
134
134
|
}
|
|
135
|
-
},
|
|
135
|
+
}, a = () => {
|
|
136
136
|
clearTimeout(t.preservationTime), t.preservationTime = setTimeout(() => {
|
|
137
|
-
s(),
|
|
137
|
+
s(), a();
|
|
138
138
|
}, t.timeValue * 60 * 1e3);
|
|
139
139
|
}, v = () => {
|
|
140
|
-
t.checked ?
|
|
140
|
+
t.checked ? a() : clearTimeout(t.preservationTime);
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return N(() => {
|
|
143
143
|
clearTimeout(t.preservationTime);
|
|
144
144
|
}), {
|
|
145
145
|
state: t,
|
|
146
146
|
editor: o,
|
|
147
147
|
editorOptions: l,
|
|
148
|
-
isLoading:
|
|
148
|
+
isLoading: y,
|
|
149
149
|
isSaved: n,
|
|
150
|
-
close:
|
|
150
|
+
close: i,
|
|
151
151
|
openApi: s,
|
|
152
|
-
saveApi:
|
|
152
|
+
saveApi: d,
|
|
153
153
|
delayOptions: e,
|
|
154
154
|
autoSave: v
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
}, oe = { class: "toolbar-save" }, te = { class: "save-style" }, ne = { class: "save-time" }, ae = { class: "save-button-group" };
|
|
158
|
-
function se(n, e, t, o,
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
|
|
158
|
+
function se(n, e, t, o, i, s) {
|
|
159
|
+
const d = m("svg-icon"), l = m("vue-monaco"), a = m("tiny-button"), v = m("tiny-dialog-box"), p = m("toolbar-base"), f = m("tiny-checkbox"), w = m("tiny-select"), E = m("tiny-popover");
|
|
160
|
+
return x(), h("div", oe, [
|
|
161
|
+
c(E, {
|
|
162
162
|
"visible-arrow": !1,
|
|
163
163
|
width: "203",
|
|
164
164
|
trigger: "hover"
|
|
165
165
|
}, {
|
|
166
166
|
reference: r(() => [
|
|
167
|
-
|
|
167
|
+
c(p, {
|
|
168
168
|
content: o.isLoading ? "保存中" : "保存",
|
|
169
169
|
icon: t.options.icon.default || t.options.icon,
|
|
170
170
|
options: { ...t.options, showDots: !o.isSaved() },
|
|
171
171
|
onClickApi: o.openApi
|
|
172
172
|
}, {
|
|
173
173
|
button: r(() => [
|
|
174
|
-
d
|
|
174
|
+
c(d, { name: t.iconExpand }, null, 8, ["name"])
|
|
175
175
|
]),
|
|
176
176
|
default: r(() => [
|
|
177
|
-
|
|
177
|
+
c(v, {
|
|
178
178
|
class: "dialog-box",
|
|
179
179
|
modal: !1,
|
|
180
180
|
fullscreen: !0,
|
|
181
181
|
"append-to-body": !0,
|
|
182
182
|
visible: o.state.visible,
|
|
183
183
|
title: "Schema 本地与线上差异",
|
|
184
|
-
"onUpdate:visible": e[0] || (e[0] = (
|
|
184
|
+
"onUpdate:visible": e[0] || (e[0] = (b) => o.state.visible = b)
|
|
185
185
|
}, {
|
|
186
186
|
footer: r(() => [
|
|
187
|
-
|
|
187
|
+
c(a, { onClick: o.close }, {
|
|
188
188
|
default: r(() => e[3] || (e[3] = [
|
|
189
189
|
k("取 消")
|
|
190
190
|
])),
|
|
191
191
|
_: 1
|
|
192
192
|
}, 8, ["onClick"]),
|
|
193
|
-
|
|
193
|
+
c(a, {
|
|
194
194
|
type: "primary",
|
|
195
195
|
onClick: o.saveApi
|
|
196
196
|
}, {
|
|
@@ -201,7 +201,7 @@ function se(n, e, t, o, a, s) {
|
|
|
201
201
|
}, 8, ["onClick"])
|
|
202
202
|
]),
|
|
203
203
|
default: r(() => [
|
|
204
|
-
o.state.visible ? (
|
|
204
|
+
o.state.visible ? (x(), O(l, {
|
|
205
205
|
key: 0,
|
|
206
206
|
ref: "editor",
|
|
207
207
|
class: "monaco-editor",
|
|
@@ -218,11 +218,11 @@ function se(n, e, t, o, a, s) {
|
|
|
218
218
|
}, 8, ["content", "icon", "options", "onClickApi"])
|
|
219
219
|
]),
|
|
220
220
|
default: r(() => [
|
|
221
|
-
|
|
222
|
-
e[8] || (e[8] =
|
|
223
|
-
|
|
221
|
+
g("div", te, [
|
|
222
|
+
e[8] || (e[8] = g("div", { class: "save-setting" }, "保存设置", -1)),
|
|
223
|
+
c(f, {
|
|
224
224
|
modelValue: o.state.checked,
|
|
225
|
-
"onUpdate:modelValue": e[1] || (e[1] = (
|
|
225
|
+
"onUpdate:modelValue": e[1] || (e[1] = (b) => o.state.checked = b),
|
|
226
226
|
name: "tiny-checkbox"
|
|
227
227
|
}, {
|
|
228
228
|
default: r(() => e[5] || (e[5] = [
|
|
@@ -230,18 +230,18 @@ function se(n, e, t, o, a, s) {
|
|
|
230
230
|
])),
|
|
231
231
|
_: 1
|
|
232
232
|
}, 8, ["modelValue"]),
|
|
233
|
-
|
|
234
|
-
e[6] || (e[6] =
|
|
235
|
-
|
|
233
|
+
g("div", ne, [
|
|
234
|
+
e[6] || (e[6] = g("div", { class: "save-time-label" }, "保存间隔", -1)),
|
|
235
|
+
c(w, {
|
|
236
236
|
modelValue: o.state.timeValue,
|
|
237
|
-
"onUpdate:modelValue": e[2] || (e[2] = (
|
|
237
|
+
"onUpdate:modelValue": e[2] || (e[2] = (b) => o.state.timeValue = b),
|
|
238
238
|
options: o.delayOptions,
|
|
239
239
|
disabled: !o.state.checked,
|
|
240
240
|
autocomplete: ""
|
|
241
241
|
}, null, 8, ["modelValue", "options", "disabled"])
|
|
242
242
|
]),
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
g("div", ae, [
|
|
244
|
+
c(a, {
|
|
245
245
|
type: "primary",
|
|
246
246
|
onClick: o.autoSave
|
|
247
247
|
}, {
|
|
@@ -258,7 +258,7 @@ function se(n, e, t, o, a, s) {
|
|
|
258
258
|
]);
|
|
259
259
|
}
|
|
260
260
|
const ie = /* @__PURE__ */ I(ee, [["render", se], ["__scopeId", "data-v-75c21aff"]]), pe = {
|
|
261
|
-
...
|
|
261
|
+
...V,
|
|
262
262
|
entry: ie,
|
|
263
263
|
apis: $
|
|
264
264
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"homepage": "https://opentiny.design/tiny-engine",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opentiny/tiny-engine-common": "2.
|
|
29
|
-
"@opentiny/tiny-engine-meta-register": "2.
|
|
30
|
-
"@opentiny/tiny-engine-utils": "2.
|
|
28
|
+
"@opentiny/tiny-engine-common": "2.1.0",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.1.0",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.
|
|
33
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.1.0",
|
|
34
34
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
35
35
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
36
36
|
"vite": "^5.4.2"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"@opentiny/vue": "^3.14.0",
|
|
40
40
|
"vue": "^3.4.15"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "faf3072c75ea5024689972e2a687916e084c156f"
|
|
43
43
|
}
|