@opentiny/tiny-engine-toolbar-save 2.5.0-rc.3 → 2.5.0-rc.5
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 +99 -99
- 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 {
|
|
6
|
-
import { constants as
|
|
2
|
+
import { reactive as N, ref as B, onMounted as P, onUnmounted as x, resolveComponent as f, createElementBlock as U, openBlock as E, createVNode as p, withCtx as d, createBlock as I, createCommentVNode as G, createTextVNode as S, createElementVNode as k } from "vue";
|
|
3
|
+
import { ToolbarBase as R, VueMonaco as j } from "@opentiny/tiny-engine-common";
|
|
4
|
+
import { Select as Y, Checkbox as q, DialogBox as z, Popover as F, Button as H } from "@opentiny/vue";
|
|
5
|
+
import { useMessage as V, useCanvas as C, getOptions as K, useNotify as A, useLayout as Q, usePage as W, getMetaApi as X, META_APP as Z, useBlock as $ } from "@opentiny/tiny-engine-meta-register";
|
|
6
|
+
import { constants as w } from "@opentiny/tiny-engine-utils";
|
|
7
7
|
import { handlePageUpdate as ee } from "@opentiny/tiny-engine-common/js/http";
|
|
8
|
-
const
|
|
8
|
+
const D = {
|
|
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
|
+
}, { publish: te } = V(), { PAGE_STATUS: g, AUTO_SAVED: M } = w, _ = N({
|
|
19
19
|
visible: !1,
|
|
20
20
|
code: "",
|
|
21
21
|
originalCode: "",
|
|
22
22
|
disabled: !1
|
|
23
|
-
}), b =
|
|
23
|
+
}), b = B(!1), oe = async (a) => {
|
|
24
24
|
var s;
|
|
25
|
-
const e =
|
|
25
|
+
const e = X(Z.BlockManage), { getCurrentBlock: o } = $(), 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
|
-
},
|
|
28
|
-
const { currentPage: e } =
|
|
27
|
+
}, ae = async (a) => {
|
|
28
|
+
const { currentPage: e } = C().pageState, o = {
|
|
29
29
|
page_content: a
|
|
30
30
|
};
|
|
31
31
|
b.value = !0;
|
|
@@ -33,38 +33,38 @@ const V = {
|
|
|
33
33
|
id: e.id,
|
|
34
34
|
params: { ...e, ...o }
|
|
35
35
|
};
|
|
36
|
-
await ee(t), b.value = !1;
|
|
37
|
-
},
|
|
38
|
-
const { pageSettingState: e, isTemporaryPage: o } =
|
|
36
|
+
await ee(t), b.value = !1, te({ topic: "page-saved" });
|
|
37
|
+
}, O = (a) => {
|
|
38
|
+
const { pageSettingState: e, isTemporaryPage: o } = W(), { 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
|
-
const
|
|
42
|
-
return e.currentPageData[
|
|
41
|
+
const v = "page_content";
|
|
42
|
+
return e.currentPageData[v] = n, Promise.resolve();
|
|
43
43
|
}
|
|
44
|
-
return c(null), t() ?
|
|
45
|
-
},
|
|
46
|
-
var
|
|
47
|
-
const { isSaved: a, getSchema: e } =
|
|
44
|
+
return c(null), t() ? oe(n) : ae(n);
|
|
45
|
+
}, J = async () => {
|
|
46
|
+
var v;
|
|
47
|
+
const { isSaved: a, getSchema: e } = C();
|
|
48
48
|
if (a() || _.disabled)
|
|
49
49
|
return;
|
|
50
|
-
const { beforeSave: o, saveMethod: t, saved: s } =
|
|
50
|
+
const { beforeSave: o, saveMethod: t, saved: s } = K(D.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
|
-
const l = (
|
|
60
|
+
const l = (v = Q().layoutState) == null ? void 0 : v.pageStatus, r = l == null ? void 0 : l.state, i = l == null ? void 0 : l.data, n = {
|
|
61
61
|
[g.Release]: "当前页面未锁定,请先锁定再保存",
|
|
62
62
|
[g.Empty]: "当前应用无页面,请先新建页面再保存",
|
|
63
63
|
[g.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
|
|
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
|
+
}, ne = () => {
|
|
88
88
|
try {
|
|
89
|
-
const a = localStorage.getItem(
|
|
89
|
+
const a = localStorage.getItem(M) ?? "";
|
|
90
90
|
return JSON.parse(a) ?? !1;
|
|
91
91
|
} catch {
|
|
92
92
|
return !1;
|
|
93
93
|
}
|
|
94
|
-
},
|
|
94
|
+
}, se = (a) => {
|
|
95
95
|
try {
|
|
96
|
-
return localStorage.setItem(
|
|
96
|
+
return localStorage.setItem(M, JSON.stringify(a)), !0;
|
|
97
97
|
} catch {
|
|
98
98
|
return !1;
|
|
99
99
|
}
|
|
100
|
-
}, { OPEN_DELAY:
|
|
101
|
-
saveCommon:
|
|
102
|
-
openCommon:
|
|
103
|
-
},
|
|
100
|
+
}, { OPEN_DELAY: ie } = w, le = {
|
|
101
|
+
saveCommon: O,
|
|
102
|
+
openCommon: J
|
|
103
|
+
}, ce = {
|
|
104
104
|
components: {
|
|
105
|
-
VueMonaco:
|
|
106
|
-
TinyButton:
|
|
107
|
-
TinyPopover:
|
|
108
|
-
TinyDialogBox:
|
|
109
|
-
TinyCheckbox:
|
|
110
|
-
TinySelect:
|
|
111
|
-
ToolbarBase:
|
|
105
|
+
VueMonaco: j,
|
|
106
|
+
TinyButton: H,
|
|
107
|
+
TinyPopover: F,
|
|
108
|
+
TinyDialogBox: z,
|
|
109
|
+
TinyCheckbox: q,
|
|
110
|
+
TinySelect: Y,
|
|
111
|
+
ToolbarBase: R
|
|
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 } = V(), 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
|
-
const
|
|
165
|
+
const v = () => {
|
|
166
166
|
e.visible = !1, e.originalCode = "";
|
|
167
|
-
},
|
|
168
|
-
b.value ||
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
},
|
|
167
|
+
}, u = () => {
|
|
168
|
+
b.value || J();
|
|
169
|
+
}, h = () => {
|
|
170
|
+
O();
|
|
171
|
+
}, T = {
|
|
172
172
|
language: "json",
|
|
173
173
|
lineNumbers: !0,
|
|
174
174
|
minimap: {
|
|
@@ -176,70 +176,70 @@ 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
|
-
},
|
|
182
|
-
|
|
181
|
+
}, L = () => {
|
|
182
|
+
se(e.checked), e.checked ? m() : clearTimeout(e.preservationTime);
|
|
183
183
|
};
|
|
184
|
-
return
|
|
185
|
-
e.checked =
|
|
186
|
-
}),
|
|
184
|
+
return P(() => {
|
|
185
|
+
e.checked = ne(), e.checked && m();
|
|
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
|
-
close:
|
|
195
|
-
openApi:
|
|
196
|
-
saveApi:
|
|
194
|
+
close: v,
|
|
195
|
+
openApi: u,
|
|
196
|
+
saveApi: h,
|
|
197
197
|
delayOptions: a,
|
|
198
|
-
saveConfig:
|
|
199
|
-
OPEN_DELAY:
|
|
198
|
+
saveConfig: L,
|
|
199
|
+
OPEN_DELAY: ie
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
},
|
|
202
|
+
}, re = (a, e) => {
|
|
203
203
|
const o = a.__vccOpts || a;
|
|
204
204
|
for (const [t, s] of e)
|
|
205
205
|
o[t] = s;
|
|
206
206
|
return o;
|
|
207
|
-
},
|
|
207
|
+
}, de = { class: "toolbar-save" }, ue = { class: "save-style" }, me = { class: "save-time" }, pe = { 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"),
|
|
210
|
-
return
|
|
211
|
-
|
|
209
|
+
const r = f("svg-icon"), i = f("tiny-checkbox"), n = f("tiny-select"), c = f("tiny-button"), v = f("tiny-popover"), u = f("vue-monaco"), h = f("tiny-dialog-box"), T = f("toolbar-base");
|
|
210
|
+
return E(), U("div", de, [
|
|
211
|
+
p(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:
|
|
218
|
-
v
|
|
217
|
+
button: d(() => [
|
|
218
|
+
p(v, {
|
|
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:
|
|
225
|
-
|
|
224
|
+
reference: d(() => [
|
|
225
|
+
p(r, { name: o.iconExpand }, null, 8, ["name"])
|
|
226
226
|
]),
|
|
227
|
-
default:
|
|
227
|
+
default: d(() => [
|
|
228
228
|
k("div", ue, [
|
|
229
229
|
e[6] || (e[6] = k("div", { class: "save-setting" }, "保存设置", -1)),
|
|
230
|
-
|
|
230
|
+
p(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", me, [
|
|
241
241
|
e[4] || (e[4] = k("div", { class: "save-time-label" }, "保存间隔", -1)),
|
|
242
|
-
|
|
242
|
+
p(n, {
|
|
243
243
|
modelValue: t.state.timeValue,
|
|
244
244
|
"onUpdate:modelValue": e[1] || (e[1] = (m) => t.state.timeValue = m),
|
|
245
245
|
options: t.delayOptions,
|
|
@@ -247,12 +247,12 @@ function ve(a, e, o, t, s, l) {
|
|
|
247
247
|
autocomplete: ""
|
|
248
248
|
}, null, 8, ["modelValue", "options", "disabled"])
|
|
249
249
|
]),
|
|
250
|
-
k("div",
|
|
251
|
-
|
|
250
|
+
k("div", pe, [
|
|
251
|
+
p(c, {
|
|
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
|
-
|
|
266
|
+
default: d(() => [
|
|
267
|
+
p(h, {
|
|
268
268
|
class: "dialog-box",
|
|
269
269
|
modal: !1,
|
|
270
270
|
fullscreen: !0,
|
|
@@ -273,25 +273,25 @@ 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:
|
|
277
|
-
|
|
278
|
-
default:
|
|
276
|
+
footer: d(() => [
|
|
277
|
+
p(c, { onClick: t.close }, {
|
|
278
|
+
default: d(() => e[7] || (e[7] = [
|
|
279
279
|
S("取 消")
|
|
280
280
|
])),
|
|
281
281
|
_: 1
|
|
282
282
|
}, 8, ["onClick"]),
|
|
283
|
-
|
|
283
|
+
p(c, {
|
|
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(), I(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"])) : G("", !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
|
|
312
|
-
...
|
|
313
|
-
entry:
|
|
314
|
-
apis:
|
|
311
|
+
const fe = /* @__PURE__ */ re(ce, [["render", ve], ["__scopeId", "data-v-047f42c8"]]), he = {
|
|
312
|
+
...D,
|
|
313
|
+
entry: fe,
|
|
314
|
+
apis: le
|
|
315
315
|
};
|
|
316
316
|
export {
|
|
317
|
-
|
|
317
|
+
he 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.5.0-rc.
|
|
3
|
+
"version": "2.5.0-rc.5",
|
|
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.5.0-rc.
|
|
29
|
-
"@opentiny/tiny-engine-meta-register": "2.5.0-rc.
|
|
30
|
-
"@opentiny/tiny-engine-utils": "2.5.0-rc.
|
|
28
|
+
"@opentiny/tiny-engine-common": "2.5.0-rc.5",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.5.0-rc.5",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.5.0-rc.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.5.0-rc.
|
|
33
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.5.0-rc.5",
|
|
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": "700103ccd438a1973ed2ac85639a13b91d3a9981"
|
|
43
43
|
}
|