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