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