@opentiny/tiny-engine-toolbar-save 2.0.0 → 2.1.0

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 +74 -74
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./style.css";
2
- import { reactive as P, ref as V, onUnmounted as h, resolveComponent as m, openBlock as B, createElementBlock as N, createVNode as d, withCtx as r, createTextVNode as k, createBlock as O, createCommentVNode as M, createElementVNode as b } from "vue";
2
+ import { reactive as B, ref as P, onUnmounted as N, resolveComponent as m, openBlock as x, createElementBlock as h, createVNode as c, withCtx as r, createTextVNode as k, createBlock as O, createCommentVNode as M, createElementVNode as g } from "vue";
3
3
  import { VueMonaco as U, ToolbarBase as D } from "@opentiny/tiny-engine-common";
4
4
  import { Button as L, Popover as G, DialogBox as R, Checkbox as j, Select as J } from "@opentiny/vue";
5
- import { usePage as q, useCanvas as T, getOptions as z, useNotify as S, useLayout as F, getMetaApi as H, META_APP as K, useBlock as Q } from "@opentiny/tiny-engine-meta-register";
5
+ import { usePage as q, useCanvas as C, getOptions as z, useNotify as T, useLayout as F, getMetaApi as H, META_APP as K, useBlock as Q } from "@opentiny/tiny-engine-meta-register";
6
6
  import { constants as W } from "@opentiny/tiny-engine-utils";
7
7
  import { handlePageUpdate as X } from "@opentiny/tiny-engine-common/js/http";
