@opentiny/tiny-engine-toolbar-save 2.4.1 → 2.4.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.
Files changed (2) hide show
  1. package/dist/index.js +73 -73
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./style.css";
2
- import { reactive as x, ref as h, onMounted as A, onUnmounted as O, resolveComponent as f, createElementBlock as J, openBlock as P, createVNode as v, withCtx as u, createBlock as L, createCommentVNode as U, createTextVNode as S, createElementVNode as k } from "vue";
3
- import { ToolbarBase as I, VueMonaco as G } from "@opentiny/tiny-engine-common";
4
- import { Select as R, Checkbox as j, DialogBox as Y, Popover as q, Button as z } from "@opentiny/vue";
5
- import { useCanvas as B, getOptions as H, useNotify as D, useLayout as K, usePage as Q, getMetaApi as W, META_APP as X, useBlock as Z, useMessage as $ } from "@opentiny/tiny-engine-meta-register";
6
- import { constants as N } from "@opentiny/tiny-engine-utils";
2
+ import { reactive as N, ref as B, onMounted as P, onUnmounted as x, resolveComponent as f, createElementBlock as L, openBlock as E, createVNode as v, withCtx as d, createBlock as U, createCommentVNode as I, createTextVNode as S, createElementVNode as k } from "vue";
3
+ import { ToolbarBase as G, VueMonaco as R } from "@opentiny/tiny-engine-common";
4
+ import { Select as j, Checkbox as Y, DialogBox as q, Popover as z, Button as F } from "@opentiny/vue";
5
+ import { useCanvas as C, getOptions as H, useNotify as A, useLayout as K, usePage as Q, getMetaApi as W, META_APP as X, useBlock as Z, useMessage as $ } from "@opentiny/tiny-engine-meta-register";
6
+ import { constants as V } from "@opentiny/tiny-engine-utils";
7
7
  import { handlePageUpdate as ee } from "@opentiny/tiny-engine-common/js/http";
