@opentiny/tiny-engine-toolbar-save 1.0.2-beta.0 → 1.0.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 -82
  2. package/package.json +21 -11
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 l, openBlock as y, createElementBlock as L, Fragment as w, createVNode as r, withCtx as d, createElementVNode as b, normalizeClass as M, 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 z, DialogBox as J } from "@opentiny/vue";
5
+ import { useCanvas as P, useLayout as S, useBlock as j, usePage as F, useNotify as I } from "@opentiny/tiny-engine-controller";
6
+ import { theme as q } from "@opentiny/tiny-engine-controller/adapter";
7
+ import { setSchema as H, selectNode as K, getSchema as Q } from "@opentiny/tiny-engine-canvas";
8
+ import { constants as W } from "@opentiny/tiny-engine-utils";
9
+ import { handlePageUpdate as X } from "@opentiny/tiny-engine-common/js/http";
10
+ const { pageState: h, isSaved: Y, isBlock: Z } = P(), { PLUGIN_NAME: $, getPluginApi: ee } = S(), { getCurrentBlock: oe } = j(), { PAGE_STATUS: a } = W, { pageSettingState: u, isTemporaryPage: _ } = F(), 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), te = 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 = ee($.BlockManage), o = oe();
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
+ }, ne = 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 X(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, H(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 K(null), Z() ? te(e) : ne(e);
32
+ }, x = async () => {
34
33
  var c;
35
- if (Z() || m.disabled)
34
+ if (Y() || 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
+ I({
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 = Q();
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 ae = (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;
61
+ }, se = {
62
+ saveCommon: f,
63
+ openCommon: x
70
64
  }, ie = {
71
- saveCommon: y,
72
- openCommon: N
73
- }, ce = {
74
65
  components: {
75
- VueMonaco: U,
76
- TinyButton: I,
77
- TinyPopover: J,
78
- TinyDialogBox: j
66
+ VueMonaco: R,
67
+ TinyButton: U,
68
+ TinyPopover: z,
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: q(),
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
+ }, ce = { class: "dots" };
117
+ function le(n, e, o, t, s, c) {
118
+ const p = l("svg-icon"), N = l("tiny-popover"), A = l("vue-monaco"), g = l("tiny-button"), T = l("tiny-dialog-box");
119
+ return y(), L(w, null, [
120
+ r(N, {
130
121
  trigger: "hover",
131
122
  "open-delay": 1e3,
132
123
  "popper-class": "toolbar-right-popover",
@@ -134,46 +125,46 @@ 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
+ class: M([t.isLoading ? "saving" : "icon"]),
130
+ onClick: e[0] || (e[0] = (...v) => t.openApi && t.openApi(...v))
140
131
  }, [
141
- G(C("span", re, null, 512), [
142
- [V, !t.isSaved()]
132
+ O(b("span", ce, null, 512), [
133
+ [G, !t.isSaved()]
143
134
  ]),
144
- l(c, { name: o.icon }, null, 8, ["name"])
135
+ r(p, { name: o.icon }, null, 8, ["name"])
145
136
  ], 2)
146
137
  ]),
147
138
  _: 1
148
139
  }, 8, ["content"]),
149
- l(L, {
140
+ r(T, {
150
141
  class: "dialog-box",
151
142
  modal: !1,
152
143
  fullscreen: !0,
153
144
  "append-to-body": !0,
154
145
  visible: t.state.visible,
155
146
  title: "Schema 本地与线上差异",
156
- "onUpdate:visible": e[1] || (e[1] = (_) => t.state.visible = _)
147
+ "onUpdate:visible": e[1] || (e[1] = (v) => t.state.visible = v)
157
148
  }, {
158
149
  footer: d(() => [
159
- l(b, { onClick: t.close }, {
150
+ r(g, { onClick: t.close }, {
160
151
  default: d(() => [
161
- S("取 消")
152
+ k("取 消")
162
153
  ]),
163
154
  _: 1
164
155
  }, 8, ["onClick"]),
165
- l(b, {
156
+ r(g, {
166
157
  type: "primary",
167
158
  onClick: t.saveApi
168
159
  }, {
169
160
  default: d(() => [
170
- S("保 存")
161
+ k("保 存")
171
162
  ]),
172
163
  _: 1
173
164
  }, 8, ["onClick"])
174
165
  ]),
175
166
  default: d(() => [
176
- t.state.visible ? (k(), D(A, {
167
+ t.state.visible ? (y(), V(A, {
177
168
  key: 0,
178
169
  ref: "editor",
179
170
  class: "monaco-editor",
@@ -181,20 +172,20 @@ function le(n, e, o, t, i, u) {
181
172
  options: t.editorOptions,
182
173
  value: t.state.code,
183
174
  original: t.state.originalCode
184
- }, null, 8, ["options", "value", "original"])) : R("", !0)
175
+ }, null, 8, ["options", "value", "original"])) : D("", !0)
185
176
  ]),
186
177
  _: 1
187
178
  }, 8, ["visible"])
188
179
  ], 64);
189
180
  }
190
- const de = /* @__PURE__ */ se(ce, [["render", le], ["__scopeId", "data-v-6d9e48c8"]]), ke = {
181
+ const re = /* @__PURE__ */ ae(ie, [["render", le], ["__scopeId", "data-v-6d9e48c8"]]), be = {
191
182
  id: "save",
192
183
  title: "save",
193
184
  icon: "",
194
185
  align: "right",
195
- component: de,
196
- api: ie
186
+ component: re,
187
+ api: se
197
188
  };
198
189
  export {
199
- ke as default
190
+ be as default
200
191
  };
package/package.json CHANGED
@@ -1,29 +1,39 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-save",
3
- "version": "1.0.2-beta.0",
3
+ "version": "1.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "scripts": {
8
- "build": "vite build"
9
- },
10
7
  "main": "dist/index.js",
11
8
  "module": "dist/index.js",
12
9
  "files": [
13
10
  "dist"
14
11
  ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/opentiny/tiny-engine",
15
+ "directory": "packages/toolbars/save"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/opentiny/tiny-engine/issues"
19
+ },
20
+ "author": "OpenTiny Team",
21
+ "license": "MIT",
22
+ "homepage": "https://opentiny.design/tiny-engine",
15
23
  "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
24
  "@opentiny/vue": "~3.10.0",
21
- "vue": "3.2.45"
25
+ "vue": "3.2.45",
26
+ "@opentiny/tiny-engine-canvas": "1.0.2",
27
+ "@opentiny/tiny-engine-common": "1.0.1",
28
+ "@opentiny/tiny-engine-controller": "1.0.2",
29
+ "@opentiny/tiny-engine-utils": "1.0.3"
22
30
  },
23
31
  "devDependencies": {
24
32
  "@vitejs/plugin-vue": "^4.2.3",
25
33
  "@vitejs/plugin-vue-jsx": "^1.3.10",
26
34
  "vite": "^4.3.7"
27
35
  },
28
- "gitHead": "93f1b6980dd79fbaa4ec40be658daac8161b53a6"
29
- }
36
+ "scripts": {
37
+ "build": "vite build"
38
+ }
39
+ }