@opentiny/tiny-engine-toolbar-lock 2.0.0-alpha.2 → 2.0.0-alpha.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.
Files changed (2) hide show
  1. package/dist/index.js +83 -83
  2. package/package.json +11 -9
package/dist/index.js CHANGED
@@ -1,123 +1,123 @@
1
- import { reactive as O, computed as m, resolveComponent as f, openBlock as v, createElementBlock as h, createVNode as N, withCtx as b, createElementVNode as x, createCommentVNode as $ } from "vue";
2
- import { useCanvas as C, useLayout as P, useBlock as S, useNotify as g } from "@opentiny/tiny-engine-meta-register";
3
- import { constants as T } from "@opentiny/tiny-engine-utils";
4
- import { Popover as B } from "@opentiny/vue";
5
- import { useHttp as M } from "@opentiny/tiny-engine-http";
6
- const E = M(), G = (e) => E.get(`app-center/api/apps/canvas/lock?${e}`), L = (e, c) => {
7
- const r = e.__vccOpts || e;
8
- for (const [t, l] of c)
9
- r[t] = l;
10
- return r;
11
- }, { COMPONENT_NAME: U, PAGE_STATUS: s } = T, k = {
1
+ import { reactive as N, computed as m, resolveComponent as _, openBlock as b, createBlock as x, createCommentVNode as S } from "vue";
2
+ import { useCanvas as T, useLayout as $, useBlock as h, useNotify as k } from "@opentiny/tiny-engine-meta-register";
3
+ import { constants as B } from "@opentiny/tiny-engine-utils";
4
+ import { ToolbarBase as C } from "@opentiny/tiny-engine-common";
5
+ import { useHttp as v } from "@opentiny/tiny-engine-http";
6
+ const L = v(), M = (e) => L.get(`app-center/api/apps/canvas/lock?${e}`), P = (e, a) => {
7
+ const o = e.__vccOpts || e;
8
+ for (const [c, s] of a)
9
+ o[c] = s;
10
+ return o;
11
+ }, { COMPONENT_NAME: A, PAGE_STATUS: t } = B, d = {
12
12
  block: "区块",
13
13
  page: "页面"
14
- }, d = {
15
- [s.Release]: {
16
- message: (e) => `${k[e]}解锁成功!`,
14
+ }, g = {
15
+ [t.Release]: {
16
+ message: (e) => `${d[e]}解锁成功!`,
17
17
  currentOptName: "解锁",
18
18
  nextOptName: "锁定"
19
19
  },
20
- [s.Lock]: {
21
- message: (e) => `${k[e]}解锁成功!`,
20
+ [t.Lock]: {
21
+ message: (e) => `${d[e]}解锁成功!`,
22
22
  currentOptName: "解锁",
23
23
  nextOptName: "解锁"
24
24
  },
25
- [s.Occupy]: {
26
- message: (e) => `${k[e]}锁定成功`,
25
+ [t.Occupy]: {
26
+ message: (e) => `${d[e]}锁定成功`,
27
27
  currentOptName: "锁定",
28
28
  nextOptName: "解锁"
29
29
  }
30
- }, A = {
30
+ }, G = {
31
31
  components: {
32
- TinyPopover: B
32
+ ToolbarBase: C
33
33
  },
34
- setup() {
35
- const { pageState: e } = C(), { layoutState: c } = P(), { getCurrentBlock: r } = S(), t = O({
36
- status: m(() => c.pageStatus.state),
37
- isGuest: m(() => c.pageStatus.state === s.Guest),
34
+ props: {
35
+ options: {
36
+ type: Object,
37
+ default: () => ({})
38
+ }
39
+ },
40
+ setup(e) {
41
+ const { pageState: a } = T(), { layoutState: o } = $(), { getCurrentBlock: c } = h(), s = N({
42
+ status: m(() => o.pageStatus.state),
43
+ isGuest: m(() => o.pageStatus.state === t.Guest),
38
44
  type: "",
39
45
  disabled: !1
40
- }), l = m(() => {
41
- switch (t.status) {
42
- case s.Occupy:
43
- return "locked";
44
- case s.Lock:
45
- return "user-locked";
46
+ }), y = m(() => {
47
+ switch (s.status) {
48
+ case t.Occupy:
49
+ return e.options.icon.locked;
50
+ case t.Lock:
51
+ return e.options.icon.userLocked;
46
52
  default:
47
- return "unlocked";
53
+ return e.options.icon.unlocked;
48
54
  }
49
- }), u = (n, p, i) => {
50
- G(`id=${n}&state=${i}&type=${p}`).then((o) => {
51
- var _;
52
- if ((o == null ? void 0 : o.operate) === "success")
53
- g({
55
+ }), p = (l, O, i) => {
56
+ M(`id=${l}&state=${i}&type=${O}`).then((n) => {
57
+ var f;
58
+ if ((n == null ? void 0 : n.operate) === "success")
59
+ k({
54
60
  type: "success",
55
- message: d[i].message(p)
56
- }), c.pageStatus.state = i;
61
+ message: g[i].message(O)
62
+ }), o.pageStatus.state = i;
57
63
  else {
58
- const a = (_ = c.pageStatus) == null ? void 0 : _.data;
59
- g({
64
+ const r = (f = o.pageStatus) == null ? void 0 : f.data;
65
+ k({
60
66
  type: "warning",
61
- message: `当前页面被 ${(a == null ? void 0 : a.username) || ""} ${(a == null ? void 0 : a.resetPasswordToken) || ""} 锁定,请联系解锁`
67
+ message: `当前页面被 ${(r == null ? void 0 : r.username) || ""} ${(r == null ? void 0 : r.resetPasswordToken) || ""} 锁定,请联系解锁`
62
68
  });
63
69
  }
64
- }).catch((o) => {
65
- g({
70
+ }).catch((n) => {
71
+ k({
66
72
  type: "error",
67
- title: `页面${d[i].currentOptName}失败`,
68
- message: JSON.stringify((o == null ? void 0 : o.message) || o)
73
+ title: `页面${g[i].currentOptName}失败`,
74
+ message: JSON.stringify((n == null ? void 0 : n.message) || n)
69
75
  });
70
76
  }).finally(() => {
71
- t.disabled = !1;
77
+ s.disabled = !1;
72
78
  });
73
79
  };
74
80
  return {
75
- state: t,
81
+ state: s,
76
82
  lockOrUnlock: () => {
77
- if (t.disabled)
83
+ if (s.disabled)
78
84
  return;
79
- const n = t.status === s.Occupy || t.status === s.Lock ? s.Release : s.Occupy;
80
- e.currentSchema = {}, e.properties = null, t.disabled = !0, e.pageSchema.componentName !== U.Block ? u(e.currentPage.id, "page", n) : u(r().id, "block", n);
85
+ const l = s.status === t.Occupy || s.status === t.Lock ? t.Release : t.Occupy;
86
+ a.currentSchema = {}, a.properties = null, s.disabled = !0, a.pageSchema.componentName !== A.Block ? p(a.currentPage.id, "page", l) : p(c().id, "block", l);
81
87
  },
82
- PAGE_STATUS: s,
83
- statusMessageMap: d,
84
- iconName: l
88
+ PAGE_STATUS: t,
89
+ statusMessageMap: g,
90
+ iconName: y
85
91
  };
86
92
  }
87
- }, V = { key: 0 }, R = { class: "icon" };
88
- function q(e, c, r, t, l, u) {
89
- var p;
90
- const y = f("svg-icon"), n = f("tiny-popover");
91
- return t.state.isGuest ? $("", !0) : (v(), h("span", V, [
92
- N(n, {
93
- trigger: "hover",
94
- "open-delay": 1e3,
95
- "popper-class": "toolbar-right-popover",
96
- "append-to-body": "",
97
- content: (p = t.statusMessageMap[t.state.status]) == null ? void 0 : p.nextOptName
98
- }, {
99
- reference: b(() => [
100
- x("span", R, [
101
- N(y, {
102
- name: t.iconName,
103
- onClick: t.lockOrUnlock
104
- }, null, 8, ["name", "onClick"])
105
- ])
106
- ]),
107
- _: 1
108
- }, 8, ["content"])
109
- ]));
93
+ };
94
+ function U(e, a, o, c, s, y) {
95
+ var u;
96
+ const p = _("toolbar-base");
97
+ return c.state.isGuest ? S("", !0) : (b(), x(p, {
98
+ key: 0,
99
+ icon: c.iconName,
100
+ content: (u = c.statusMessageMap[c.state.status]) == null ? void 0 : u.nextOptName,
101
+ options: o.options,
102
+ onClickApi: c.lockOrUnlock
103
+ }, null, 8, ["icon", "content", "options", "onClickApi"]));
110
104
  }
111
- const w = /* @__PURE__ */ L(A, [["render", q]]), D = {
105
+ const E = /* @__PURE__ */ P(G, [["render", U]]), R = {
112
106
  id: "engine.toolbars.lock",
113
107
  title: "lock",
114
108
  type: "toolbars",
115
- icon: "",
116
- align: "left"
117
- }, K = {
118
- ...D,
119
- entry: w
109
+ options: {
110
+ icon: {
111
+ locked: "locked",
112
+ userLocked: "user-locked",
113
+ unlocked: "unlocked"
114
+ },
115
+ renderType: "icon"
116
+ }
117
+ }, V = {
118
+ ...R,
119
+ entry: E
120
120
  };
121
121
  export {
122
- K as default
122
+ V as default
123
123
  };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-lock",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "scripts": {
8
8
  "build": "vite build"
9
9
  },
10
+ "type": "module",
10
11
  "main": "dist/index.js",
11
12
  "module": "dist/index.js",
12
13
  "files": [
@@ -24,19 +25,20 @@
24
25
  "license": "MIT",
25
26
  "homepage": "https://opentiny.design/tiny-engine",
26
27
  "dependencies": {
27
- "@opentiny/tiny-engine-http": "2.0.0-alpha.2",
28
- "@opentiny/tiny-engine-meta-register": "2.0.0-alpha.2",
29
- "@opentiny/tiny-engine-utils": "2.0.0-alpha.2"
28
+ "@opentiny/tiny-engine-common": "2.0.0-alpha.3",
29
+ "@opentiny/tiny-engine-http": "2.0.0-alpha.3",
30
+ "@opentiny/tiny-engine-meta-register": "2.0.0-alpha.3",
31
+ "@opentiny/tiny-engine-utils": "2.0.0-alpha.3"
30
32
  },
31
33
  "devDependencies": {
32
- "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.0.0-alpha.2",
33
- "@vitejs/plugin-vue": "^4.2.3",
34
- "@vitejs/plugin-vue-jsx": "^3.1.0",
35
- "vite": "^4.3.7"
34
+ "@opentiny/tiny-engine-vite-plugin-meta-comments": "2.0.0-alpha.3",
35
+ "@vitejs/plugin-vue": "^5.1.2",
36
+ "@vitejs/plugin-vue-jsx": "^4.0.1",
37
+ "vite": "^5.4.2"
36
38
  },
37
39
  "peerDependencies": {
38
40
  "@opentiny/vue": "^3.14.0",
39
41
  "vue": "^3.4.15"
40
42
  },
41
- "gitHead": "695ecd00f21aa39965a9ddb02590ae274f92cd8e"
43
+ "gitHead": "20aba1ffa81a1633feec954e3146586193c18f22"
42
44
  }