@opentiny/tiny-engine-toolbar-save 1.0.2-beta.0 → 1.0.3

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,47 +1,46 @@
1
1
  import "./style.css";
2
- import { reactive as B, ref as P, watch as T, onBeforeMount as w, resolveComponent as r, openBlock as k, createElementBlock as E, Fragment as M, createVNode as l, withCtx as d, createElementVNode as C, normalizeClass as O, withDirectives as G, vShow as V, createTextVNode as S, createBlock as D, createCommentVNode as R } from "vue";
3
- import { VueMonaco as U } from "@opentiny/tiny-engine-common";
4
- import { Loading as z, Button as I, Popover as J, DialogBox as j } from "@opentiny/vue";
5
- import { useCanvas as h, useLayout as x, useBlock as F, usePage as q, useNotify as H } from "@opentiny/tiny-engine-controller";
6
- import { theme as K } from "@opentiny/tiny-engine-controller/adapter";
7
- import { setSchema as Q, getSchema as W } from "@opentiny/tiny-engine-canvas";
8
- import { constants as X } from "@opentiny/tiny-engine-utils";
9
- import { handlePageUpdate as Y } from "@opentiny/tiny-engine-common/js/http";
10
- const { pageState: f, isSaved: Z, isBlock: $ } = h(), { PLUGIN_NAME: ee, getPluginApi: oe } = x(), { getCurrentBlock: te } = F(), { PAGE_STATUS: a } = X, { pageSettingState: p, isTemporaryPage: g } = q(), m = B({
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-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({
11
11
  visible: !1,
12
12
  code: "",
13
13
  originalCode: "",
14
14
  disabled: !1
15
- }), s = P(!1), ne = async (n) => {
15
+ }), i = B(!1), oe = async (n) => {
16
16
  var t;
17
- const e = oe(ee.BlockManage), o = te();
18
- o.label = n.fileName, o.content = n, s.value = !0, o.screenshot = await e.getBlockBase64(), await ((t = e.saveBlock) == null ? void 0 : t.call(e, o)), s.value = !1;
19
- }, ae = async (n) => {
20
- const { currentPage: e } = f, o = {
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
21
  page_content: n
22
22
  };
23
- s.value = !0, await Y(e.id, { ...e, ...o }), s.value = !1;
24
- }, y = (n) => {
23
+ i.value = !0, await W(e.id, { ...e, ...o }), i.value = !1;
24
+ }, f = (n) => {
25
25
  const e = JSON.parse(n);
26
- if (f.pageSchema = e, Q(e), p != null && p.isAIPage) {
27
- g.saved && (g.saved = !1), g.saved = !0;
26
+ if (h.pageSchema = e, q(e), u != null && u.isAIPage) {
27
+ _.saved && (_.saved = !1), _.saved = !0;
28
28
  const o = "page_content";
29
- p.currentPageData[o] = e;
30
- return;
29
+ return u.currentPageData[o] = e, Promise.resolve();
31
30
  }
32
- $() ? ne(e) : ae(e);
33
- }, N = async () => {
31
+ return H(null), Y() ? oe(e) : te(e);
32
+ }, x = async () => {
34
33
  var c;
35
- if (Z() || m.disabled)
34
+ if (X() || m.disabled)
36
35
  return;
37
- const n = (c = x().layoutState) == null ? void 0 : c.pageStatus, e = n == null ? void 0 : n.state, o = n == null ? void 0 : n.data, t = {
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
- H({
43
+ F({
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
- let i = z.service({
53
- lock: !0,
54
- text: "保存中",
55
- background: "rgba(0, 0, 0, 0.5)"
51
+ const s = K();
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 se = (n, e) => {
56
+ const ne = (n, e) => {
66
57
  const o = n.__vccOpts || n;
67
- for (const [t, i] of e)
68
- o[t] = i;
58
+ for (const [t, s] of e)
59
+ o[t] = s;
69
60
  return o;
70
- }, ie = {
71
- saveCommon: y,
72
- openCommon: N
73
- }, ce = {
61
+ }, ae = {
62
+ saveCommon: f,
63
+ openCommon: x
64
+ }, se = {
74
65
  components: {
75
- VueMonaco: U,
76
- TinyButton: I,
77
- TinyPopover: J,
78
- TinyDialogBox: j
66
+ VueMonaco: D,
67
+ TinyButton: R,
68
+ TinyPopover: U,
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 } = h(), e = B({
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 = P(null), t = () => {
84
+ }), o = B(null), t = () => {
94
85
  e.visible = !1, e.originalCode = "";
95
- }, i = () => {
96
- s.value || N();
97
- }, u = () => {
98
- y();
99
- }, c = {
100
- theme: K(),
86
+ }, s = () => {
87
+ i.value || x();
88
+ }, c = () => {
89
+ f();
90
+ }, p = {
91
+ theme: I(),
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 w(() => {
103
+ return E(() => {
113
104
  clearTimeout(e.timer);
114
105
  }), {
115
106
  state: e,
116
107
  editor: o,
117
- editorOptions: c,
118
- isLoading: s,
108
+ editorOptions: p,
109
+ isLoading: i,
119
110
  close: t,
120
111
  isSaved: n,
121
- openApi: i,
122
- saveApi: u
112
+ openApi: s,
113
+ saveApi: c
123
114
  };
124
115
  }
125
- }, re = { class: "dots" };
126
- function le(n, e, o, t, i, u) {
127
- const c = r("svg-icon"), v = r("tiny-popover"), A = r("vue-monaco"), b = r("tiny-button"), L = r("tiny-dialog-box");
128
- return k(), E(M, null, [
129
- l(v, {
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, {
130
121
  trigger: "hover",
131
122
  "open-delay": 1e3,
132
123
  "popper-class": "toolbar-right-popover",
@@ -134,46 +125,47 @@ function le(n, e, o, t, i, u) {
134
125
  content: t.isLoading ? "保存中" : "保存"
135
126
  }, {
136
127
  reference: d(() => [
137
- C("span", {
138
- class: O([t.isLoading ? "saving" : "icon"]),
139
- onClick: e[0] || (e[0] = (..._) => t.openApi && t.openApi(..._))
128
+ b("span", {
129
+ id: `${t.isLoading ? "saving" : ""}`,
130
+ class: "icon",
131
+ onClick: e[0] || (e[0] = (...v) => t.openApi && t.openApi(...v))
140
132
  }, [
141
- G(C("span", re, null, 512), [
142
- [V, !t.isSaved()]
133
+ M(b("span", ce, null, 512), [
134
+ [O, !t.isSaved()]
143
135
  ]),
144
- l(c, { name: o.icon }, null, 8, ["name"])
145
- ], 2)
136
+ l(p, { name: o.icon }, null, 8, ["name"])
137
+ ], 8, ie)
146
138
  ]),
147
139
  _: 1
148
140
  }, 8, ["content"]),
149
- l(L, {
141
+ l(T, {
150
142
  class: "dialog-box",
151
143
  modal: !1,
152
144
  fullscreen: !0,
153
145
  "append-to-body": !0,
154
146
  visible: t.state.visible,
155
147
  title: "Schema 本地与线上差异",
156
- "onUpdate:visible": e[1] || (e[1] = (_) => t.state.visible = _)
148
+ "onUpdate:visible": e[1] || (e[1] = (v) => t.state.visible = v)
157
149
  }, {
158
150
  footer: d(() => [
159
- l(b, { onClick: t.close }, {
151
+ l(g, { onClick: t.close }, {
160
152
  default: d(() => [
161
- S("取 消")
153
+ k("取 消")
162
154
  ]),
163
155
  _: 1
164
156
  }, 8, ["onClick"]),
165
- l(b, {
157
+ l(g, {
166
158
  type: "primary",
167
159
  onClick: t.saveApi
168
160
  }, {
169
161
  default: d(() => [
170
- S("保 存")
162
+ k("保 存")
171
163
  ]),
172
164
  _: 1
173
165
  }, 8, ["onClick"])
174
166
  ]),
175
167
  default: d(() => [
176
- t.state.visible ? (k(), D(A, {
168
+ t.state.visible ? (y(), G(A, {
177
169
  key: 0,
178
170
  ref: "editor",
179
171
  class: "monaco-editor",
@@ -181,20 +173,20 @@ function le(n, e, o, t, i, u) {
181
173
  options: t.editorOptions,
182
174
  value: t.state.code,
183
175
  original: t.state.originalCode
184
- }, null, 8, ["options", "value", "original"])) : R("", !0)
176
+ }, null, 8, ["options", "value", "original"])) : V("", !0)
185
177
  ]),
186
178
  _: 1
187
179
  }, 8, ["visible"])
188
180
  ], 64);
189
181
  }
190
- const de = /* @__PURE__ */ se(ce, [["render", le], ["__scopeId", "data-v-6d9e48c8"]]), ke = {
182
+ const le = /* @__PURE__ */ ne(se, [["render", re], ["__scopeId", "data-v-a55d2356"]]), be = {
191
183
  id: "save",
192
184
  title: "save",
193
185
  icon: "",
194
186
  align: "right",
195
- component: de,
196
- api: ie
187
+ component: le,
188
+ api: ae
197
189
  };
198
190
  export {
199
- ke as default
191
+ be as default
200
192
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .dots[data-v-6d9e48c8]{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-6d9e48c8]{width:32px;height:32px;display:inline-block;cursor:not-allowed;color:var(--ti-lowcode-disabled-color);font-size:20px;margin-bottom:-2px}.dialog-box[data-v-6d9e48c8] .tiny-dialog-box{display:flex;flex-direction:column}.dialog-box[data-v-6d9e48c8] .tiny-dialog-box .tiny-dialog-box__body{flex:1}.dialog-box .monaco-editor[data-v-6d9e48c8]{width:100%;height:100%}.changeRole a{color:var(--ti-lowcode-canvas-handle-hover-bg);padding:0 5px}
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-save",
3
- "version": "1.0.2-beta.0",
3
+ "version": "1.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,18 +12,31 @@
12
12
  "files": [
13
13
  "dist"
14
14
  ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/opentiny/tiny-engine",
18
+ "directory": "packages/toolbars/save"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/opentiny/tiny-engine/issues"
22
+ },
23
+ "author": "OpenTiny Team",
24
+ "license": "MIT",
25
+ "homepage": "https://opentiny.design/tiny-engine",
15
26
  "dependencies": {
16
- "@opentiny/tiny-engine-canvas": "^1.0.3-beta.0",
17
- "@opentiny/tiny-engine-common": "^1.0.1-beta.0",
18
- "@opentiny/tiny-engine-controller": "^1.0.1-beta.0",
19
- "@opentiny/tiny-engine-utils": "^1.0.2-beta.0",
20
- "@opentiny/vue": "~3.10.0",
21
- "vue": "3.2.45"
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"
22
32
  },
23
33
  "devDependencies": {
24
34
  "@vitejs/plugin-vue": "^4.2.3",
25
35
  "@vitejs/plugin-vue-jsx": "^1.3.10",
26
36
  "vite": "^4.3.7"
27
37
  },
28
- "gitHead": "93f1b6980dd79fbaa4ec40be658daac8161b53a6"
38
+ "peerDependencies": {
39
+ "vue": "^3.4.15"
40
+ },
41
+ "gitHead": "9a6cce3988accb39c97a9a21169c022c65a8e27f"
29
42
  }