8
- const V = {
8
+ const w = {
9
9
  id: "engine.toolbars.save",
10
10
  type: "toolbars",
11
11
  title: "save",
@@ -15,17 +15,17 @@ const V = {
15
15
  },
16
16
  renderType: "button"
17
17
  }
18
- }, { PAGE_STATUS: g, AUTO_SAVED: w } = N, _ = x({
18
+ }, { PAGE_STATUS: g, AUTO_SAVED: D } = V, _ = N({
19
19
  visible: !1,
20
20
  code: "",
21
21
  originalCode: "",
22
22
  disabled: !1
23
- }), b = h(!1), te = async (a) => {
23
+ }), b = B(!1), te = async (a) => {
24
24
  var s;
25
25
  const e = W(X.BlockManage), { getCurrentBlock: o } = Z(), t = o();
26
26
  t.label = a.fileName, t.content = a, b.value = !0, t.screenshot = await e.getBlockBase64(), await ((s = e.saveBlock) == null ? void 0 : s.call(e, t)), b.value = !1;
27
27
  }, oe = async (a) => {
28
- const { currentPage: e } = B().pageState, o = {
28
+ const { currentPage: e } = C().pageState, o = {
29
29
  page_content: a
30
30
  };
31
31
  b.value = !0;
@@ -34,27 +34,27 @@ const V = {
34
34
  params: { ...e, ...o }
35
35
  };
36
36
  await ee(t), b.value = !1;
37
- }, T = (a) => {
38
- const { pageSettingState: e, isTemporaryPage: o } = Q(), { isBlock: t, canvasApi: s, pageState: l, resetBlockCanvasState: r, resetPageCanvasState: i } = B(), n = JSON.parse(a), { selectNode: c } = s.value;
37
+ }, O = (a) => {
38
+ const { pageSettingState: e, isTemporaryPage: o } = Q(), { isBlock: t, canvasApi: s, pageState: l, resetBlockCanvasState: r, resetPageCanvasState: i } = C(), n = JSON.parse(a), { selectNode: c } = s.value;
39
39
  if (t() ? r({ ...l, pageSchema: n }) : i({ ...l, pageSchema: n }), e != null && e.isAIPage) {
40
40
  o.saved && (o.saved = !1), o.saved = !0;
41
41
  const p = "page_content";
42
42
  return e.currentPageData[p] = n, Promise.resolve();
43
43
  }
44
44
  return c(null), t() ? te(n) : oe(n);
45
- }, F = async () => {
45
+ }, M = async () => {
46
46
  var p;
47
- const { isSaved: a, getSchema: e } = B();
47
+ const { isSaved: a, getSchema: e } = C();
48
48
  if (a() || _.disabled)
49
49
  return;
50
- const { beforeSave: o, saveMethod: t, saved: s } = H(V.id);
50
+ const { beforeSave: o, saveMethod: t, saved: s } = H(w.id);
51
51
  try {
52
52
  if (typeof o == "function" && await o(), typeof t == "function" && await t())
53
53
  return;
54
- } catch (d) {
55
- D({
54
+ } catch (u) {
55
+ A({
56
56
  type: "error",
57
- message: `Error in saving: ${d}`
57
+ message: `Error in saving: ${u}`
58
58
  });
59
59
  }
60
60
  const l = (p = K().layoutState) == null ? void 0 : p.pageStatus, r = l == null ? void 0 : l.state, i = l == null ? void 0 : l.data, n = {
@@ -64,7 +64,7 @@ const V = {
64
64
  [g.Lock]: `当前页面被 ${i == null ? void 0 : i.username} ${i == null ? void 0 : i.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
65
65
  };
66
66
  if ([g.Release, g.Empty, g.Guest, g.Lock].includes(r)) {
67
- D({
67
+ A({
68
68
  type: "error",
69
69
  title: "保存失败",
70
70
  message: n[r]
@@ -73,42 +73,42 @@ const V = {
73
73
  }
74
74
  _.disabled = !0;
75
75
  const c = e();
76
- _.code = JSON.stringify(c || {}, null, 2), T(_.code).finally(() => {
76
+ _.code = JSON.stringify(c || {}, null, 2), O(_.code).finally(() => {
77
77
  if (_.disabled = !1, typeof s == "function")
78
78
  try {
79
79
  s();
80
- } catch (d) {
81
- D({
80
+ } catch (u) {
81
+ A({
82
82
  type: "error",
83
- message: `Error in saved: ${d}`
83
+ message: `Error in saved: ${u}`
84
84
  });
85
85
  }
86
86
  });
87
87
  }, ae = () => {
88
88
  try {
89
- const a = localStorage.getItem(w) ?? "";
89
+ const a = localStorage.getItem(D) ?? "";
90
90
  return JSON.parse(a) ?? !1;
91
91
  } catch {
92
92
  return !1;
93
93
  }
94
94
  }, ne = (a) => {
95
95
  try {
96
- return localStorage.setItem(w, JSON.stringify(a)), !0;
96
+ return localStorage.setItem(D, JSON.stringify(a)), !0;
97
97
  } catch {
98
98
  return !1;
99
99
  }
100
- }, { OPEN_DELAY: se } = N, ie = {
101
- saveCommon: T,
102
- openCommon: F
100
+ }, { OPEN_DELAY: se } = V, ie = {
101
+ saveCommon: O,
102
+ openCommon: M
103
103
  }, le = {
104
104
  components: {
105
- VueMonaco: G,
106
- TinyButton: z,
107
- TinyPopover: q,
108
- TinyDialogBox: Y,
109
- TinyCheckbox: j,
110
- TinySelect: R,
111
- ToolbarBase: I
105
+ VueMonaco: R,
106
+ TinyButton: F,
107
+ TinyPopover: z,
108
+ TinyDialogBox: q,
109
+ TinyCheckbox: Y,
110
+ TinySelect: j,
111
+ ToolbarBase: G
112
112
  },
113
113
  props: {
114
114
  iconExpand: {
@@ -125,15 +125,15 @@ const V = {
125
125
  { value: 5, label: "5分钟" },
126
126
  { value: 10, label: "10分钟" },
127
127
  { value: 15, label: "15分钟" }
128
- ], e = x({
128
+ ], e = N({
129
129
  visible: !1,
130
130
  code: "",
131
131
  originalCode: "",
132
132
  checked: !1,
133
133
  timeValue: 5,
134
134
  preservationTime: null
135
- }), o = h(null), { isSaved: t, setSaved: s, getSchema: l } = B(), { subscribe: r, unsubscribe: i } = $(), n = "toolbar-save", c = h(null);
136
- A(() => {
135
+ }), o = B(null), { isSaved: t, setSaved: s, getSchema: l } = C(), { subscribe: r, unsubscribe: i } = $(), n = "toolbar-save", c = B(null);
136
+ P(() => {
137
137
  r({
138
138
  topic: "pageOrBlockInit",
139
139
  subscriber: n,
@@ -159,16 +159,16 @@ const V = {
159
159
  }
160
160
  }
161
161
  });
162
- }), O(() => {
162
+ }), x(() => {
163
163
  i({ topic: "pageOrBlockInit", subscriber: n }), i({ topic: "schemaChange", subscriber: n }), i({ topic: "schemaImport", subscriber: n });
164
164
  });
165
165
  const p = () => {
166
166
  e.visible = !1, e.originalCode = "";
167
- }, d = () => {
168
- b.value || F();
169
- }, C = () => {
170
- T();
171
- }, E = {
167
+ }, u = () => {
168
+ b.value || M();
169
+ }, h = () => {
170
+ O();
171
+ }, T = {
172
172
  language: "json",
173
173
  lineNumbers: !0,
174
174
  minimap: {
@@ -176,26 +176,26 @@ const V = {
176
176
  }
177
177
  }, m = () => {
178
178
  clearTimeout(e.preservationTime), e.preservationTime = setTimeout(() => {
179
- d(), m();
179
+ u(), m();
180
180
  }, e.timeValue * 60 * 1e3);
181
- }, M = () => {
181
+ }, J = () => {
182
182
  ne(e.checked), e.checked ? m() : clearTimeout(e.preservationTime);
183
183
  };
184
- return A(() => {
184
+ return P(() => {
185
185
  e.checked = ae(), e.checked && m();
186
- }), O(() => {
186
+ }), x(() => {
187
187
  clearTimeout(e.preservationTime);
188
188
  }), {
189
189
  state: e,
190
190
  editor: o,
191
- editorOptions: E,
191
+ editorOptions: T,
192
192
  isLoading: b,
193
193
  isSaved: t,
194
194
  close: p,
195
- openApi: d,
196
- saveApi: C,
195
+ openApi: u,
196
+ saveApi: h,
197
197
  delayOptions: a,
198
- saveConfig: M,
198
+ saveConfig: J,
199
199
  OPEN_DELAY: se
200
200
  };
201
201
  }
@@ -204,40 +204,40 @@ const V = {
204
204
  for (const [t, s] of e)
205
205
  o[t] = s;
206
206
  return o;
207
- }, re = { class: "toolbar-save" }, ue = { class: "save-style" }, de = { class: "save-time" }, me = { class: "save-button-group" };
207
+ }, re = { class: "toolbar-save" }, de = { class: "save-style" }, ue = { class: "save-time" }, me = { class: "save-button-group" };
208
208
  function ve(a, e, o, t, s, l) {
209
- const r = f("svg-icon"), i = f("tiny-checkbox"), n = f("tiny-select"), c = f("tiny-button"), p = f("tiny-popover"), d = f("vue-monaco"), C = f("tiny-dialog-box"), E = f("toolbar-base");
210
- return P(), J("div", re, [
211
- v(E, {
209
+ const r = f("svg-icon"), i = f("tiny-checkbox"), n = f("tiny-select"), c = f("tiny-button"), p = f("tiny-popover"), u = f("vue-monaco"), h = f("tiny-dialog-box"), T = f("toolbar-base");
210
+ return E(), L("div", re, [
211
+ v(T, {
212
212
  content: t.isLoading ? "保存中" : "保存",
213
213
  icon: o.options.icon.default || o.options.icon,
214
214
  options: { ...o.options, showDots: !t.isSaved() },
215
215
  onClickApi: t.openApi
216
216
  }, {
217
- button: u(() => [
217
+ button: d(() => [
218
218
  v(p, {
219
219
  "visible-arrow": !1,
220
220
  width: "203",
221
221
  trigger: "click",
222
222
  "open-delay": t.OPEN_DELAY.Default
223
223
  }, {
224
- reference: u(() => [
224
+ reference: d(() => [
225
225
  v(r, { name: o.iconExpand }, null, 8, ["name"])
226
226
  ]),
227
- default: u(() => [
228
- k("div", ue, [
227
+ default: d(() => [
228
+ k("div", de, [
229
229
  e[6] || (e[6] = k("div", { class: "save-setting" }, "保存设置", -1)),
230
230
  v(i, {
231
231
  modelValue: t.state.checked,
232
232
  "onUpdate:modelValue": e[0] || (e[0] = (m) => t.state.checked = m),
233
233
  name: "tiny-checkbox"
234
234
  }, {
235
- default: u(() => e[3] || (e[3] = [
235
+ default: d(() => e[3] || (e[3] = [
236
236
  S("自动保存")
237
237
  ])),
238
238
  _: 1
239
239
  }, 8, ["modelValue"]),
240
- k("div", de, [
240
+ k("div", ue, [
241
241
  e[4] || (e[4] = k("div", { class: "save-time-label" }, "保存间隔", -1)),
242
242
  v(n, {
243
243
  modelValue: t.state.timeValue,
@@ -252,7 +252,7 @@ function ve(a, e, o, t, s, l) {
252
252
  type: "primary",
253
253
  onClick: t.saveConfig
254
254
  }, {
255
- default: u(() => e[5] || (e[5] = [
255
+ default: d(() => e[5] || (e[5] = [
256
256
  S("设置并保存")
257
257
  ])),
258
258
  _: 1
@@ -263,8 +263,8 @@ function ve(a, e, o, t, s, l) {
263
263
  _: 1
264
264
  }, 8, ["open-delay"])
265
265
  ]),
266
- default: u(() => [
267
- v(C, {
266
+ default: d(() => [
267
+ v(h, {
268
268
  class: "dialog-box",
269
269
  modal: !1,
270
270
  fullscreen: !0,
@@ -273,9 +273,9 @@ function ve(a, e, o, t, s, l) {
273
273
  title: "Schema 本地与线上差异",
274
274
  "onUpdate:visible": e[2] || (e[2] = (m) => t.state.visible = m)
275
275
  }, {
276
- footer: u(() => [
276
+ footer: d(() => [
277
277
  v(c, { onClick: t.close }, {
278
- default: u(() => e[7] || (e[7] = [
278
+ default: d(() => e[7] || (e[7] = [
279
279
  S("取 消")
280
280
  ])),
281
281
  _: 1
@@ -284,14 +284,14 @@ function ve(a, e, o, t, s, l) {
284
284
  type: "primary",
285
285
  onClick: t.saveApi
286
286
  }, {
287
- default: u(() => e[8] || (e[8] = [
287
+ default: d(() => e[8] || (e[8] = [
288
288
  S("保 存")
289
289
  ])),
290
290
  _: 1
291
291
  }, 8, ["onClick"])
292
292
  ]),
293
- default: u(() => [
294
- t.state.visible ? (P(), L(d, {
293
+ default: d(() => [
294
+ t.state.visible ? (E(), U(u, {
295
295
  key: 0,
296
296
  ref: "editor",
297
297
  class: "monaco-editor",
@@ -299,7 +299,7 @@ function ve(a, e, o, t, s, l) {
299
299
  options: t.editorOptions,
300
300
  value: t.state.code,
301
301
  original: t.state.originalCode
302
- }, null, 8, ["options", "value", "original"])) : U("", !0)
302
+ }, null, 8, ["options", "value", "original"])) : I("", !0)
303
303
  ]),
304
304
  _: 1
305
305
  }, 8, ["visible"])
@@ -308,11 +308,11 @@ function ve(a, e, o, t, s, l) {
308
308
  }, 8, ["content", "icon", "options", "onClickApi"])
309
309
  ]);
310
310
  }
311
- const pe = /* @__PURE__ */ ce(le, [["render", ve], ["__scopeId", "data-v-047f42c8"]]), Be = {
312
- ...V,
311
+ const pe = /* @__PURE__ */ ce(le, [["render", ve], ["__scopeId", "data-v-047f42c8"]]), Ce = {
312
+ ...w,
313
313
  entry: pe,
314
314
  apis: ie
315
315
  };
316
316
  export {
317
- Be as default
317
+ Ce as default
318
318
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-save",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,12 +25,12 @@
25
25
  "license": "MIT",
26
26
  "homepage": "https://opentiny.design/tiny-engine",
27
27
  "dependencies": {
28
- "@opentiny/tiny-engine-common": "2.4.1",
29
- "@opentiny/tiny-engine-meta-register": "2.4.1",
30
- "@opentiny/tiny-engine-utils": "2.4.1"
28
+ "@opentiny/tiny-engine-common": "2.4.2",
29
+ "@opentiny/tiny-engine-meta-register": "2.4.2",
30
+ "@opentiny/tiny-engine-utils": "2.4.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.4.1",
33
+ "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.4.2",
34
34
  "@vitejs/plugin-vue": "^5.1.2",
35
35
  "@vitejs/plugin-vue-jsx": "^4.0.1",
36
36
  "vite": "^5.4.2"
@@ -39,5 +39,5 @@
39
39
  "@opentiny/vue": "^3.20.0",
40
40
  "vue": "^3.4.15"
41
41
  },
42
- "gitHead": "5a3c6f536a46e25338800e9fe4c72c12e0c32bc5"
42
+ "gitHead": "3c5679965e80e59a8083fe629086e42b7b5dde36"
43
43
  }