8
- const A = {
8
+ const V = {
9
9
  id: "engine.toolbars.save",
10
10
  type: "toolbars",
11
11
  title: "save",
@@ -15,78 +15,78 @@ const A = {
15
15
  },
16
16
  renderType: "button"
17
17
  }
18
- }, { PAGE_STATUS: u } = W, g = P({
18
+ }, { PAGE_STATUS: u } = W, _ = B({
19
19
  visible: !1,
20
20
  code: "",
21
21
  originalCode: "",
22
22
  disabled: !1
23
- }), f = V(!1), Y = async (n) => {
24
- var a;
23
+ }), y = P(!1), Y = async (n) => {
24
+ var i;
25
25
  const e = H(K.BlockManage), { getCurrentBlock: t } = Q(), o = t();
26
- o.label = n.fileName, o.content = n, f.value = !0, o.screenshot = await e.getBlockBase64(), await ((a = e.saveBlock) == null ? void 0 : a.call(e, o)), f.value = !1;
26
+ o.label = n.fileName, o.content = n, y.value = !0, o.screenshot = await e.getBlockBase64(), await ((i = e.saveBlock) == null ? void 0 : i.call(e, o)), y.value = !1;
27
27
  }, Z = async (n) => {
28
- const { currentPage: e } = T().pageState, t = {
28
+ const { currentPage: e } = C().pageState, t = {
29
29
  page_content: n
30
30
  };
31
- f.value = !0, await X(e.id, { ...e, ...t }, !1, !0), f.value = !1;
32
- }, x = (n) => {
33
- const { pageSettingState: e, isTemporaryPage: t } = q(), { isBlock: o, canvasApi: a, pageState: s } = T(), i = JSON.parse(n), { setSchema: l, selectNode: c } = a.value;
34
- if (s.pageSchema = i, l(i), e != null && e.isAIPage) {
31
+ y.value = !0, await X(e.id, { ...e, ...t }, !1, !0), y.value = !1;
32
+ }, S = (n) => {
33
+ const { pageSettingState: e, isTemporaryPage: t } = q(), { isBlock: o, canvasApi: i, pageState: s, resetBlockCanvasState: d, resetPageCanvasState: l } = C(), a = JSON.parse(n), { selectNode: v } = i.value;
34
+ if (o() ? d({ ...s, pageSchema: a }) : l({ ...s, pageSchema: a }), e != null && e.isAIPage) {
35
35
  t.saved && (t.saved = !1), t.saved = !0;
36
- const v = "page_content";
37
- return e.currentPageData[v] = i, Promise.resolve();
36
+ const p = "page_content";
37
+ return e.currentPageData[p] = a, Promise.resolve();
38
38
  }
39
- return c(null), o() ? Y(i) : Z(i);
40
- }, w = async () => {
41
- var _;
42
- const { isSaved: n, canvasApi: e } = T();
43
- if (n() || g.disabled)
39
+ return v(null), o() ? Y(a) : Z(a);
40
+ }, A = async () => {
41
+ var p;
42
+ const { isSaved: n, getSchema: e } = C();
43
+ if (n() || _.disabled)
44
44
  return;
45
- const { beforeSave: t, saveMethod: o, saved: a } = z(A.id);
45
+ const { beforeSave: t, saveMethod: o, saved: i } = z(V.id);
46
46
  try {
47
47
  if (typeof t == "function" && await t(), typeof o == "function" && await o())
48
48
  return;
49
- } catch (p) {
50
- S({
49
+ } catch (f) {
50
+ T({
51
51
  type: "error",
52
- message: `Error in saving: ${p}`
52
+ message: `Error in saving: ${f}`
53
53
  });
54
54
  }
55
- const s = (_ = F().layoutState) == null ? void 0 : _.pageStatus, i = s == null ? void 0 : s.state, l = s == null ? void 0 : s.data, { getSchema: c } = e.value, v = {
55
+ const s = (p = F().layoutState) == null ? void 0 : p.pageStatus, d = s == null ? void 0 : s.state, l = s == null ? void 0 : s.data, a = {
56
56
  [u.Release]: "当前页面未锁定,请先锁定再保存",
57
57
  [u.Empty]: "当前应用无页面,请先新建页面再保存",
58
58
  [u.Guest]: "官网演示应用不能保存页面,如需体验请切换应用",
59
59
  [u.Lock]: `当前页面被 ${l == null ? void 0 : l.username} ${l == null ? void 0 : l.resetPasswordToken} 锁定,如需编辑请先联系他解锁文件,然后再锁定该页面后编辑!`
60
60
  };
61
- if ([u.Release, u.Empty, u.Guest, u.Lock].includes(i)) {
62
- S({
61
+ if ([u.Release, u.Empty, u.Guest, u.Lock].includes(d)) {
62
+ T({
63
63
  type: "error",
64
64
  title: "保存失败",
65
- message: v[i]
65
+ message: a[d]
66
66
  });
67
67
  return;
68
68
  }
69
- g.disabled = !0;
70
- const C = c();
71
- g.code = JSON.stringify(C || {}, null, 2), x(g.code).finally(() => {
72
- if (g.disabled = !1, typeof a == "function")
69
+ _.disabled = !0;
70
+ const v = e();
71
+ _.code = JSON.stringify(v || {}, null, 2), S(_.code).finally(() => {
72
+ if (_.disabled = !1, typeof i == "function")
73
73
  try {
74
- a();
75
- } catch (p) {
76
- S({
74
+ i();
75
+ } catch (f) {
76
+ T({
77
77
  type: "error",
78
- message: `Error in saved: ${p}`
78
+ message: `Error in saved: ${f}`
79
79
  });
80
80
  }
81
81
  });
82
82
  }, I = (n, e) => {
83
83
  const t = n.__vccOpts || n;
84
- for (const [o, a] of e)
85
- t[o] = a;
84
+ for (const [o, i] of e)
85
+ t[o] = i;
86
86
  return t;
87
87
  }, $ = {
88
- saveCommon: x,
89
- openCommon: w
88
+ saveCommon: S,
89
+ openCommon: A
90
90
  }, ee = {
91
91
  components: {
92
92
  VueMonaco: U,
@@ -108,11 +108,11 @@ const A = {
108
108
  }
109
109
  },
110
110
  setup() {
111
- const { isSaved: n } = T(), e = [
111
+ const { isSaved: n } = C(), e = [
112
112
  { value: 5, label: "5分钟" },
113
113
  { value: 10, label: "10分钟" },
114
114
  { value: 15, label: "15分钟" }
115
- ], t = P({
115
+ ], t = B({
116
116
  visible: !1,
117
117
  code: "",
118
118
  originalCode: "",
@@ -120,77 +120,77 @@ const A = {
120
120
  timeValue: 5,
121
121
  checked: !1,
122
122
  preservationTime: null
123
- }), o = V(null), a = () => {
123
+ }), o = P(null), i = () => {
124
124
  t.visible = !1, t.originalCode = "";
125
125
  }, s = () => {
126
- f.value || w();
127
- }, i = () => {
128
- x();
126
+ y.value || A();
127
+ }, d = () => {
128
+ S();
129
129
  }, l = {
130
130
  language: "json",
131
131
  lineNumbers: !0,
132
132
  minimap: {
133
133
  enabled: !1
134
134
  }
135
- }, c = () => {
135
+ }, a = () => {
136
136
  clearTimeout(t.preservationTime), t.preservationTime = setTimeout(() => {
137
- s(), c();
137
+ s(), a();
138
138
  }, t.timeValue * 60 * 1e3);
139
139
  }, v = () => {
140
- t.checked ? c() : clearTimeout(t.preservationTime);
140
+ t.checked ? a() : clearTimeout(t.preservationTime);
141
141
  };
142
- return h(() => {
142
+ return N(() => {
143
143
  clearTimeout(t.preservationTime);
144
144
  }), {
145
145
  state: t,
146
146
  editor: o,
147
147
  editorOptions: l,
148
- isLoading: f,
148
+ isLoading: y,
149
149
  isSaved: n,
150
- close: a,
150
+ close: i,
151
151
  openApi: s,
152
- saveApi: i,
152
+ saveApi: d,
153
153
  delayOptions: e,
154
154
  autoSave: v
155
155
  };
156
156
  }
157
157
  }, oe = { class: "toolbar-save" }, te = { class: "save-style" }, ne = { class: "save-time" }, ae = { class: "save-button-group" };
158
- function se(n, e, t, o, a, s) {
159
- const i = m("svg-icon"), l = m("vue-monaco"), c = m("tiny-button"), v = m("tiny-dialog-box"), C = m("toolbar-base"), _ = m("tiny-checkbox"), p = m("tiny-select"), E = m("tiny-popover");
160
- return B(), N("div", oe, [
161
- d(E, {
158
+ function se(n, e, t, o, i, s) {
159
+ const d = m("svg-icon"), l = m("vue-monaco"), a = m("tiny-button"), v = m("tiny-dialog-box"), p = m("toolbar-base"), f = m("tiny-checkbox"), w = m("tiny-select"), E = m("tiny-popover");
160
+ return x(), h("div", oe, [
161
+ c(E, {
162
162
  "visible-arrow": !1,
163
163
  width: "203",
164
164
  trigger: "hover"
165
165
  }, {
166
166
  reference: r(() => [
167
- d(C, {
167
+ c(p, {
168
168
  content: o.isLoading ? "保存中" : "保存",
169
169
  icon: t.options.icon.default || t.options.icon,
170
170
  options: { ...t.options, showDots: !o.isSaved() },
171
171
  onClickApi: o.openApi
172
172
  }, {
173
173
  button: r(() => [
174
- d(i, { name: t.iconExpand }, null, 8, ["name"])
174
+ c(d, { name: t.iconExpand }, null, 8, ["name"])
175
175
  ]),
176
176
  default: r(() => [
177
- d(v, {
177
+ c(v, {
178
178
  class: "dialog-box",
179
179
  modal: !1,
180
180
  fullscreen: !0,
181
181
  "append-to-body": !0,
182
182
  visible: o.state.visible,
183
183
  title: "Schema 本地与线上差异",
184
- "onUpdate:visible": e[0] || (e[0] = (y) => o.state.visible = y)
184
+ "onUpdate:visible": e[0] || (e[0] = (b) => o.state.visible = b)
185
185
  }, {
186
186
  footer: r(() => [
187
- d(c, { onClick: o.close }, {
187
+ c(a, { onClick: o.close }, {
188
188
  default: r(() => e[3] || (e[3] = [
189
189
  k("取 消")
190
190
  ])),
191
191
  _: 1
192
192
  }, 8, ["onClick"]),
193
- d(c, {
193
+ c(a, {
194
194
  type: "primary",
195
195
  onClick: o.saveApi
196
196
  }, {
@@ -201,7 +201,7 @@ function se(n, e, t, o, a, s) {
201
201
  }, 8, ["onClick"])
202
202
  ]),
203
203
  default: r(() => [
204
- o.state.visible ? (B(), O(l, {
204
+ o.state.visible ? (x(), O(l, {
205
205
  key: 0,
206
206
  ref: "editor",
207
207
  class: "monaco-editor",
@@ -218,11 +218,11 @@ function se(n, e, t, o, a, s) {
218
218
  }, 8, ["content", "icon", "options", "onClickApi"])
219
219
  ]),
220
220
  default: r(() => [
221
- b("div", te, [
222
- e[8] || (e[8] = b("div", { class: "save-setting" }, "保存设置", -1)),
223
- d(_, {
221
+ g("div", te, [
222
+ e[8] || (e[8] = g("div", { class: "save-setting" }, "保存设置", -1)),
223
+ c(f, {
224
224
  modelValue: o.state.checked,
225
- "onUpdate:modelValue": e[1] || (e[1] = (y) => o.state.checked = y),
225
+ "onUpdate:modelValue": e[1] || (e[1] = (b) => o.state.checked = b),
226
226
  name: "tiny-checkbox"
227
227
  }, {
228
228
  default: r(() => e[5] || (e[5] = [
@@ -230,18 +230,18 @@ function se(n, e, t, o, a, s) {
230
230
  ])),
231
231
  _: 1
232
232
  }, 8, ["modelValue"]),
233
- b("div", ne, [
234
- e[6] || (e[6] = b("div", { class: "save-time-label" }, "保存间隔", -1)),
235
- d(p, {
233
+ g("div", ne, [
234
+ e[6] || (e[6] = g("div", { class: "save-time-label" }, "保存间隔", -1)),
235
+ c(w, {
236
236
  modelValue: o.state.timeValue,
237
- "onUpdate:modelValue": e[2] || (e[2] = (y) => o.state.timeValue = y),
237
+ "onUpdate:modelValue": e[2] || (e[2] = (b) => o.state.timeValue = b),
238
238
  options: o.delayOptions,
239
239
  disabled: !o.state.checked,
240
240
  autocomplete: ""
241
241
  }, null, 8, ["modelValue", "options", "disabled"])
242
242
  ]),
243
- b("div", ae, [
244
- d(c, {
243
+ g("div", ae, [
244
+ c(a, {
245
245
  type: "primary",
246
246
  onClick: o.autoSave
247
247
  }, {
@@ -258,7 +258,7 @@ function se(n, e, t, o, a, s) {
258
258
  ]);
259
259
  }
260
260
  const ie = /* @__PURE__ */ I(ee, [["render", se], ["__scopeId", "data-v-75c21aff"]]), pe = {
261
- ...A,
261
+ ...V,
262
262
  entry: ie,
263
263
  apis: $
264
264
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-save",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
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.0.0",
29
- "@opentiny/tiny-engine-meta-register": "2.0.0",
30
- "@opentiny/tiny-engine-utils": "2.0.0"
28
+ "@opentiny/tiny-engine-common": "2.1.0",
29
+ "@opentiny/tiny-engine-meta-register": "2.1.0",
30
+ "@opentiny/tiny-engine-utils": "2.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.0.0",
33
+ "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.1.0",
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.14.0",
40
40
  "vue": "^3.4.15"
41
41
  },
42
- "gitHead": "26b32b2236bb85d8113158fd1475884aa99a9657"
42
+ "gitHead": "faf3072c75ea5024689972e2a687916e084c156f"
43
43
  }