@opentiny/tiny-engine-toolbar-save 2.5.0-rc.4 → 2.5.0-rc.6
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 +65 -65
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import { reactive as N, ref as B, onMounted as P, onUnmounted as x, resolveComponent as f, createElementBlock as
|
|
3
|
-
import { ToolbarBase as
|
|
4
|
-
import { Select as
|
|
5
|
-
import { useCanvas as C, getOptions as
|
|
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,16 +15,16 @@ const w = {
|
|
|
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 = B(!1),
|
|
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
|
-
},
|
|
27
|
+
}, ae = async (a) => {
|
|
28
28
|
const { currentPage: e } = C().pageState, o = {
|
|
29
29
|
page_content: a
|
|
30
30
|
};
|
|
@@ -33,21 +33,21 @@ const w = {
|
|
|
33
33
|
id: e.id,
|
|
34
34
|
params: { ...e, ...o }
|
|
35
35
|
};
|
|
36
|
-
await ee(t), b.value = !1;
|
|
36
|
+
await ee(t), b.value = !1, te({ topic: "page-saved" });
|
|
37
37
|
}, O = (a) => {
|
|
38
|
-
const { pageSettingState: e, isTemporaryPage: o } =
|
|
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
|
|
44
|
+
return c(null), t() ? oe(n) : ae(n);
|
|
45
|
+
}, J = async () => {
|
|
46
|
+
var v;
|
|
47
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;
|
|
@@ -57,7 +57,7 @@ const w = {
|
|
|
57
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]: "官网演示应用不能保存页面,如需体验请切换应用",
|
|
@@ -84,31 +84,31 @@ const w = {
|
|
|
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:
|
|
100
|
+
}, { OPEN_DELAY: ie } = w, le = {
|
|
101
101
|
saveCommon: O,
|
|
102
|
-
openCommon:
|
|
103
|
-
},
|
|
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: {
|
|
@@ -132,7 +132,7 @@ const w = {
|
|
|
132
132
|
checked: !1,
|
|
133
133
|
timeValue: 5,
|
|
134
134
|
preservationTime: null
|
|
135
|
-
}), o = B(null), { isSaved: t, setSaved: s, getSchema: l } = C(), { subscribe: r, unsubscribe: i } =
|
|
135
|
+
}), o = B(null), { isSaved: t, setSaved: s, getSchema: l } = C(), { subscribe: r, unsubscribe: i } = V(), n = "toolbar-save", c = B(null);
|
|
136
136
|
P(() => {
|
|
137
137
|
r({
|
|
138
138
|
topic: "pageOrBlockInit",
|
|
@@ -162,10 +162,10 @@ const w = {
|
|
|
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
167
|
}, u = () => {
|
|
168
|
-
b.value ||
|
|
168
|
+
b.value || J();
|
|
169
169
|
}, h = () => {
|
|
170
170
|
O();
|
|
171
171
|
}, T = {
|
|
@@ -178,11 +178,11 @@ const w = {
|
|
|
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
184
|
return P(() => {
|
|
185
|
-
e.checked =
|
|
185
|
+
e.checked = ne(), e.checked && m();
|
|
186
186
|
}), x(() => {
|
|
187
187
|
clearTimeout(e.preservationTime);
|
|
188
188
|
}), {
|
|
@@ -191,43 +191,43 @@ const w = {
|
|
|
191
191
|
editorOptions: T,
|
|
192
192
|
isLoading: b,
|
|
193
193
|
isSaved: t,
|
|
194
|
-
close:
|
|
194
|
+
close: v,
|
|
195
195
|
openApi: u,
|
|
196
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 E(),
|
|
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
217
|
button: d(() => [
|
|
218
|
-
v
|
|
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
224
|
reference: d(() => [
|
|
225
|
-
|
|
225
|
+
p(r, { name: o.iconExpand }, null, 8, ["name"])
|
|
226
226
|
]),
|
|
227
227
|
default: d(() => [
|
|
228
|
-
k("div",
|
|
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"
|
|
@@ -237,9 +237,9 @@ function ve(a, e, o, t, s, l) {
|
|
|
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,8 +247,8 @@ 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
|
}, {
|
|
@@ -264,7 +264,7 @@ function ve(a, e, o, t, s, l) {
|
|
|
264
264
|
}, 8, ["open-delay"])
|
|
265
265
|
]),
|
|
266
266
|
default: d(() => [
|
|
267
|
-
|
|
267
|
+
p(h, {
|
|
268
268
|
class: "dialog-box",
|
|
269
269
|
modal: !1,
|
|
270
270
|
fullscreen: !0,
|
|
@@ -274,13 +274,13 @@ function ve(a, e, o, t, s, l) {
|
|
|
274
274
|
"onUpdate:visible": e[2] || (e[2] = (m) => t.state.visible = m)
|
|
275
275
|
}, {
|
|
276
276
|
footer: d(() => [
|
|
277
|
-
|
|
277
|
+
p(c, { onClick: t.close }, {
|
|
278
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
|
}, {
|
|
@@ -291,7 +291,7 @@ function ve(a, e, o, t, s, l) {
|
|
|
291
291
|
}, 8, ["onClick"])
|
|
292
292
|
]),
|
|
293
293
|
default: d(() => [
|
|
294
|
-
t.state.visible ? (E(),
|
|
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.6",
|
|
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.6",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.5.0-rc.6",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.5.0-rc.6"
|
|
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.6",
|
|
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": "5989f69d75c8175c6b6bacc627c4eef975be1c50"
|
|
43
43
|
}
|