@dazhicheng/ui 1.6.23 → 1.6.24

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.
@@ -1,8 +1,8 @@
1
- import { queryDataPermissionDetailDataTypeContext as E } from "../api/dataTypeContext.js";
2
- import { fetchUserListOnce as V, clearUserListCache as _ } from "./userListCache.js";
3
- import { ref as j, watchEffect as k, unref as R, computed as B } from "vue";
4
- import { useOwnerRoutePath as F } from "./useOwnerRoutePath.js";
5
- const u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), W = "all", G = { label: "全部", value: W }, T = /* @__PURE__ */ new WeakMap(), H = {
1
+ import { queryDataPermissionDetailDataTypeContext as j } from "../api/dataTypeContext.js";
2
+ import { fetchUserListOnce as k, clearUserListCache as B } from "./userListCache.js";
3
+ import { ref as F, watchEffect as W, unref as U, computed as G } from "vue";
4
+ import { useOwnerRoutePath as H } from "./useOwnerRoutePath.js";
5
+ const u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), J = "all", Q = { label: "全部", value: J }, b = /* @__PURE__ */ new WeakMap(), X = {
6
6
  platformId: ["platformName", "platformId"],
7
7
  shopId: ["shopName", "shopId"],
8
8
  purchasePlaceId: ["purchasePlaceName", "purchasePlaceCode"],
@@ -10,115 +10,119 @@ const u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), y = /* @__PU
10
10
  lockUserId: ["userName", "userId"],
11
11
  userId: ["fullName", "id"]
12
12
  };
13
- function J(n, s = []) {
14
- const i = T.get(s) || /* @__PURE__ */ new Map(), c = i.get(n);
15
- if (c) return c.slice();
16
- const [D, S] = H[n], w = s.map((p) => {
17
- const o = n === "purchasePlaceId" ? p.purchaseInfo || {} : p;
13
+ function Y(n, a = []) {
14
+ const i = b.get(a) || /* @__PURE__ */ new Map(), o = i.get(n);
15
+ if (o) return o.slice();
16
+ const [y, S] = X[n], m = a.map((h) => {
17
+ const c = n === "purchasePlaceId" ? h.purchaseInfo || {} : h;
18
18
  return {
19
- ...p,
20
- label: o == null ? void 0 : o[D],
21
- value: o == null ? void 0 : o[S]
19
+ ...h,
20
+ label: c == null ? void 0 : c[y],
21
+ value: c == null ? void 0 : c[S]
22
22
  };
23
23
  });
24
- return i.set(n, w), T.set(s, i), w.slice();
24
+ return i.set(n, m), b.set(a, i), m.slice();
25
25
  }
26
- function K(n) {
27
- const s = F(), i = j({});
28
- function c(t = {}) {
26
+ function re(n) {
27
+ const a = H(), i = F({});
28
+ function o(t = {}) {
29
29
  i.value = n.codes.reduce(
30
- (e, r) => (e[r] = J(r, t[r]), e),
30
+ (e, r) => (e[r] = Y(r, t[r]), e),
31
31
  {}
32
32
  );
33
33
  }
34
- function D(t) {
34
+ function y(t) {
35
35
  var e;
36
36
  return typeof n.showAll == "boolean" ? n.showAll : ((e = n.showAll) == null ? void 0 : e[t]) ?? !1;
37
37
  }
38
38
  function S() {
39
- y.clear(), g.clear(), u.clear(), d.clear(), m.clear(), _();
39
+ p.clear(), f.clear(), u.clear(), d.clear(), I.clear(), B();
40
40
  }
41
- function w(t) {
42
- u.delete(t), d.delete(t), g.delete(t);
41
+ function m(t) {
42
+ u.delete(t), d.delete(t), f.delete(t);
43
43
  }
44
- function p(t) {
44
+ function h(t) {
45
45
  const e = d.get(t) || /* @__PURE__ */ new Set(), r = e.size;
46
- n.codes.forEach((l) => e.add(l)), d.set(t, e), e.size !== r && O(t);
46
+ n.codes.forEach((l) => e.add(l)), d.set(t, e), e.size !== r && A(t);
47
47
  }
48
- async function o(t = !1) {
49
- const e = s, r = R(n.dataSource);
48
+ async function c(t = !1) {
49
+ const e = a, r = U(n.dataSource);
50
50
  if (r) {
51
- c({ ...u.get(e) || {}, ...r });
51
+ o({ ...u.get(e) || {}, ...r });
52
52
  return;
53
53
  }
54
- for (; ; ) {
55
- const l = u.get(e) || {}, A = [...d.get(e) || n.codes], C = t ? A : A.filter((a) => !Object.prototype.hasOwnProperty.call(l, a));
56
- if (t = !1, !C.length) {
57
- c(l);
54
+ const l = /* @__PURE__ */ new Set(), V = 32;
55
+ for (let L = 0; L < V; L++) {
56
+ const v = u.get(e) || {}, M = [...d.get(e) || n.codes], g = t ? M : M.filter((s) => !Object.prototype.hasOwnProperty.call(v, s));
57
+ if (t = !1, !g.length) {
58
+ o(v);
58
59
  return;
59
60
  }
60
- const L = y.get(e);
61
- if (L) {
62
- await L;
61
+ const N = p.get(e);
62
+ if (N) {
63
+ await N;
63
64
  continue;
64
65
  }
65
- const M = C.filter((a) => a !== "userId"), z = C.includes("userId"), N = Promise.allSettled([
66
- M.length ? E({ dataTypeName: M }).then(
67
- (a) => a
66
+ if (g.every((s) => l.has(s))) {
67
+ o(v);
68
+ return;
69
+ }
70
+ g.forEach((s) => l.add(s));
71
+ const x = g.filter((s) => s !== "userId"), _ = g.includes("userId"), D = Promise.allSettled([
72
+ x.length ? j({ dataTypeName: x }).then(
73
+ (s) => s
68
74
  ) : Promise.resolve([]),
69
- z ? V() : Promise.resolve(void 0)
70
- ]).then(([a, q]) => {
71
- const P = a.status === "fulfilled" ? a.value : [], I = q.status === "fulfilled" ? q.value : void 0;
75
+ _ ? k() : Promise.resolve(void 0)
76
+ ]).then(([s, q]) => {
77
+ const w = s.status === "fulfilled" ? s.value : [], C = q.status === "fulfilled" ? q.value : void 0;
72
78
  return {
73
- // 请求过的 code 一定落键:接口没返回的(无该维度权限、请求失败)也写成空数组,
74
- // 否则它永远算「缺失」,上面的复查循环会一直重发同一个请求
75
- ...C.reduce((f, h) => (f[h] = [], f), {}),
76
- ...I != null && I.length ? { userId: I } : {},
77
- ...P.reduce((f, h) => {
78
- const x = h == null ? void 0 : h.dataTypeCode;
79
- return x && (f[x] = h.originalItems || []), f;
79
+ ...C != null && C.length ? { userId: C } : {},
80
+ ...w.reduce((O, P) => {
81
+ const T = P == null ? void 0 : P.dataTypeCode;
82
+ return T && (O[T] = P.originalItems || []), O;
80
83
  }, {})
81
84
  };
82
- }), v = (m.get(e) || 0) + 1;
83
- m.set(e, v), y.set(e, N);
85
+ }), R = (I.get(e) || 0) + 1;
86
+ I.set(e, R), p.set(e, D);
84
87
  try {
85
- const a = await N;
86
- if (m.get(e) !== v) continue;
87
- const P = { ...u.get(e) || {}, ...a };
88
- u.set(e, P), c(P);
88
+ const s = await D;
89
+ if (I.get(e) !== R) continue;
90
+ const w = { ...u.get(e) || {}, ...s };
91
+ u.set(e, w), o(w);
89
92
  } finally {
90
- m.get(e) === v && y.delete(e);
93
+ p.get(e) === D && p.delete(e);
91
94
  }
92
95
  }
96
+ o(u.get(e) || {});
93
97
  }
94
- async function U() {
95
- const t = s, e = new Set(d.get(t) || n.codes);
96
- S(), w(t), d.set(t, e), await o(!0);
98
+ async function E() {
99
+ const t = a, e = new Set(d.get(t) || n.codes);
100
+ S(), m(t), d.set(t, e), await c(!0);
97
101
  }
98
- function O(t) {
99
- const e = g.get(t);
102
+ function A(t) {
103
+ const e = f.get(t);
100
104
  if (e) return e;
101
- const r = Promise.resolve().then(() => o());
102
- return g.set(t, r), r.finally(() => {
103
- g.get(t) === r && g.delete(t);
105
+ const r = Promise.resolve().then(() => c());
106
+ return f.set(t, r), r.finally(() => {
107
+ f.get(t) === r && f.delete(t);
104
108
  }), r;
105
109
  }
106
- k(() => {
107
- const t = R(n.dataSource);
108
- t && c({ ...u.get(s) || {}, ...t });
110
+ W(() => {
111
+ const t = U(n.dataSource);
112
+ t && o({ ...u.get(a) || {}, ...t });
109
113
  });
110
- function b(t) {
111
- c(u.get(t));
114
+ function z(t) {
115
+ o(u.get(t));
112
116
  }
113
- return p(s), O(s).then(() => b(s)), {
117
+ return h(a), A(a).then(() => z(a)), {
114
118
  /**
115
119
  * 数据源
116
120
  */
117
- dataSource: B(() => {
121
+ dataSource: G(() => {
118
122
  const t = n.codes.reduce(
119
123
  (e, r) => {
120
124
  const l = i.value[r] || [];
121
- return e[r] = D(r) ? [G, ...l] : l, e;
125
+ return e[r] = y(r) ? [Q, ...l] : l, e;
122
126
  },
123
127
  {}
124
128
  );
@@ -134,9 +138,9 @@ function K(n) {
134
138
  /**
135
139
  * @description 清空所有缓存,重新请求
136
140
  */
137
- reload: U
141
+ reload: E
138
142
  };
139
143
  }
140
144
  export {
141
- K as useDataPermissionOptions
145
+ re as useDataPermissionOptions
142
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.6.23",
3
+ "version": "1.6.24",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",