@opentiny/tiny-engine-toolbar-save 1.0.3 → 2.0.0-alpha.1
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 +181 -113
- package/dist/style.css +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,171 +1,236 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import { reactive as
|
|
3
|
-
import { VueMonaco as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { useCanvas as
|
|
6
|
-
import { theme as I } from "@opentiny/tiny-engine-controller/adapter";
|
|
7
|
-
import { setSchema as q, selectNode as H, getSchema as K } from "@opentiny/tiny-engine-canvas";
|
|
2
|
+
import { reactive as V, ref as T, onUnmounted as A, resolveComponent as p, openBlock as C, createElementBlock as w, Fragment as E, createElementVNode as v, createVNode as i, withCtx as l, toDisplayString as N, withModifiers as M, createTextVNode as b, createBlock as U, createCommentVNode as D } from "vue";
|
|
3
|
+
import { VueMonaco as L } from "@opentiny/tiny-engine-common";
|
|
4
|
+
import { Button as O, Popover as G, DialogBox as R, Checkbox as h, Select as J } from "@opentiny/vue";
|
|
5
|
+
import { usePage as j, useCanvas as y, useLayout as F, useNotify as q, getMetaApi as z, META_APP as H, useBlock as K } from "@opentiny/tiny-engine-meta-register";
|
|
8
6
|
import { constants as Q } from "@opentiny/tiny-engine-utils";
|
|
9
7
|
import { handlePageUpdate as W } from "@opentiny/tiny-engine-common/js/http";
|
|
10
|
-
const {
|
|
8
|
+
const { PAGE_STATUS: u } = Q, g = V({
|
|
11
9
|
visible: !1,
|
|
12
10
|
code: "",
|
|
13
11
|
originalCode: "",
|
|
14
12
|
disabled: !1
|
|
15
|
-
}),
|
|
16
|
-
var
|
|
17
|
-
const e =
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
const { currentPage: e } =
|
|
21
|
-
page_content:
|
|
13
|
+
}), _ = T(!1), X = async (a) => {
|
|
14
|
+
var n;
|
|
15
|
+
const e = z(H.BlockManage), { getCurrentBlock: o } = K(), t = o();
|
|
16
|
+
t.label = a.fileName, t.content = a, _.value = !0, t.screenshot = await e.getBlockBase64(), await ((n = e.saveBlock) == null ? void 0 : n.call(e, t)), _.value = !1;
|
|
17
|
+
}, Y = async (a) => {
|
|
18
|
+
const { currentPage: e } = y().pageState, o = {
|
|
19
|
+
page_content: a
|
|
22
20
|
};
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
const e = JSON.parse(n
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return
|
|
21
|
+
_.value = !0, await W(e.id, { ...e, ...o }), _.value = !1;
|
|
22
|
+
}, k = (a) => {
|
|
23
|
+
const { pageSettingState: e, isTemporaryPage: o } = j(), { isBlock: t, canvasApi: n, pageState: f } = y(), s = JSON.parse(a), { setSchema: r, selectNode: d } = n.value;
|
|
24
|
+
if (f.pageSchema = s, r(s), e != null && e.isAIPage) {
|
|
25
|
+
o.saved && (o.saved = !1), o.saved = !0;
|
|
26
|
+
const c = "page_content";
|
|
27
|
+
return e.currentPageData[c] = s, Promise.resolve();
|
|
30
28
|
}
|
|
31
|
-
return
|
|
29
|
+
return d(null), t() ? X(s) : Y(s);
|
|
32
30
|
}, x = async () => {
|
|
33
|
-
var
|
|
34
|
-
|
|
31
|
+
var d;
|
|
32
|
+
const { isSaved: a, canvasApi: e } = y();
|
|
33
|
+
if (a() || g.disabled)
|
|
35
34
|
return;
|
|
36
|
-
const
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
35
|
+
const o = (d = F().layoutState) == null ? void 0 : d.pageStatus, t = o == null ? void 0 : o.state, n = o == null ? void 0 : o.data, { getSchema: f } = e.value, s = {
|
|
36
|
+
[u.Release]: "当前页面未锁定,请先锁定再保存",
|
|
37
|
+
[u.Empty]: "当前应用无页面,请先新建页面再保存",
|
|
38
|
+
[u.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
|
|
39
|
+
[u.Lock]: `当前页面被 ${n == null ? void 0 : n.username} ${n == null ? void 0 : n.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
|
|
41
40
|
};
|
|
42
|
-
if ([
|
|
43
|
-
|
|
41
|
+
if ([u.Release, u.Empty, u.Guest, u.Lock].includes(t)) {
|
|
42
|
+
q({
|
|
44
43
|
type: "error",
|
|
45
44
|
title: "保存失败",
|
|
46
|
-
message: t
|
|
45
|
+
message: s[t]
|
|
47
46
|
});
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
g.disabled = !0;
|
|
50
|
+
const r = f();
|
|
51
|
+
g.code = JSON.stringify(r || {}, null, 2), k(g.code).finally(() => {
|
|
52
|
+
g.disabled = !1;
|
|
54
53
|
});
|
|
55
54
|
};
|
|
56
|
-
const
|
|
57
|
-
const o =
|
|
58
|
-
for (const [t,
|
|
59
|
-
o[t] =
|
|
55
|
+
const Z = (a, e) => {
|
|
56
|
+
const o = a.__vccOpts || a;
|
|
57
|
+
for (const [t, n] of e)
|
|
58
|
+
o[t] = n;
|
|
60
59
|
return o;
|
|
61
|
-
},
|
|
62
|
-
saveCommon:
|
|
60
|
+
}, I = {
|
|
61
|
+
saveCommon: k,
|
|
63
62
|
openCommon: x
|
|
64
|
-
},
|
|
63
|
+
}, $ = {
|
|
65
64
|
components: {
|
|
66
|
-
VueMonaco:
|
|
67
|
-
TinyButton:
|
|
68
|
-
TinyPopover:
|
|
69
|
-
TinyDialogBox:
|
|
65
|
+
VueMonaco: L,
|
|
66
|
+
TinyButton: O,
|
|
67
|
+
TinyPopover: G,
|
|
68
|
+
TinyDialogBox: R,
|
|
69
|
+
TinyCheckbox: h,
|
|
70
|
+
TinySelect: J
|
|
70
71
|
},
|
|
71
72
|
props: {
|
|
72
73
|
icon: {
|
|
73
74
|
type: String,
|
|
74
75
|
default: "save"
|
|
76
|
+
},
|
|
77
|
+
iconExpand: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: "down-arrow"
|
|
75
80
|
}
|
|
76
81
|
},
|
|
77
82
|
setup() {
|
|
78
|
-
const
|
|
83
|
+
const a = [
|
|
84
|
+
{ value: 5, label: "5分钟" },
|
|
85
|
+
{ value: 10, label: "10分钟" },
|
|
86
|
+
{ value: 15, label: "15分钟" }
|
|
87
|
+
], e = V({
|
|
79
88
|
visible: !1,
|
|
80
89
|
code: "",
|
|
81
90
|
originalCode: "",
|
|
82
91
|
disabled: !1,
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
timeValue: 5,
|
|
93
|
+
saveVisible: !1,
|
|
94
|
+
checked: !1,
|
|
95
|
+
preservationTime: null
|
|
96
|
+
}), o = T(null), t = () => {
|
|
85
97
|
e.visible = !1, e.originalCode = "";
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
theme: I(),
|
|
92
|
-
tabSize: 2,
|
|
98
|
+
}, n = () => {
|
|
99
|
+
_.value || x();
|
|
100
|
+
}, f = () => {
|
|
101
|
+
k();
|
|
102
|
+
}, s = {
|
|
93
103
|
language: "json",
|
|
94
|
-
autoIndent: !0,
|
|
95
104
|
lineNumbers: !0,
|
|
96
|
-
formatOnPaste: !0,
|
|
97
|
-
automaticLayout: !0,
|
|
98
|
-
roundedSelection: !0,
|
|
99
105
|
minimap: {
|
|
100
106
|
enabled: !1
|
|
101
107
|
}
|
|
108
|
+
}, r = () => {
|
|
109
|
+
clearTimeout(e.preservationTime), e.preservationTime = setTimeout(() => {
|
|
110
|
+
n(), r();
|
|
111
|
+
}, e.timeValue * 60 * 1e3);
|
|
112
|
+
}, d = () => {
|
|
113
|
+
e.checked ? r() : clearTimeout(e.preservationTime), e.saveVisible = !1;
|
|
114
|
+
}, c = () => {
|
|
115
|
+
e.saveVisible = !1;
|
|
102
116
|
};
|
|
103
|
-
return
|
|
104
|
-
clearTimeout(e.
|
|
117
|
+
return A(() => {
|
|
118
|
+
clearTimeout(e.preservationTime);
|
|
105
119
|
}), {
|
|
106
120
|
state: e,
|
|
107
121
|
editor: o,
|
|
108
|
-
editorOptions:
|
|
109
|
-
isLoading:
|
|
122
|
+
editorOptions: s,
|
|
123
|
+
isLoading: _,
|
|
110
124
|
close: t,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
openApi: n,
|
|
126
|
+
saveApi: f,
|
|
127
|
+
options: a,
|
|
128
|
+
cancel: c,
|
|
129
|
+
autoSave: d
|
|
114
130
|
};
|
|
115
131
|
}
|
|
116
|
-
},
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
}, ee = { class: "toolbar-save" }, te = { class: "save-title" }, oe = { class: "save-style" }, ne = { class: "save-time" }, ae = { class: "save-button-group" };
|
|
133
|
+
function se(a, e, o, t, n, f) {
|
|
134
|
+
const s = p("svg-icon"), r = p("tiny-checkbox"), d = p("tiny-select"), c = p("tiny-button"), S = p("tiny-popover"), B = p("vue-monaco"), P = p("tiny-dialog-box");
|
|
135
|
+
return C(), w(E, null, [
|
|
136
|
+
v("div", ee, [
|
|
137
|
+
i(c, {
|
|
138
|
+
class: "save-button",
|
|
139
|
+
onClick: t.openApi
|
|
140
|
+
}, {
|
|
141
|
+
default: l(() => [
|
|
142
|
+
i(s, { name: o.icon }, null, 8, ["name"]),
|
|
143
|
+
v("span", te, N(t.isLoading ? "保存中" : "保存"), 1),
|
|
144
|
+
v("span", {
|
|
145
|
+
onClick: e[3] || (e[3] = M((m) => t.state.saveVisible = !t.state.saveVisible, ["stop"]))
|
|
146
|
+
}, [
|
|
147
|
+
i(S, {
|
|
148
|
+
modelValue: t.state.saveVisible,
|
|
149
|
+
"onUpdate:modelValue": e[2] || (e[2] = (m) => t.state.saveVisible = m),
|
|
150
|
+
"visible-arrow": !1,
|
|
151
|
+
width: "203",
|
|
152
|
+
trigger: "manual"
|
|
153
|
+
}, {
|
|
154
|
+
reference: l(() => [
|
|
155
|
+
i(s, { name: o.iconExpand }, null, 8, ["name"])
|
|
156
|
+
]),
|
|
157
|
+
default: l(() => [
|
|
158
|
+
v("div", oe, [
|
|
159
|
+
e[9] || (e[9] = v("div", { class: "save-setting" }, "保存设置", -1)),
|
|
160
|
+
i(r, {
|
|
161
|
+
modelValue: t.state.checked,
|
|
162
|
+
"onUpdate:modelValue": e[0] || (e[0] = (m) => t.state.checked = m),
|
|
163
|
+
name: "tiny-checkbox"
|
|
164
|
+
}, {
|
|
165
|
+
default: l(() => e[5] || (e[5] = [
|
|
166
|
+
b("自动保存")
|
|
167
|
+
])),
|
|
168
|
+
_: 1
|
|
169
|
+
}, 8, ["modelValue"]),
|
|
170
|
+
v("div", ne, [
|
|
171
|
+
e[6] || (e[6] = v("div", null, "保存间隔", -1)),
|
|
172
|
+
i(d, {
|
|
173
|
+
modelValue: t.state.timeValue,
|
|
174
|
+
"onUpdate:modelValue": e[1] || (e[1] = (m) => t.state.timeValue = m),
|
|
175
|
+
options: t.options,
|
|
176
|
+
disabled: !t.state.checked,
|
|
177
|
+
autocomplete: ""
|
|
178
|
+
}, null, 8, ["modelValue", "options", "disabled"])
|
|
179
|
+
]),
|
|
180
|
+
v("div", ae, [
|
|
181
|
+
i(c, { onClick: t.cancel }, {
|
|
182
|
+
default: l(() => e[7] || (e[7] = [
|
|
183
|
+
b("取消")
|
|
184
|
+
])),
|
|
185
|
+
_: 1
|
|
186
|
+
}, 8, ["onClick"]),
|
|
187
|
+
i(c, {
|
|
188
|
+
type: "primary",
|
|
189
|
+
onClick: t.autoSave
|
|
190
|
+
}, {
|
|
191
|
+
default: l(() => e[8] || (e[8] = [
|
|
192
|
+
b("设置并保存")
|
|
193
|
+
])),
|
|
194
|
+
_: 1
|
|
195
|
+
}, 8, ["onClick"])
|
|
196
|
+
])
|
|
197
|
+
])
|
|
198
|
+
]),
|
|
199
|
+
_: 1
|
|
200
|
+
}, 8, ["modelValue"])
|
|
201
|
+
])
|
|
202
|
+
]),
|
|
203
|
+
_: 1
|
|
204
|
+
}, 8, ["onClick"])
|
|
205
|
+
]),
|
|
206
|
+
i(P, {
|
|
142
207
|
class: "dialog-box",
|
|
143
208
|
modal: !1,
|
|
144
209
|
fullscreen: !0,
|
|
145
210
|
"append-to-body": !0,
|
|
146
211
|
visible: t.state.visible,
|
|
147
212
|
title: "Schema 本地与线上差异",
|
|
148
|
-
"onUpdate:visible": e[
|
|
213
|
+
"onUpdate:visible": e[4] || (e[4] = (m) => t.state.visible = m)
|
|
149
214
|
}, {
|
|
150
|
-
footer:
|
|
151
|
-
|
|
152
|
-
default:
|
|
153
|
-
|
|
154
|
-
]),
|
|
215
|
+
footer: l(() => [
|
|
216
|
+
i(c, { onClick: t.close }, {
|
|
217
|
+
default: l(() => e[10] || (e[10] = [
|
|
218
|
+
b("取 消")
|
|
219
|
+
])),
|
|
155
220
|
_: 1
|
|
156
221
|
}, 8, ["onClick"]),
|
|
157
|
-
|
|
222
|
+
i(c, {
|
|
158
223
|
type: "primary",
|
|
159
224
|
onClick: t.saveApi
|
|
160
225
|
}, {
|
|
161
|
-
default:
|
|
162
|
-
|
|
163
|
-
]),
|
|
226
|
+
default: l(() => e[11] || (e[11] = [
|
|
227
|
+
b("保 存")
|
|
228
|
+
])),
|
|
164
229
|
_: 1
|
|
165
230
|
}, 8, ["onClick"])
|
|
166
231
|
]),
|
|
167
|
-
default:
|
|
168
|
-
t.state.visible ? (
|
|
232
|
+
default: l(() => [
|
|
233
|
+
t.state.visible ? (C(), U(B, {
|
|
169
234
|
key: 0,
|
|
170
235
|
ref: "editor",
|
|
171
236
|
class: "monaco-editor",
|
|
@@ -173,20 +238,23 @@ function re(n, e, o, t, s, c) {
|
|
|
173
238
|
options: t.editorOptions,
|
|
174
239
|
value: t.state.code,
|
|
175
240
|
original: t.state.originalCode
|
|
176
|
-
}, null, 8, ["options", "value", "original"])) :
|
|
241
|
+
}, null, 8, ["options", "value", "original"])) : D("", !0)
|
|
177
242
|
]),
|
|
178
243
|
_: 1
|
|
179
244
|
}, 8, ["visible"])
|
|
180
245
|
], 64);
|
|
181
246
|
}
|
|
182
|
-
const
|
|
183
|
-
id: "save",
|
|
247
|
+
const ie = /* @__PURE__ */ Z($, [["render", se], ["__scopeId", "data-v-159e4497"]]), le = {
|
|
248
|
+
id: "engine.toolbars.save",
|
|
249
|
+
type: "toolbars",
|
|
184
250
|
title: "save",
|
|
185
251
|
icon: "",
|
|
186
|
-
align: "right"
|
|
187
|
-
|
|
188
|
-
|
|
252
|
+
align: "right"
|
|
253
|
+
}, fe = {
|
|
254
|
+
...le,
|
|
255
|
+
entry: ie,
|
|
256
|
+
apis: I
|
|
189
257
|
};
|
|
190
258
|
export {
|
|
191
|
-
|
|
259
|
+
fe as default
|
|
192
260
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.dots[data-v-
|
|
1
|
+
.dots[data-v-159e4497]{width:6px;height:6px;background:var(--ti-lowcode-toolbar-dot-color);border-radius:50%;display:inline-block;position:absolute;top:4px;right:3px;z-index:100}.toolbar-save .save-button[data-v-159e4497]{background-color:var(--ti-lowcode-toolbar-button-bg);border:none;min-width:70px;height:26px;display:flex;align-items:center;padding:0 8px;border-radius:4px}.toolbar-save .save-button[data-v-159e4497]:not(.disabled):hover{background-color:var(--ti-lowcode-toolbar-button-bg)}.toolbar-save .save-button .save-title[data-v-159e4497]{margin:0 6px}.toolbar-save[data-v-159e4497] .icon-down-arrow:focus{outline:none}.save-style[data-v-159e4497]{padding:14px;font-size:12px}.save-style .save-button-group[data-v-159e4497]{text-align:right}.save-style .save-button-group[data-v-159e4497] .tiny-button{min-width:40px;padding:0 8px;height:26px;line-height:24px;border-radius:4px}.save-time[data-v-159e4497]{line-height:24px;font-size:12px;margin:13px 0 14px;display:flex}.save-time .tiny-select[data-v-159e4497]{width:103px;margin-left:12px}.save-time .tiny-select[data-v-159e4497] .tiny-input__suffix{width:12px;top:12px}#saving[data-v-159e4497]{cursor:not-allowed;color:var(--ti-lowcode-disabled-color)}#saving[data-v-159e4497] svg{color:var(--ti-lowcode-disabled-color)}.dialog-box[data-v-159e4497] .tiny-dialog-box{display:flex;flex-direction:column}.dialog-box[data-v-159e4497] .tiny-dialog-box .tiny-dialog-box__body{flex:1}.dialog-box .monaco-editor[data-v-159e4497]{width:100%;height:100%}.changeRole a{color:var(--ti-lowcode-canvas-handle-hover-bg);padding:0 5px}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"homepage": "https://opentiny.design/tiny-engine",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@opentiny/tiny-engine-
|
|
28
|
-
"@opentiny/tiny-engine-
|
|
29
|
-
"@opentiny/tiny-engine-
|
|
30
|
-
"@opentiny/tiny-engine-utils": "1.0.4",
|
|
31
|
-
"@opentiny/vue": "~3.10.0"
|
|
27
|
+
"@opentiny/tiny-engine-common": "2.0.0-alpha.1",
|
|
28
|
+
"@opentiny/tiny-engine-meta-register": "2.0.0-alpha.1",
|
|
29
|
+
"@opentiny/tiny-engine-utils": "2.0.0-alpha.1"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
32
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.0.0-alpha.1",
|
|
34
33
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
35
|
-
"@vitejs/plugin-vue-jsx": "^1.
|
|
34
|
+
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
36
35
|
"vite": "^4.3.7"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
38
|
+
"@opentiny/vue": "^3.14.0",
|
|
39
39
|
"vue": "^3.4.15"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "f15ccc5dde391288bf4297e3ffc35aab52651f3d"
|
|
42
42
|
}
|