@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 CHANGED
@@ -1,171 +1,236 @@
1
1
  import "./style.css";
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";
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 { 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({
8
+ const { PAGE_STATUS: u } = Q, g = V({
11
9
  visible: !1,
12
10
  code: "",
13
11
  originalCode: "",
14
12
  disabled: !1
15
- }), i = B(!1), oe = async (n) => {
16
- var t;
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
- page_content: n
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
- i.value = !0, await W(e.id, { ...e, ...o }), i.value = !1;
24
- }, f = (n) => {
25
- const e = JSON.parse(n);
26
- if (h.pageSchema = e, q(e), u != null && u.isAIPage) {
27
- _.saved && (_.saved = !1), _.saved = !0;
28
- const o = "page_content";
29
- return u.currentPageData[o] = e, Promise.resolve();
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 H(null), Y() ? oe(e) : te(e);
29
+ return d(null), t() ? X(s) : Y(s);
32
30
  }, x = async () => {
33
- var c;
34
- if (X() || m.disabled)
31
+ var d;
32
+ const { isSaved: a, canvasApi: e } = y();
33
+ if (a() || g.disabled)
35
34
  return;
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 = {
37
- [a.Release]: "当前页面未锁定,请先锁定再保存",
38
- [a.Empty]: "当前应用无页面,请先新建页面再保存",
39
- [a.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
40
- [a.Lock]: `当前页面被 ${o == null ? void 0 : o.username} ${o == null ? void 0 : o.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
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 ([a.Release, a.Empty, a.Guest, a.Lock].includes(e)) {
43
- F({
41
+ if ([u.Release, u.Empty, u.Guest, u.Lock].includes(t)) {
42
+ q({
44
43
  type: "error",
45
44
  title: "保存失败",
46
- message: t[e]
45
+ message: s[t]
47
46
  });
48
47
  return;
49
48
  }
50
- m.disabled = !0;
51
- const s = K();
52
- m.code = JSON.stringify(s || {}, null, 2), f(m.code).finally(() => {
53
- m.disabled = !1;
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 ne = (n, e) => {
57
- const o = n.__vccOpts || n;
58
- for (const [t, s] of e)
59
- o[t] = s;
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
- }, ae = {
62
- saveCommon: f,
60
+ }, I = {
61
+ saveCommon: k,
63
62
  openCommon: x
64
- }, se = {
63
+ }, $ = {
65
64
  components: {
66
- VueMonaco: D,
67
- TinyButton: R,
68
- TinyPopover: U,
69
- TinyDialogBox: J
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 { isSaved: n } = P(), e = C({
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
- timer: null
84
- }), o = B(null), t = () => {
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
- }, s = () => {
87
- i.value || x();
88
- }, c = () => {
89
- f();
90
- }, p = {
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 E(() => {
104
- clearTimeout(e.timer);
117
+ return A(() => {
118
+ clearTimeout(e.preservationTime);
105
119
  }), {
106
120
  state: e,
107
121
  editor: o,
108
- editorOptions: p,
109
- isLoading: i,
122
+ editorOptions: s,
123
+ isLoading: _,
110
124
  close: t,
111
- isSaved: n,
112
- openApi: s,
113
- saveApi: c
125
+ openApi: n,
126
+ saveApi: f,
127
+ options: a,
128
+ cancel: c,
129
+ autoSave: d
114
130
  };
115
131
  }
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, {
121
- trigger: "hover",
122
- "open-delay": 1e3,
123
- "popper-class": "toolbar-right-popover",
124
- "append-to-body": "",
125
- content: t.isLoading ? "保存中" : "保存"
126
- }, {
127
- reference: d(() => [
128
- b("span", {
129
- id: `${t.isLoading ? "saving" : ""}`,
130
- class: "icon",
131
- onClick: e[0] || (e[0] = (...v) => t.openApi && t.openApi(...v))
132
- }, [
133
- M(b("span", ce, null, 512), [
134
- [O, !t.isSaved()]
135
- ]),
136
- l(p, { name: o.icon }, null, 8, ["name"])
137
- ], 8, ie)
138
- ]),
139
- _: 1
140
- }, 8, ["content"]),
141
- l(T, {
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[1] || (e[1] = (v) => t.state.visible = v)
213
+ "onUpdate:visible": e[4] || (e[4] = (m) => t.state.visible = m)
149
214
  }, {
150
- footer: d(() => [
151
- l(g, { onClick: t.close }, {
152
- default: d(() => [
153
- k("取 消")
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
- l(g, {
222
+ i(c, {
158
223
  type: "primary",
159
224
  onClick: t.saveApi
160
225
  }, {
161
- default: d(() => [
162
- k("保 存")
163
- ]),
226
+ default: l(() => e[11] || (e[11] = [
227
+ b("保 存")
228
+ ])),
164
229
  _: 1
165
230
  }, 8, ["onClick"])
166
231
  ]),
167
- default: d(() => [
168
- t.state.visible ? (y(), G(A, {
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"])) : V("", !0)
241
+ }, null, 8, ["options", "value", "original"])) : D("", !0)
177
242
  ]),
178
243
  _: 1
179
244
  }, 8, ["visible"])
180
245
  ], 64);
181
246
  }
182
- const le = /* @__PURE__ */ ne(se, [["render", re], ["__scopeId", "data-v-a55d2356"]]), be = {
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
- component: le,
188
- api: ae
252
+ align: "right"
253
+ }, fe = {
254
+ ...le,
255
+ entry: ie,
256
+ apis: I
189
257
  };
190
258
  export {
191
- be as default
259
+ fe as default
192
260
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
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}
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": "1.0.3",
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-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"
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.3.10",
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": "9a6cce3988accb39c97a9a21169c022c65a8e27f"
41
+ "gitHead": "f15ccc5dde391288bf4297e3ffc35aab52651f3d"
42
42
  }