@opentiny/tiny-engine-toolbar-save 2.4.1-rc.0 → 2.4.2
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 +73 -73
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import { reactive as
|
|
3
|
-
import { ToolbarBase as
|
|
4
|
-
import { Select as
|
|
5
|
-
import { useCanvas as
|
|
6
|
-
import { constants as
|
|
2
|
+
import { reactive as N, ref as B, onMounted as P, onUnmounted as x, resolveComponent as f, createElementBlock as L, openBlock as E, createVNode as v, withCtx as d, createBlock as U, createCommentVNode as I, createTextVNode as S, createElementVNode as k } from "vue";
|
|
3
|
+
import { ToolbarBase as G, VueMonaco as R } from "@opentiny/tiny-engine-common";
|
|
4
|
+
import { Select as j, Checkbox as Y, DialogBox as q, Popover as z, Button as F } from "@opentiny/vue";
|
|
5
|
+
import { useCanvas as C, getOptions as H, useNotify as A, useLayout as K, usePage as Q, getMetaApi as W, META_APP as X, useBlock as Z, useMessage as $ } from "@opentiny/tiny-engine-meta-register";
|
|
6
|
+
import { constants as V } from "@opentiny/tiny-engine-utils";
|
|
7
7
|
import { handlePageUpdate as ee } from "@opentiny/tiny-engine-common/js/http";
|
|
8
|
-
const
|
|
8
|
+
const w = {
|
|
9
9
|
id: "engine.toolbars.save",
|
|
10
10
|
type: "toolbars",
|
|
11
11
|
title: "save",
|
|
@@ -15,17 +15,17 @@ const V = {
|
|
|
15
15
|
},
|
|
16
16
|
renderType: "button"
|
|
17
17
|
}
|
|
18
|
-
}, { PAGE_STATUS: g, AUTO_SAVED:
|
|
18
|
+
}, { PAGE_STATUS: g, AUTO_SAVED: D } = V, _ = N({
|
|
19
19
|
visible: !1,
|
|
20
20
|
code: "",
|
|
21
21
|
originalCode: "",
|
|
22
22
|
disabled: !1
|
|
23
|
-
}), b =
|
|
23
|
+
}), b = B(!1), te = async (a) => {
|
|
24
24
|
var s;
|
|
25
25
|
const e = W(X.BlockManage), { getCurrentBlock: o } = Z(), t = o();
|
|
26
26
|
t.label = a.fileName, t.content = a, b.value = !0, t.screenshot = await e.getBlockBase64(), await ((s = e.saveBlock) == null ? void 0 : s.call(e, t)), b.value = !1;
|
|
27
27
|
}, oe = async (a) => {
|
|
28
|
-
const { currentPage: e } =
|
|
28
|
+
const { currentPage: e } = C().pageState, o = {
|
|
29
29
|
page_content: a
|
|
30
30
|
};
|
|
31
31
|
b.value = !0;
|
|
@@ -34,27 +34,27 @@ const V = {
|
|
|
34
34
|
params: { ...e, ...o }
|
|
35
35
|
};
|
|
36
36
|
await ee(t), b.value = !1;
|
|
37
|
-
},
|
|
38
|
-
const { pageSettingState: e, isTemporaryPage: o } = Q(), { isBlock: t, canvasApi: s, pageState: l, resetBlockCanvasState: r, resetPageCanvasState: i } =
|
|
37
|
+
}, O = (a) => {
|
|
38
|
+
const { pageSettingState: e, isTemporaryPage: o } = Q(), { isBlock: t, canvasApi: s, pageState: l, resetBlockCanvasState: r, resetPageCanvasState: i } = C(), n = JSON.parse(a), { selectNode: c } = s.value;
|
|
39
39
|
if (t() ? r({ ...l, pageSchema: n }) : i({ ...l, pageSchema: n }), e != null && e.isAIPage) {
|
|
40
40
|
o.saved && (o.saved = !1), o.saved = !0;
|
|
41
41
|
const p = "page_content";
|
|
42
42
|
return e.currentPageData[p] = n, Promise.resolve();
|
|
43
43
|
}
|
|
44
44
|
return c(null), t() ? te(n) : oe(n);
|
|
45
|
-
},
|
|
45
|
+
}, M = async () => {
|
|
46
46
|
var p;
|
|
47
|
-
const { isSaved: a, getSchema: e } =
|
|
47
|
+
const { isSaved: a, getSchema: e } = C();
|
|
48
48
|
if (a() || _.disabled)
|
|
49
49
|
return;
|
|
50
|
-
const { beforeSave: o, saveMethod: t, saved: s } = H(
|
|
50
|
+
const { beforeSave: o, saveMethod: t, saved: s } = H(w.id);
|
|
51
51
|
try {
|
|
52
52
|
if (typeof o == "function" && await o(), typeof t == "function" && await t())
|
|
53
53
|
return;
|
|
54
|
-
} catch (
|
|
55
|
-
|
|
54
|
+
} catch (u) {
|
|
55
|
+
A({
|
|
56
56
|
type: "error",
|
|
57
|
-
message: `Error in saving: ${
|
|
57
|
+
message: `Error in saving: ${u}`
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
const l = (p = K().layoutState) == null ? void 0 : p.pageStatus, r = l == null ? void 0 : l.state, i = l == null ? void 0 : l.data, n = {
|
|
@@ -64,7 +64,7 @@ const V = {
|
|
|
64
64
|
[g.Lock]: `当前页面被 ${i == null ? void 0 : i.username} ${i == null ? void 0 : i.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
|
|
65
65
|
};
|
|
66
66
|
if ([g.Release, g.Empty, g.Guest, g.Lock].includes(r)) {
|
|
67
|
-
|
|
67
|
+
A({
|
|
68
68
|
type: "error",
|
|
69
69
|
title: "保存失败",
|
|
70
70
|
message: n[r]
|
|
@@ -73,42 +73,42 @@ const V = {
|
|
|
73
73
|
}
|
|
74
74
|
_.disabled = !0;
|
|
75
75
|
const c = e();
|
|
76
|
-
_.code = JSON.stringify(c || {}, null, 2),
|
|
76
|
+
_.code = JSON.stringify(c || {}, null, 2), O(_.code).finally(() => {
|
|
77
77
|
if (_.disabled = !1, typeof s == "function")
|
|
78
78
|
try {
|
|
79
79
|
s();
|
|
80
|
-
} catch (
|
|
81
|
-
|
|
80
|
+
} catch (u) {
|
|
81
|
+
A({
|
|
82
82
|
type: "error",
|
|
83
|
-
message: `Error in saved: ${
|
|
83
|
+
message: `Error in saved: ${u}`
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
}, ae = () => {
|
|
88
88
|
try {
|
|
89
|
-
const a = localStorage.getItem(
|
|
89
|
+
const a = localStorage.getItem(D) ?? "";
|
|
90
90
|
return JSON.parse(a) ?? !1;
|
|
91
91
|
} catch {
|
|
92
92
|
return !1;
|
|
93
93
|
}
|
|
94
94
|
}, ne = (a) => {
|
|
95
95
|
try {
|
|
96
|
-
return localStorage.setItem(
|
|
96
|
+
return localStorage.setItem(D, JSON.stringify(a)), !0;
|
|
97
97
|
} catch {
|
|
98
98
|
return !1;
|
|
99
99
|
}
|
|
100
|
-
}, { OPEN_DELAY: se } =
|
|
101
|
-
saveCommon:
|
|
102
|
-
openCommon:
|
|
100
|
+
}, { OPEN_DELAY: se } = V, ie = {
|
|
101
|
+
saveCommon: O,
|
|
102
|
+
openCommon: M
|
|
103
103
|
}, le = {
|
|
104
104
|
components: {
|
|
105
|
-
VueMonaco:
|
|
106
|
-
TinyButton:
|
|
107
|
-
TinyPopover:
|
|
108
|
-
TinyDialogBox:
|
|
109
|
-
TinyCheckbox:
|
|
110
|
-
TinySelect:
|
|
111
|
-
ToolbarBase:
|
|
105
|
+
VueMonaco: R,
|
|
106
|
+
TinyButton: F,
|
|
107
|
+
TinyPopover: z,
|
|
108
|
+
TinyDialogBox: q,
|
|
109
|
+
TinyCheckbox: Y,
|
|
110
|
+
TinySelect: j,
|
|
111
|
+
ToolbarBase: G
|
|
112
112
|
},
|
|
113
113
|
props: {
|
|
114
114
|
iconExpand: {
|
|
@@ -125,15 +125,15 @@ const V = {
|
|
|
125
125
|
{ value: 5, label: "5分钟" },
|
|
126
126
|
{ value: 10, label: "10分钟" },
|
|
127
127
|
{ value: 15, label: "15分钟" }
|
|
128
|
-
], e =
|
|
128
|
+
], e = N({
|
|
129
129
|
visible: !1,
|
|
130
130
|
code: "",
|
|
131
131
|
originalCode: "",
|
|
132
132
|
checked: !1,
|
|
133
133
|
timeValue: 5,
|
|
134
134
|
preservationTime: null
|
|
135
|
-
}), o =
|
|
136
|
-
|
|
135
|
+
}), o = B(null), { isSaved: t, setSaved: s, getSchema: l } = C(), { subscribe: r, unsubscribe: i } = $(), n = "toolbar-save", c = B(null);
|
|
136
|
+
P(() => {
|
|
137
137
|
r({
|
|
138
138
|
topic: "pageOrBlockInit",
|
|
139
139
|
subscriber: n,
|
|
@@ -159,16 +159,16 @@ const V = {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
-
}),
|
|
162
|
+
}), x(() => {
|
|
163
163
|
i({ topic: "pageOrBlockInit", subscriber: n }), i({ topic: "schemaChange", subscriber: n }), i({ topic: "schemaImport", subscriber: n });
|
|
164
164
|
});
|
|
165
165
|
const p = () => {
|
|
166
166
|
e.visible = !1, e.originalCode = "";
|
|
167
|
-
},
|
|
168
|
-
b.value ||
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
},
|
|
167
|
+
}, u = () => {
|
|
168
|
+
b.value || M();
|
|
169
|
+
}, h = () => {
|
|
170
|
+
O();
|
|
171
|
+
}, T = {
|
|
172
172
|
language: "json",
|
|
173
173
|
lineNumbers: !0,
|
|
174
174
|
minimap: {
|
|
@@ -176,26 +176,26 @@ const V = {
|
|
|
176
176
|
}
|
|
177
177
|
}, m = () => {
|
|
178
178
|
clearTimeout(e.preservationTime), e.preservationTime = setTimeout(() => {
|
|
179
|
-
|
|
179
|
+
u(), m();
|
|
180
180
|
}, e.timeValue * 60 * 1e3);
|
|
181
|
-
},
|
|
181
|
+
}, J = () => {
|
|
182
182
|
ne(e.checked), e.checked ? m() : clearTimeout(e.preservationTime);
|
|
183
183
|
};
|
|
184
|
-
return
|
|
184
|
+
return P(() => {
|
|
185
185
|
e.checked = ae(), e.checked && m();
|
|
186
|
-
}),
|
|
186
|
+
}), x(() => {
|
|
187
187
|
clearTimeout(e.preservationTime);
|
|
188
188
|
}), {
|
|
189
189
|
state: e,
|
|
190
190
|
editor: o,
|
|
191
|
-
editorOptions:
|
|
191
|
+
editorOptions: T,
|
|
192
192
|
isLoading: b,
|
|
193
193
|
isSaved: t,
|
|
194
194
|
close: p,
|
|
195
|
-
openApi:
|
|
196
|
-
saveApi:
|
|
195
|
+
openApi: u,
|
|
196
|
+
saveApi: h,
|
|
197
197
|
delayOptions: a,
|
|
198
|
-
saveConfig:
|
|
198
|
+
saveConfig: J,
|
|
199
199
|
OPEN_DELAY: se
|
|
200
200
|
};
|
|
201
201
|
}
|
|
@@ -204,40 +204,40 @@ const V = {
|
|
|
204
204
|
for (const [t, s] of e)
|
|
205
205
|
o[t] = s;
|
|
206
206
|
return o;
|
|
207
|
-
}, re = { class: "toolbar-save" },
|
|
207
|
+
}, re = { class: "toolbar-save" }, de = { class: "save-style" }, ue = { class: "save-time" }, me = { class: "save-button-group" };
|
|
208
208
|
function ve(a, e, o, t, s, l) {
|
|
209
|
-
const r = f("svg-icon"), i = f("tiny-checkbox"), n = f("tiny-select"), c = f("tiny-button"), p = f("tiny-popover"),
|
|
210
|
-
return
|
|
211
|
-
v(
|
|
209
|
+
const r = f("svg-icon"), i = f("tiny-checkbox"), n = f("tiny-select"), c = f("tiny-button"), p = f("tiny-popover"), u = f("vue-monaco"), h = f("tiny-dialog-box"), T = f("toolbar-base");
|
|
210
|
+
return E(), L("div", re, [
|
|
211
|
+
v(T, {
|
|
212
212
|
content: t.isLoading ? "保存中" : "保存",
|
|
213
213
|
icon: o.options.icon.default || o.options.icon,
|
|
214
214
|
options: { ...o.options, showDots: !t.isSaved() },
|
|
215
215
|
onClickApi: t.openApi
|
|
216
216
|
}, {
|
|
217
|
-
button:
|
|
217
|
+
button: d(() => [
|
|
218
218
|
v(p, {
|
|
219
219
|
"visible-arrow": !1,
|
|
220
220
|
width: "203",
|
|
221
221
|
trigger: "click",
|
|
222
222
|
"open-delay": t.OPEN_DELAY.Default
|
|
223
223
|
}, {
|
|
224
|
-
reference:
|
|
224
|
+
reference: d(() => [
|
|
225
225
|
v(r, { name: o.iconExpand }, null, 8, ["name"])
|
|
226
226
|
]),
|
|
227
|
-
default:
|
|
228
|
-
k("div",
|
|
227
|
+
default: d(() => [
|
|
228
|
+
k("div", de, [
|
|
229
229
|
e[6] || (e[6] = k("div", { class: "save-setting" }, "保存设置", -1)),
|
|
230
230
|
v(i, {
|
|
231
231
|
modelValue: t.state.checked,
|
|
232
232
|
"onUpdate:modelValue": e[0] || (e[0] = (m) => t.state.checked = m),
|
|
233
233
|
name: "tiny-checkbox"
|
|
234
234
|
}, {
|
|
235
|
-
default:
|
|
235
|
+
default: d(() => e[3] || (e[3] = [
|
|
236
236
|
S("自动保存")
|
|
237
237
|
])),
|
|
238
238
|
_: 1
|
|
239
239
|
}, 8, ["modelValue"]),
|
|
240
|
-
k("div",
|
|
240
|
+
k("div", ue, [
|
|
241
241
|
e[4] || (e[4] = k("div", { class: "save-time-label" }, "保存间隔", -1)),
|
|
242
242
|
v(n, {
|
|
243
243
|
modelValue: t.state.timeValue,
|
|
@@ -252,7 +252,7 @@ function ve(a, e, o, t, s, l) {
|
|
|
252
252
|
type: "primary",
|
|
253
253
|
onClick: t.saveConfig
|
|
254
254
|
}, {
|
|
255
|
-
default:
|
|
255
|
+
default: d(() => e[5] || (e[5] = [
|
|
256
256
|
S("设置并保存")
|
|
257
257
|
])),
|
|
258
258
|
_: 1
|
|
@@ -263,8 +263,8 @@ function ve(a, e, o, t, s, l) {
|
|
|
263
263
|
_: 1
|
|
264
264
|
}, 8, ["open-delay"])
|
|
265
265
|
]),
|
|
266
|
-
default:
|
|
267
|
-
v(
|
|
266
|
+
default: d(() => [
|
|
267
|
+
v(h, {
|
|
268
268
|
class: "dialog-box",
|
|
269
269
|
modal: !1,
|
|
270
270
|
fullscreen: !0,
|
|
@@ -273,9 +273,9 @@ function ve(a, e, o, t, s, l) {
|
|
|
273
273
|
title: "Schema 本地与线上差异",
|
|
274
274
|
"onUpdate:visible": e[2] || (e[2] = (m) => t.state.visible = m)
|
|
275
275
|
}, {
|
|
276
|
-
footer:
|
|
276
|
+
footer: d(() => [
|
|
277
277
|
v(c, { onClick: t.close }, {
|
|
278
|
-
default:
|
|
278
|
+
default: d(() => e[7] || (e[7] = [
|
|
279
279
|
S("取 消")
|
|
280
280
|
])),
|
|
281
281
|
_: 1
|
|
@@ -284,14 +284,14 @@ function ve(a, e, o, t, s, l) {
|
|
|
284
284
|
type: "primary",
|
|
285
285
|
onClick: t.saveApi
|
|
286
286
|
}, {
|
|
287
|
-
default:
|
|
287
|
+
default: d(() => e[8] || (e[8] = [
|
|
288
288
|
S("保 存")
|
|
289
289
|
])),
|
|
290
290
|
_: 1
|
|
291
291
|
}, 8, ["onClick"])
|
|
292
292
|
]),
|
|
293
|
-
default:
|
|
294
|
-
t.state.visible ? (
|
|
293
|
+
default: d(() => [
|
|
294
|
+
t.state.visible ? (E(), U(u, {
|
|
295
295
|
key: 0,
|
|
296
296
|
ref: "editor",
|
|
297
297
|
class: "monaco-editor",
|
|
@@ -299,7 +299,7 @@ function ve(a, e, o, t, s, l) {
|
|
|
299
299
|
options: t.editorOptions,
|
|
300
300
|
value: t.state.code,
|
|
301
301
|
original: t.state.originalCode
|
|
302
|
-
}, null, 8, ["options", "value", "original"])) :
|
|
302
|
+
}, null, 8, ["options", "value", "original"])) : I("", !0)
|
|
303
303
|
]),
|
|
304
304
|
_: 1
|
|
305
305
|
}, 8, ["visible"])
|
|
@@ -308,11 +308,11 @@ function ve(a, e, o, t, s, l) {
|
|
|
308
308
|
}, 8, ["content", "icon", "options", "onClickApi"])
|
|
309
309
|
]);
|
|
310
310
|
}
|
|
311
|
-
const pe = /* @__PURE__ */ ce(le, [["render", ve], ["__scopeId", "data-v-047f42c8"]]),
|
|
312
|
-
...
|
|
311
|
+
const pe = /* @__PURE__ */ ce(le, [["render", ve], ["__scopeId", "data-v-047f42c8"]]), Ce = {
|
|
312
|
+
...w,
|
|
313
313
|
entry: pe,
|
|
314
314
|
apis: ie
|
|
315
315
|
};
|
|
316
316
|
export {
|
|
317
|
-
|
|
317
|
+
Ce as default
|
|
318
318
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
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.4.
|
|
29
|
-
"@opentiny/tiny-engine-meta-register": "2.4.
|
|
30
|
-
"@opentiny/tiny-engine-utils": "2.4.
|
|
28
|
+
"@opentiny/tiny-engine-common": "2.4.2",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.4.2",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.4.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.4.
|
|
33
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.4.2",
|
|
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.20.0",
|
|
40
40
|
"vue": "^3.4.15"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3c5679965e80e59a8083fe629086e42b7b5dde36"
|
|
43
43
|
}
|