@opentiny/tiny-engine-toolbar-save 1.0.1 → 1.0.2
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/LICENSE +22 -0
- package/dist/index.js +73 -82
- package/package.json +39 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 - present TinyEngine Authors.
|
|
4
|
+
Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
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 l, openBlock as y, createElementBlock as L, Fragment as w, createVNode as r, withCtx as d, createElementVNode as b, normalizeClass as M, 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 z, DialogBox as J } from "@opentiny/vue";
|
|
5
|
+
import { useCanvas as P, useLayout as S, useBlock as j, usePage as F, useNotify as I } from "@opentiny/tiny-engine-controller";
|
|
6
|
+
import { theme as q } from "@opentiny/tiny-engine-controller/adapter";
|
|
7
|
+
import { setSchema as H, selectNode as K, getSchema as Q } from "@opentiny/tiny-engine-canvas";
|
|
8
|
+
import { constants as W } from "@opentiny/tiny-engine-utils";
|
|
9
|
+
import { handlePageUpdate as X } from "@opentiny/tiny-engine-common/js/http";
|
|
10
|
+
const { pageState: h, isSaved: Y, isBlock: Z } = P(), { PLUGIN_NAME: $, getPluginApi: ee } = S(), { getCurrentBlock: oe } = j(), { PAGE_STATUS: a } = W, { pageSettingState: u, isTemporaryPage: _ } = F(), m = C({
|
|
11
11
|
visible: !1,
|
|
12
12
|
code: "",
|
|
13
13
|
originalCode: "",
|
|
14
14
|
disabled: !1
|
|
15
|
-
}),
|
|
15
|
+
}), i = B(!1), te = 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 = ee($.BlockManage), o = oe();
|
|
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
|
+
}, ne = async (n) => {
|
|
20
|
+
const { currentPage: e } = h, o = {
|
|
21
21
|
page_content: n
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
},
|
|
23
|
+
i.value = !0, await X(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, H(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 K(null), Z() ? te(e) : ne(e);
|
|
32
|
+
}, x = async () => {
|
|
34
33
|
var c;
|
|
35
|
-
if (
|
|
34
|
+
if (Y() || 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
|
+
I({
|
|
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 = Q();
|
|
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 ae = (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;
|
|
61
|
+
}, se = {
|
|
62
|
+
saveCommon: f,
|
|
63
|
+
openCommon: x
|
|
70
64
|
}, ie = {
|
|
71
|
-
saveCommon: y,
|
|
72
|
-
openCommon: N
|
|
73
|
-
}, ce = {
|
|
74
65
|
components: {
|
|
75
|
-
VueMonaco:
|
|
76
|
-
TinyButton:
|
|
77
|
-
TinyPopover:
|
|
78
|
-
TinyDialogBox:
|
|
66
|
+
VueMonaco: R,
|
|
67
|
+
TinyButton: U,
|
|
68
|
+
TinyPopover: z,
|
|
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: q(),
|
|
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 le(n, e, o, t,
|
|
127
|
-
const
|
|
128
|
-
return
|
|
129
|
-
|
|
116
|
+
}, ce = { class: "dots" };
|
|
117
|
+
function le(n, e, o, t, s, c) {
|
|
118
|
+
const p = l("svg-icon"), N = l("tiny-popover"), A = l("vue-monaco"), g = l("tiny-button"), T = l("tiny-dialog-box");
|
|
119
|
+
return y(), L(w, null, [
|
|
120
|
+
r(N, {
|
|
130
121
|
trigger: "hover",
|
|
131
122
|
"open-delay": 1e3,
|
|
132
123
|
"popper-class": "toolbar-right-popover",
|
|
@@ -134,46 +125,46 @@ function le(n, e, o, t, i, u) {
|
|
|
134
125
|
content: t.isLoading ? "保存中" : "保存"
|
|
135
126
|
}, {
|
|
136
127
|
reference: d(() => [
|
|
137
|
-
|
|
138
|
-
class:
|
|
139
|
-
onClick: e[0] || (e[0] = (...
|
|
128
|
+
b("span", {
|
|
129
|
+
class: M([t.isLoading ? "saving" : "icon"]),
|
|
130
|
+
onClick: e[0] || (e[0] = (...v) => t.openApi && t.openApi(...v))
|
|
140
131
|
}, [
|
|
141
|
-
|
|
142
|
-
[
|
|
132
|
+
O(b("span", ce, null, 512), [
|
|
133
|
+
[G, !t.isSaved()]
|
|
143
134
|
]),
|
|
144
|
-
|
|
135
|
+
r(p, { name: o.icon }, null, 8, ["name"])
|
|
145
136
|
], 2)
|
|
146
137
|
]),
|
|
147
138
|
_: 1
|
|
148
139
|
}, 8, ["content"]),
|
|
149
|
-
|
|
140
|
+
r(T, {
|
|
150
141
|
class: "dialog-box",
|
|
151
142
|
modal: !1,
|
|
152
143
|
fullscreen: !0,
|
|
153
144
|
"append-to-body": !0,
|
|
154
145
|
visible: t.state.visible,
|
|
155
146
|
title: "Schema 本地与线上差异",
|
|
156
|
-
"onUpdate:visible": e[1] || (e[1] = (
|
|
147
|
+
"onUpdate:visible": e[1] || (e[1] = (v) => t.state.visible = v)
|
|
157
148
|
}, {
|
|
158
149
|
footer: d(() => [
|
|
159
|
-
|
|
150
|
+
r(g, { onClick: t.close }, {
|
|
160
151
|
default: d(() => [
|
|
161
|
-
|
|
152
|
+
k("取 消")
|
|
162
153
|
]),
|
|
163
154
|
_: 1
|
|
164
155
|
}, 8, ["onClick"]),
|
|
165
|
-
|
|
156
|
+
r(g, {
|
|
166
157
|
type: "primary",
|
|
167
158
|
onClick: t.saveApi
|
|
168
159
|
}, {
|
|
169
160
|
default: d(() => [
|
|
170
|
-
|
|
161
|
+
k("保 存")
|
|
171
162
|
]),
|
|
172
163
|
_: 1
|
|
173
164
|
}, 8, ["onClick"])
|
|
174
165
|
]),
|
|
175
166
|
default: d(() => [
|
|
176
|
-
t.state.visible ? (
|
|
167
|
+
t.state.visible ? (y(), V(A, {
|
|
177
168
|
key: 0,
|
|
178
169
|
ref: "editor",
|
|
179
170
|
class: "monaco-editor",
|
|
@@ -181,20 +172,20 @@ function le(n, e, o, t, i, u) {
|
|
|
181
172
|
options: t.editorOptions,
|
|
182
173
|
value: t.state.code,
|
|
183
174
|
original: t.state.originalCode
|
|
184
|
-
}, null, 8, ["options", "value", "original"])) :
|
|
175
|
+
}, null, 8, ["options", "value", "original"])) : D("", !0)
|
|
185
176
|
]),
|
|
186
177
|
_: 1
|
|
187
178
|
}, 8, ["visible"])
|
|
188
179
|
], 64);
|
|
189
180
|
}
|
|
190
|
-
const
|
|
181
|
+
const re = /* @__PURE__ */ ae(ie, [["render", le], ["__scopeId", "data-v-6d9e48c8"]]), be = {
|
|
191
182
|
id: "save",
|
|
192
183
|
title: "save",
|
|
193
184
|
icon: "",
|
|
194
185
|
align: "right",
|
|
195
|
-
component:
|
|
196
|
-
api:
|
|
186
|
+
component: re,
|
|
187
|
+
api: se
|
|
197
188
|
};
|
|
198
189
|
export {
|
|
199
|
-
|
|
190
|
+
be as default
|
|
200
191
|
};
|
package/package.json
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentiny/tiny-engine-toolbar-save",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/opentiny/tiny-engine",
|
|
15
|
+
"directory": "packages/toolbars/save"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/opentiny/tiny-engine/issues"
|
|
19
|
+
},
|
|
20
|
+
"author": "OpenTiny Team",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"homepage": "https://opentiny.design/tiny-engine",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@opentiny/vue": "~3.10.0",
|
|
25
|
+
"vue": "3.2.45",
|
|
26
|
+
"@opentiny/tiny-engine-canvas": "1.0.2",
|
|
27
|
+
"@opentiny/tiny-engine-common": "1.0.1",
|
|
28
|
+
"@opentiny/tiny-engine-controller": "1.0.2",
|
|
29
|
+
"@opentiny/tiny-engine-utils": "1.0.3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
33
|
+
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
|
34
|
+
"vite": "^4.3.7"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build"
|
|
38
|
+
}
|
|
39
|
+
}
|