@opentiny/tiny-engine-toolbar-save 1.0.4-alpha.0 → 1.0.5

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