@opentiny/tiny-engine-toolbar-save 1.0.4-alpha.0 → 1.0.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 +90 -91
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import { reactive as C, ref as B, onBeforeMount as
|
|
3
|
-
import { VueMonaco as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { useCanvas as P, useLayout as S, useBlock as
|
|
6
|
-
import { theme as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const { pageState: h, isSaved: X, isBlock: Y } = P(), { PLUGIN_NAME: Z, getPluginApi: $ } = S(), { getCurrentBlock: ee } = j(), { PAGE_STATUS: a } = Q, { pageSettingState: u, isTemporaryPage: _ } = z(), m = C({
|
|
2
|
+
import { reactive as C, ref as B, onBeforeMount as L, resolveComponent as r, openBlock as y, createElementBlock as w, Fragment as M, createVNode as c, withCtx as d, createElementVNode as b, withDirectives as O, vShow as G, createTextVNode as k, createBlock as V, createCommentVNode as D } from "vue";
|
|
3
|
+
import { VueMonaco as R } from "@opentiny/tiny-engine-common";
|
|
4
|
+
import { Button as U, Popover as J, DialogBox as j } from "@opentiny/vue";
|
|
5
|
+
import { useCanvas as P, useLayout as S, useBlock as z, usePage as F, useNotify as I } from "@opentiny/tiny-engine-controller";
|
|
6
|
+
import { theme as q } from "@opentiny/tiny-engine-controller/adapter";
|
|
7
|
+
import { constants as H } from "@opentiny/tiny-engine-utils";
|
|
8
|
+
import { handlePageUpdate as K } from "@opentiny/tiny-engine-controller/js/http";
|
|
9
|
+
const { pageState: x, isSaved: Q, isBlock: W, canvasApi: N } = P(), { PLUGIN_NAME: X, getPluginApi: Y } = S(), { getCurrentBlock: Z } = z(), { PAGE_STATUS: s } = H, { pageSettingState: p, isTemporaryPage: _ } = F(), u = C({
|
|
11
10
|
visible: !1,
|
|
12
11
|
code: "",
|
|
13
12
|
originalCode: "",
|
|
14
13
|
disabled: !1
|
|
15
|
-
}),
|
|
16
|
-
var
|
|
17
|
-
const e =
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
const { currentPage: e } =
|
|
14
|
+
}), l = B(!1), $ = async (n) => {
|
|
15
|
+
var o;
|
|
16
|
+
const e = Y(X.BlockManage), t = Z();
|
|
17
|
+
t.label = n.fileName, t.content = n, l.value = !0, t.screenshot = await e.getBlockBase64(), await ((o = e.saveBlock) == null ? void 0 : o.call(e, t)), l.value = !1;
|
|
18
|
+
}, ee = async (n) => {
|
|
19
|
+
const { currentPage: e } = x, t = {
|
|
21
20
|
page_content: n
|
|
22
21
|
};
|
|
23
|
-
|
|
22
|
+
l.value = !0, await K(e.id, { ...e, ...t }, !1, !0), l.value = !1;
|
|
24
23
|
}, f = (n) => {
|
|
25
|
-
const e = JSON.parse(n);
|
|
26
|
-
if (
|
|
24
|
+
const e = JSON.parse(n), { setSchema: t, selectNode: o } = N.value;
|
|
25
|
+
if (x.pageSchema = e, t(e), p != null && p.isAIPage) {
|
|
27
26
|
_.saved && (_.saved = !1), _.saved = !0;
|
|
28
|
-
const
|
|
29
|
-
return
|
|
27
|
+
const a = "page_content";
|
|
28
|
+
return p.currentPageData[a] = e, Promise.resolve();
|
|
30
29
|
}
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
var
|
|
34
|
-
if (
|
|
30
|
+
return o(null), W() ? $(e) : ee(e);
|
|
31
|
+
}, A = async () => {
|
|
32
|
+
var i;
|
|
33
|
+
if (Q() || u.disabled)
|
|
35
34
|
return;
|
|
36
|
-
const n = (
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
35
|
+
const n = (i = S().layoutState) == null ? void 0 : i.pageStatus, e = n == null ? void 0 : n.state, t = n == null ? void 0 : n.data, { getSchema: o } = N.value, a = {
|
|
36
|
+
[s.Release]: "当前页面未锁定,请先锁定再保存",
|
|
37
|
+
[s.Empty]: "当前应用无页面,请先新建页面再保存",
|
|
38
|
+
[s.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
|
|
39
|
+
[s.Lock]: `当前页面被 ${t == null ? void 0 : t.username} ${t == null ? void 0 : t.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
|
|
41
40
|
};
|
|
42
|
-
if ([
|
|
43
|
-
|
|
41
|
+
if ([s.Release, s.Empty, s.Guest, s.Lock].includes(e)) {
|
|
42
|
+
I({
|
|
44
43
|
type: "error",
|
|
45
44
|
title: "保存失败",
|
|
46
|
-
message:
|
|
45
|
+
message: a[e]
|
|
47
46
|
});
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
u.disabled = !0;
|
|
50
|
+
const m = o();
|
|
51
|
+
u.code = JSON.stringify(m || {}, null, 2), f(u.code).finally(() => {
|
|
52
|
+
u.disabled = !1;
|
|
54
53
|
});
|
|
55
54
|
};
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
for (const [
|
|
59
|
-
o
|
|
60
|
-
return
|
|
61
|
-
},
|
|
55
|
+
const oe = (n, e) => {
|
|
56
|
+
const t = n.__vccOpts || n;
|
|
57
|
+
for (const [o, a] of e)
|
|
58
|
+
t[o] = a;
|
|
59
|
+
return t;
|
|
60
|
+
}, te = {
|
|
62
61
|
saveCommon: f,
|
|
63
|
-
openCommon:
|
|
64
|
-
},
|
|
62
|
+
openCommon: A
|
|
63
|
+
}, ne = {
|
|
65
64
|
components: {
|
|
66
|
-
VueMonaco:
|
|
67
|
-
TinyButton:
|
|
68
|
-
TinyPopover:
|
|
69
|
-
TinyDialogBox:
|
|
65
|
+
VueMonaco: R,
|
|
66
|
+
TinyButton: U,
|
|
67
|
+
TinyPopover: J,
|
|
68
|
+
TinyDialogBox: j
|
|
70
69
|
},
|
|
71
70
|
props: {
|
|
72
71
|
icon: {
|
|
@@ -81,14 +80,14 @@ const ne = (n, e) => {
|
|
|
81
80
|
originalCode: "",
|
|
82
81
|
disabled: !1,
|
|
83
82
|
timer: null
|
|
84
|
-
}),
|
|
83
|
+
}), t = B(null), o = () => {
|
|
85
84
|
e.visible = !1, e.originalCode = "";
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
85
|
+
}, a = () => {
|
|
86
|
+
l.value || A();
|
|
87
|
+
}, m = () => {
|
|
89
88
|
f();
|
|
90
|
-
},
|
|
91
|
-
theme:
|
|
89
|
+
}, i = {
|
|
90
|
+
theme: q(),
|
|
92
91
|
tabSize: 2,
|
|
93
92
|
language: "json",
|
|
94
93
|
autoIndent: !0,
|
|
@@ -100,93 +99,93 @@ const ne = (n, e) => {
|
|
|
100
99
|
enabled: !1
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
|
-
return
|
|
102
|
+
return L(() => {
|
|
104
103
|
clearTimeout(e.timer);
|
|
105
104
|
}), {
|
|
106
105
|
state: e,
|
|
107
|
-
editor:
|
|
108
|
-
editorOptions:
|
|
109
|
-
isLoading:
|
|
110
|
-
close:
|
|
106
|
+
editor: t,
|
|
107
|
+
editorOptions: i,
|
|
108
|
+
isLoading: l,
|
|
109
|
+
close: o,
|
|
111
110
|
isSaved: n,
|
|
112
|
-
openApi:
|
|
113
|
-
saveApi:
|
|
111
|
+
openApi: a,
|
|
112
|
+
saveApi: m
|
|
114
113
|
};
|
|
115
114
|
}
|
|
116
|
-
},
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return y(),
|
|
120
|
-
|
|
115
|
+
}, ae = ["id"], se = { class: "dots" };
|
|
116
|
+
function ie(n, e, t, o, a, m) {
|
|
117
|
+
const i = r("svg-icon"), h = r("tiny-popover"), T = r("vue-monaco"), g = r("tiny-button"), E = r("tiny-dialog-box");
|
|
118
|
+
return y(), w(M, null, [
|
|
119
|
+
c(h, {
|
|
121
120
|
trigger: "hover",
|
|
122
121
|
"open-delay": 1e3,
|
|
123
122
|
"popper-class": "toolbar-right-popover",
|
|
124
123
|
"append-to-body": "",
|
|
125
|
-
content:
|
|
124
|
+
content: o.isLoading ? "保存中" : "保存"
|
|
126
125
|
}, {
|
|
127
126
|
reference: d(() => [
|
|
128
127
|
b("span", {
|
|
129
|
-
id: `${
|
|
128
|
+
id: `${o.isLoading ? "saving" : ""}`,
|
|
130
129
|
class: "icon",
|
|
131
|
-
onClick: e[0] || (e[0] = (...v) =>
|
|
130
|
+
onClick: e[0] || (e[0] = (...v) => o.openApi && o.openApi(...v))
|
|
132
131
|
}, [
|
|
133
|
-
|
|
134
|
-
[
|
|
132
|
+
O(b("span", se, null, 512), [
|
|
133
|
+
[G, !o.isSaved()]
|
|
135
134
|
]),
|
|
136
|
-
|
|
137
|
-
], 8,
|
|
135
|
+
c(i, { name: t.icon }, null, 8, ["name"])
|
|
136
|
+
], 8, ae)
|
|
138
137
|
]),
|
|
139
138
|
_: 1
|
|
140
139
|
}, 8, ["content"]),
|
|
141
|
-
|
|
140
|
+
c(E, {
|
|
142
141
|
class: "dialog-box",
|
|
143
142
|
modal: !1,
|
|
144
143
|
fullscreen: !0,
|
|
145
144
|
"append-to-body": !0,
|
|
146
|
-
visible:
|
|
145
|
+
visible: o.state.visible,
|
|
147
146
|
title: "Schema 本地与线上差异",
|
|
148
|
-
"onUpdate:visible": e[1] || (e[1] = (v) =>
|
|
147
|
+
"onUpdate:visible": e[1] || (e[1] = (v) => o.state.visible = v)
|
|
149
148
|
}, {
|
|
150
149
|
footer: d(() => [
|
|
151
|
-
|
|
152
|
-
default: d(() => [
|
|
150
|
+
c(g, { onClick: o.close }, {
|
|
151
|
+
default: d(() => e[2] || (e[2] = [
|
|
153
152
|
k("取 消")
|
|
154
|
-
]),
|
|
153
|
+
])),
|
|
155
154
|
_: 1
|
|
156
155
|
}, 8, ["onClick"]),
|
|
157
|
-
|
|
156
|
+
c(g, {
|
|
158
157
|
type: "primary",
|
|
159
|
-
onClick:
|
|
158
|
+
onClick: o.saveApi
|
|
160
159
|
}, {
|
|
161
|
-
default: d(() => [
|
|
160
|
+
default: d(() => e[3] || (e[3] = [
|
|
162
161
|
k("保 存")
|
|
163
|
-
]),
|
|
162
|
+
])),
|
|
164
163
|
_: 1
|
|
165
164
|
}, 8, ["onClick"])
|
|
166
165
|
]),
|
|
167
166
|
default: d(() => [
|
|
168
|
-
|
|
167
|
+
o.state.visible ? (y(), V(T, {
|
|
169
168
|
key: 0,
|
|
170
169
|
ref: "editor",
|
|
171
170
|
class: "monaco-editor",
|
|
172
171
|
diffEditor: !0,
|
|
173
|
-
options:
|
|
174
|
-
value:
|
|
175
|
-
original:
|
|
176
|
-
}, null, 8, ["options", "value", "original"])) :
|
|
172
|
+
options: o.editorOptions,
|
|
173
|
+
value: o.state.code,
|
|
174
|
+
original: o.state.originalCode
|
|
175
|
+
}, null, 8, ["options", "value", "original"])) : D("", !0)
|
|
177
176
|
]),
|
|
178
177
|
_: 1
|
|
179
178
|
}, 8, ["visible"])
|
|
180
179
|
], 64);
|
|
181
180
|
}
|
|
182
|
-
const le = /* @__PURE__ */ ne
|
|
181
|
+
const le = /* @__PURE__ */ oe(ne, [["render", ie], ["__scopeId", "data-v-a55d2356"]]), fe = {
|
|
183
182
|
id: "save",
|
|
184
183
|
title: "save",
|
|
185
184
|
icon: "",
|
|
186
185
|
align: "right",
|
|
187
186
|
component: le,
|
|
188
|
-
api:
|
|
187
|
+
api: te
|
|
189
188
|
};
|
|
190
189
|
export {
|
|
191
|
-
|
|
190
|
+
fe as default
|
|
192
191
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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-canvas": "1.0.
|
|
28
|
-
"@opentiny/tiny-engine-common": "1.0.
|
|
29
|
-
"@opentiny/tiny-engine-controller": "1.0.
|
|
30
|
-
"@opentiny/tiny-engine-utils": "1.0.
|
|
31
|
-
"@opentiny/vue": "~3.10.0"
|
|
27
|
+
"@opentiny/tiny-engine-canvas": "1.0.5",
|
|
28
|
+
"@opentiny/tiny-engine-common": "1.0.4",
|
|
29
|
+
"@opentiny/tiny-engine-controller": "1.0.5",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "1.0.6"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
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": "12bfefc821d435bf69e7e02bf288b5fed633588f"
|
|
42
42
|
}
|