@hkyhy/marsun-components-core 0.1.127 → 0.1.129

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,328 +1,370 @@
1
- import { jsxs as u, jsx as r } from "react/jsx-runtime";
2
- import { notification as fe, Button as H, Badge as xe, Drawer as Ce, Space as pe, Checkbox as Z, message as ye } from "antd";
3
- import B from "classnames";
4
- import { forwardRef as Pe, useState as m, useRef as g, useMemo as ge, useCallback as k, useImperativeHandle as Re, useEffect as h } from "react";
5
- import { sanitizeInboxHtml as De } from "../sanitizeInboxHtml.js";
6
- import { INBOX_BADGE_REFRESH_EVENT as he } from "../requestInboxBadgeRefresh.js";
7
- import { emphasizeQuoted as F } from "./emphasizeQuoted.js";
8
- import { filterInboxActionsForHost as _e, resolveInboxItemActions as Ae, isInboxButtonDriven as Me } from "./inboxItemActions.js";
9
- import { inboxSceneLabel as bt, isTerminalActionStatus as Tt, normalizeInboxActions as wt, resolveInboxSceneKey as Nt } from "./inboxItemActions.js";
10
- import { loadInboxToastPrefs as Ie, shouldToastForMessageType as Oe, saveInboxToastPrefs as He } from "./toastPrefs.js";
11
- import { DEFAULT_INBOX_TOAST_PREFS as St } from "./toastPrefs.js";
12
- import n from "./style.module.scss.js";
13
- import U, { SEMANTIC_COLORS as R } from "../../../Tag/SemanticTag.js";
14
- import { Bell as Fe } from "../../../Icons/Bell.js";
15
- import Ue from "../../../StateBar/StateBar.js";
16
- import ze from "../../../SegmentedRadio/SegmentedRadio.js";
17
- import Ge from "../../../Layout/PageSpin/index.js";
18
- import Ke from "../../../Empty/Empty.js";
19
- import $e from "../../../VirtualScrollbar/VirtualScrollbar/index.js";
20
- const je = [
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { notification as Me, Badge as Oe, Button as z, Drawer as Ie, Space as Te, Checkbox as ne, message as be } from "antd";
3
+ import P from "classnames";
4
+ import { forwardRef as He, useState as y, useRef as h, useMemo as we, useCallback as N, useImperativeHandle as Fe, useEffect as T } from "react";
5
+ import { createPortal as Ue } from "react-dom";
6
+ import { sanitizeInboxHtml as ze } from "../sanitizeInboxHtml.js";
7
+ import { INBOX_BADGE_REFRESH_EVENT as Ne } from "../requestInboxBadgeRefresh.js";
8
+ import { emphasizeQuoted as re } from "./emphasizeQuoted.js";
9
+ import { filterInboxActionsForHost as Ge, resolveInboxItemActions as Ke, isInboxButtonDriven as $e } from "./inboxItemActions.js";
10
+ import { inboxSceneLabel as Pt, isTerminalActionStatus as Rt, normalizeInboxActions as _t, resolveInboxSceneKey as At } from "./inboxItemActions.js";
11
+ import { loadInboxToastPrefs as je, shouldToastForMessageType as Ve, saveInboxToastPrefs as We } from "./toastPrefs.js";
12
+ import { DEFAULT_INBOX_TOAST_PREFS as Mt } from "./toastPrefs.js";
13
+ import r from "./style.module.scss.js";
14
+ import { Bell as Qe } from "../../../Icons/Bell.js";
15
+ import oe, { SEMANTIC_COLORS as D } from "../../../Tag/SemanticTag.js";
16
+ import Xe from "../../../StateBar/StateBar.js";
17
+ import Ye from "../../../SegmentedRadio/SegmentedRadio.js";
18
+ import Je from "../../../Layout/PageSpin/index.js";
19
+ import qe from "../../../Empty/Empty.js";
20
+ import Ze from "../../../VirtualScrollbar/VirtualScrollbar/index.js";
21
+ const et = 6e3, tt = [
21
22
  { key: "", label: "全部" },
22
23
  { key: "alert", label: "预警" },
23
24
  { key: "action", label: "行动" },
24
25
  { key: "remind", label: "提醒" }
25
- ], Ve = {
26
+ ], nt = {
26
27
  alert: "预警",
27
28
  action: "行动",
28
29
  remind: "提醒"
29
- }, We = 300, Qe = 1500, Xe = 72;
30
- function ve(d) {
31
- const s = String(d || "").trim().toLowerCase();
32
- return s ? Ve[s] || s : "";
30
+ }, rt = 300, ot = 1500, at = 72;
31
+ function Ee(d) {
32
+ const a = String(d || "").trim().toLowerCase();
33
+ return a ? nt[a] || a : "";
33
34
  }
34
- function ee(d) {
35
- const s = String(d || "").trim().toLowerCase();
36
- return s === "alert" ? R.DANGER : s === "action" ? R.PRIMARY : s === "remind" ? R.WARNING : R.DEFAULT;
35
+ function Se(d) {
36
+ const a = String(d || "").trim().toLowerCase();
37
+ return a === "alert" ? D.DANGER : a === "action" ? D.PRIMARY : a === "remind" ? D.WARNING : D.DEFAULT;
37
38
  }
38
- function Ye(d) {
39
- return [d.factory, d.variety, d.metric].map((s) => String(s || "").trim()).filter(Boolean).join(" · ");
39
+ function lt(d) {
40
+ return [d.factory, d.variety, d.metric].map((a) => String(a || "").trim()).filter(Boolean).join(" · ");
40
41
  }
41
- function Je(d) {
42
- return String(d || "").trim() || R.DEFAULT;
42
+ function st(d) {
43
+ return String(d || "").trim() || D.DEFAULT;
43
44
  }
44
- function qe(d) {
45
+ function it(d) {
45
46
  try {
46
- const s = JSON.parse(d);
47
- if (!s || typeof s != "object") return null;
48
- const D = String(s.messageType || s.message_type || "").trim(), x = String(s.title || "").trim(), E = String(s.summary || "").trim();
49
- return !D && !x && !E ? null : {
50
- messageType: D || void 0,
51
- title: x || void 0,
52
- summary: E || void 0
47
+ const a = JSON.parse(d);
48
+ if (!a || typeof a != "object") return null;
49
+ const M = String(a.messageType || a.message_type || "").trim(), R = String(a.title || "").trim(), B = String(a.summary || "").trim();
50
+ return !M && !R && !B ? null : {
51
+ messageType: M || void 0,
52
+ title: R || void 0,
53
+ summary: B || void 0
53
54
  };
54
55
  } catch {
55
56
  return null;
56
57
  }
57
58
  }
58
- const gt = Pe(function({
59
- fetchInbox: s,
60
- markRead: D,
61
- onNavigate: x,
62
- pollMs: E = 0,
63
- locationKey: te,
64
- pageSize: v = 20,
65
- className: be,
66
- title: Te = "站内信",
67
- streamPath: z = "/api/v1/msg-center/inbox/stream",
68
- getAccessToken: G,
69
- onItemAction: ne
70
- }, we) {
71
- const [K, S] = m(!1), [re, ae] = m(!1), [$, oe] = m(""), [_, A] = m([]), [C, M] = m(0), [se, j] = m({}), [V, Ne] = m(""), [I, Ee] = m("all"), [P, Se] = m(() => Ie()), [Le, le] = m(!1), b = g(null), T = g(null), W = g(null), ie = g(!1), ce = g(P);
72
- ce.current = P;
73
- const Q = g(1), X = g(!1), L = g(!1), O = ge(
59
+ const Bt = He(function({
60
+ fetchInbox: a,
61
+ markRead: M,
62
+ onNavigate: R,
63
+ pollMs: B = 0,
64
+ locationKey: ae,
65
+ pageSize: E = 20,
66
+ className: Le,
67
+ title: ke = "站内信",
68
+ streamPath: G = "/api/v1/msg-center/inbox/stream",
69
+ getAccessToken: K,
70
+ onItemAction: le
71
+ }, Be) {
72
+ const [$, x] = y(!1), [se, ie] = y(!1), [j, ce] = y(""), [O, I] = y([]), [_, H] = y(0), [de, V] = y({}), [W, xe] = y(""), [F, Ce] = y("all"), [A, Pe] = y(() => je()), [Re, ue] = y(!1), [b, Q] = y(null), S = h(null), L = h(null), X = h(null), f = h(null), me = h(!1), fe = h(A);
73
+ fe.current = A;
74
+ const Y = h(1), J = h(!1), C = h(!1), U = we(
74
75
  () => ({
75
- messageType: V || void 0,
76
- unreadOnly: I === "unread" || void 0,
77
- readOnly: I === "read" || void 0
76
+ messageType: W || void 0,
77
+ unreadOnly: F === "unread" || void 0,
78
+ readOnly: F === "read" || void 0
78
79
  }),
79
- [V, I]
80
- ), Y = k(async () => {
81
- ae(!0), oe(""), Q.current = 1, L.current = !1;
80
+ [W, F]
81
+ ), q = N(async () => {
82
+ ie(!0), ce(""), Y.current = 1, C.current = !1;
82
83
  try {
83
- const e = await s({
84
+ const e = await a({
84
85
  currentPage: 1,
85
- pageSize: v,
86
- ...O
87
- }), t = (e == null ? void 0 : e.pageData) || [], o = typeof (e == null ? void 0 : e.total) == "number" ? e.total : t.length;
88
- A(t), L.current = t.length > 0 && t.length < o, M(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), j((e == null ? void 0 : e.unreadByMessageType) || {});
86
+ pageSize: E,
87
+ ...U
88
+ }), t = (e == null ? void 0 : e.pageData) || [], n = typeof (e == null ? void 0 : e.total) == "number" ? e.total : t.length;
89
+ I(t), C.current = t.length > 0 && t.length < n, H(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
89
90
  } catch (e) {
90
- A([]), L.current = !1, oe(e instanceof Error ? e.message : String(e));
91
+ I([]), C.current = !1, ce(e instanceof Error ? e.message : String(e));
91
92
  } finally {
92
- ae(!1);
93
+ ie(!1);
93
94
  }
94
- }, [s, v, O]), de = k(async () => {
95
- if (!(X.current || !L.current)) {
96
- X.current = !0, le(!0);
95
+ }, [a, E, U]), pe = N(async () => {
96
+ if (!(J.current || !C.current)) {
97
+ J.current = !0, ue(!0);
97
98
  try {
98
- const e = Q.current + 1, t = await s({
99
+ const e = Y.current + 1, t = await a({
99
100
  currentPage: e,
100
- pageSize: v,
101
- ...O
102
- }), o = (t == null ? void 0 : t.pageData) || [], a = typeof (t == null ? void 0 : t.total) == "number" ? t.total : 0;
103
- A((l) => {
104
- const c = new Set(l.map((y) => y.id)), i = o.filter((y) => (y == null ? void 0 : y.id) && !c.has(y.id)), w = i.length ? [...l, ...i] : l;
105
- return L.current = i.length > 0 && (a > 0 ? w.length < a : i.length >= v), w;
106
- }), o.length && (Q.current = e), typeof (t == null ? void 0 : t.unreadTotal) == "number" && M(t.unreadTotal), t != null && t.unreadByMessageType && j(t.unreadByMessageType);
101
+ pageSize: E,
102
+ ...U
103
+ }), n = (t == null ? void 0 : t.pageData) || [], l = typeof (t == null ? void 0 : t.total) == "number" ? t.total : 0;
104
+ I((i) => {
105
+ const s = new Set(i.map((p) => p.id)), u = n.filter((p) => (p == null ? void 0 : p.id) && !s.has(p.id)), v = u.length ? [...i, ...u] : i;
106
+ return C.current = u.length > 0 && (l > 0 ? v.length < l : u.length >= E), v;
107
+ }), n.length && (Y.current = e), typeof (t == null ? void 0 : t.unreadTotal) == "number" && H(t.unreadTotal), t != null && t.unreadByMessageType && V(t.unreadByMessageType);
107
108
  } catch {
108
- L.current = !1;
109
+ C.current = !1;
109
110
  } finally {
110
- X.current = !1, le(!1);
111
+ J.current = !1, ue(!1);
111
112
  }
112
113
  }
113
- }, [s, v, O]), Be = k(
114
+ }, [a, E, U]), _e = N(
114
115
  (e) => {
115
116
  const t = e.currentTarget;
116
- t.scrollHeight - t.scrollTop - t.clientHeight <= Xe && de();
117
+ t.scrollHeight - t.scrollTop - t.clientHeight <= at && pe();
117
118
  },
118
- [de]
119
- ), f = k(async () => {
119
+ [pe]
120
+ ), g = N(async () => {
120
121
  try {
121
- const e = await s({ currentPage: 1, pageSize: v });
122
- M(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), j((e == null ? void 0 : e.unreadByMessageType) || {});
122
+ const e = await a({ currentPage: 1, pageSize: E });
123
+ H(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
123
124
  } catch {
124
125
  }
125
- }, [s, v]), ue = k(() => {
126
- const e = W.current;
127
- if (W.current = null, !e || !Oe(ce.current, e.messageType)) return;
128
- const t = e.title || "新站内信", o = e.summary || "", a = ve(e.messageType), l = () => {
129
- fe.destroy(), S(!0);
130
- }, c = `inbox-badge-${e.messageType || "msg"}-${Date.now()}`;
131
- fe.open({
132
- key: c,
133
- className: B("marsun-inbox-toast", n.toastNotice),
134
- closable: !0,
135
- title: /* @__PURE__ */ u("div", { className: n.toastHead, children: [
136
- /* @__PURE__ */ r("span", { className: n.toastTitle, children: F(t) }),
137
- a ? /* @__PURE__ */ r(
138
- U,
139
- {
140
- color: ee(e.messageType),
141
- className: n.typeTag,
142
- children: a
143
- }
144
- ) : null
145
- ] }),
146
- message: /* @__PURE__ */ u("div", { className: n.toastHead, children: [
147
- /* @__PURE__ */ r("span", { className: n.toastTitle, children: F(t) }),
148
- a ? /* @__PURE__ */ r(
149
- U,
150
- {
151
- color: ee(e.messageType),
152
- className: n.typeTag,
153
- children: a
154
- }
155
- ) : null
156
- ] }),
157
- description: /* @__PURE__ */ u("div", { className: n.toastBody, children: [
158
- o ? /* @__PURE__ */ r("div", { className: n.toastDesc, children: F(o) }) : null,
159
- /* @__PURE__ */ r("div", { className: n.toastActions, children: /* @__PURE__ */ r(
160
- H,
161
- {
162
- type: "primary",
163
- size: "small",
164
- onClick: (i) => {
165
- i.stopPropagation(), l();
166
- },
167
- children: "查看"
168
- }
169
- ) })
170
- ] }),
171
- placement: "topRight",
172
- duration: 6,
173
- onClick: l
174
- });
175
- }, []), p = k(
126
+ }, [a, E]), Z = N(() => {
127
+ f.current != null && (window.clearTimeout(f.current), f.current = null), Q(null);
128
+ }, []), ye = N(() => {
129
+ Z(), x(!0);
130
+ }, [Z]), ge = N(() => {
131
+ const e = X.current;
132
+ if (X.current = null, !e || !Ve(fe.current, e.messageType)) return;
133
+ f.current != null && (window.clearTimeout(f.current), f.current = null);
134
+ const t = `inbox-badge-${e.messageType || "msg"}-${Date.now()}`;
135
+ Q({
136
+ key: t,
137
+ title: e.title || "新站内信",
138
+ summary: e.summary || "",
139
+ messageType: e.messageType
140
+ }), f.current = window.setTimeout(() => {
141
+ f.current = null, Q(null);
142
+ }, et);
143
+ }, []), w = N(
176
144
  (e) => {
177
- e && (W.current = e), T.current != null && window.clearTimeout(T.current), T.current = window.setTimeout(() => {
178
- T.current = null, f(), ue();
179
- }, Qe);
145
+ e && (X.current = e, ge()), L.current != null && window.clearTimeout(L.current), L.current = window.setTimeout(() => {
146
+ L.current = null, g();
147
+ }, ot);
180
148
  },
181
- [f, ue]
149
+ [g, ge]
182
150
  );
183
- Re(we, () => ({ refreshBadge: f }), [f]), h(() => {
184
- f();
185
- }, [f]), h(() => {
186
- if (te !== void 0) {
187
- if (!ie.current) {
188
- ie.current = !0;
151
+ Fe(Be, () => ({ refreshBadge: g }), [g]), T(() => {
152
+ g();
153
+ }, [g]), T(() => {
154
+ if (ae !== void 0) {
155
+ if (!me.current) {
156
+ me.current = !0;
189
157
  return;
190
158
  }
191
- p();
159
+ w();
192
160
  }
193
- }, [te, p]), h(() => {
194
- if (E <= 0) return;
161
+ }, [ae, w]), T(() => {
162
+ if (B <= 0) return;
195
163
  const e = window.setInterval(() => {
196
- f();
197
- }, E);
164
+ g();
165
+ }, B);
198
166
  return () => window.clearInterval(e);
199
- }, [E, f]), h(() => {
167
+ }, [B, g]), T(() => {
200
168
  const e = () => {
201
- b.current != null && window.clearTimeout(b.current), b.current = window.setTimeout(() => {
202
- b.current = null, p();
203
- }, We);
169
+ S.current != null && window.clearTimeout(S.current), S.current = window.setTimeout(() => {
170
+ S.current = null, w();
171
+ }, rt);
204
172
  }, t = () => {
205
173
  document.visibilityState === "visible" && e();
206
174
  };
207
175
  return window.addEventListener("focus", e), document.addEventListener("visibilitychange", t), () => {
208
- window.removeEventListener("focus", e), document.removeEventListener("visibilitychange", t), b.current != null && (window.clearTimeout(b.current), b.current = null);
176
+ window.removeEventListener("focus", e), document.removeEventListener("visibilitychange", t), S.current != null && (window.clearTimeout(S.current), S.current = null);
209
177
  };
210
- }, [p]), h(() => {
211
- const e = () => {
212
- p();
178
+ }, [w]), T(() => {
179
+ const e = (t) => {
180
+ const n = t.detail;
181
+ w((n == null ? void 0 : n.preview) || void 0);
213
182
  };
214
- return window.addEventListener(he, e), () => window.removeEventListener(he, e);
215
- }, [p]), h(() => () => {
216
- T.current != null && (window.clearTimeout(T.current), T.current = null);
217
- }, []), h(() => {
218
- if (z === !1 || typeof G != "function" || typeof window > "u" || typeof EventSource > "u") return;
219
- const e = String(G() || "").trim();
220
- if (!e) return;
221
- const t = String(z || "/api/v1/msg-center/inbox/stream").trim(), o = new URL(t, window.location.origin);
222
- o.searchParams.set("access_token", e);
223
- let a;
224
- try {
225
- a = new EventSource(o.toString());
226
- } catch {
227
- return;
228
- }
229
- const l = (c) => {
230
- const i = c, w = typeof (i == null ? void 0 : i.data) == "string" ? qe(i.data) : null;
231
- p(w);
183
+ return window.addEventListener(Ne, e), () => window.removeEventListener(Ne, e);
184
+ }, [w]), T(() => {
185
+ Me.destroy();
186
+ }, []), T(() => () => {
187
+ L.current != null && (window.clearTimeout(L.current), L.current = null), f.current != null && (window.clearTimeout(f.current), f.current = null);
188
+ }, []), T(() => {
189
+ if (G === !1 || typeof K != "function" || typeof window > "u" || typeof EventSource > "u") return;
190
+ const e = String(G || "/api/v1/msg-center/inbox/stream").trim();
191
+ let t = !1, n = null, l = null, i = 0;
192
+ const s = (c) => {
193
+ const k = c, De = typeof (k == null ? void 0 : k.data) == "string" ? it(k.data) : null;
194
+ w(De);
195
+ }, u = () => {
196
+ l != null && (window.clearTimeout(l), l = null);
197
+ }, v = () => {
198
+ if (t || l != null) return;
199
+ const c = Math.min(3e4, 1e3 * 2 ** Math.min(i, 5));
200
+ i += 1, l = window.setTimeout(() => {
201
+ l = null, p();
202
+ }, c);
203
+ }, p = () => {
204
+ if (t) return;
205
+ const c = String(K() || "").trim();
206
+ if (!c) {
207
+ v();
208
+ return;
209
+ }
210
+ n && (n.removeEventListener("badge", s), n.removeEventListener("inbox", s), n.close(), n = null);
211
+ const k = new URL(e, window.location.origin);
212
+ k.searchParams.set("access_token", c);
213
+ try {
214
+ n = new EventSource(k.toString());
215
+ } catch {
216
+ v();
217
+ return;
218
+ }
219
+ n.addEventListener("badge", s), n.addEventListener("inbox", s), n.onopen = () => {
220
+ i = 0;
221
+ }, n.onerror = () => {
222
+ t || (n == null || n.close(), n = null, v());
223
+ };
232
224
  };
233
- return a.addEventListener("badge", l), a.addEventListener("inbox", l), a.onerror = () => {
234
- a.close();
235
- }, () => {
236
- a.removeEventListener("badge", l), a.removeEventListener("inbox", l), a.close();
225
+ return p(), () => {
226
+ t = !0, u(), n && (n.removeEventListener("badge", s), n.removeEventListener("inbox", s), n.close(), n = null);
237
227
  };
238
- }, [z, G, p]), h(() => {
239
- K && Y();
240
- }, [K, Y]);
241
- const ke = ge(
242
- () => je.map((e) => {
243
- const t = e.key ? se[e.key] || 0 : C;
228
+ }, [G, K, w]), T(() => {
229
+ $ && q();
230
+ }, [$, q]);
231
+ const Ae = we(
232
+ () => tt.map((e) => {
233
+ const t = e.key ? de[e.key] || 0 : _;
244
234
  return {
245
235
  key: e.key || "all",
246
236
  label: t > 0 ? `${e.label} (${t})` : e.label
247
237
  };
248
238
  }),
249
- [se, C]
250
- ), J = (e, t) => {
251
- Se((o) => {
252
- const a = { ...o, [e]: t };
253
- return He(a), a;
239
+ [de, _]
240
+ ), ee = (e, t) => {
241
+ Pe((n) => {
242
+ const l = { ...n, [e]: t };
243
+ return We(l), l;
254
244
  });
255
- }, q = async (e, t) => {
245
+ }, te = async (e, t) => {
256
246
  if (!e.read)
257
247
  try {
258
- await D(e.id), A((a) => a.map((l) => l.id === e.id ? { ...l, read: !0 } : l)), M((a) => Math.max(0, a - 1));
259
- } catch (a) {
260
- ye.error(a instanceof Error ? a.message : "标记已读失败");
248
+ await M(e.id), I((l) => l.map((i) => i.id === e.id ? { ...i, read: !0 } : i)), H((l) => Math.max(0, l - 1));
249
+ } catch (l) {
250
+ be.error(l instanceof Error ? l.message : "标记已读失败");
261
251
  return;
262
252
  }
263
- const o = String(e.href || "").trim();
264
- if (o) {
265
- if (x) {
266
- x(o, e), S(!1);
253
+ const n = String(e.href || "").trim();
254
+ if (n) {
255
+ if (R) {
256
+ R(n, e), x(!1);
267
257
  return;
268
258
  }
269
- o.startsWith("http://") || o.startsWith("https://") ? window.open(o, "_blank", "noopener,noreferrer") : window.location.assign(o), S(!1);
259
+ n.startsWith("http://") || n.startsWith("https://") ? window.open(n, "_blank", "noopener,noreferrer") : window.location.assign(n), x(!1);
270
260
  }
271
- }, me = async (e, t) => {
261
+ }, ve = async (e, t) => {
272
262
  if (!t.disabled) {
273
- if (ne) {
263
+ if (le) {
274
264
  try {
275
- await ne(t.kind, e), S(!1), Y(), f();
276
- } catch (o) {
277
- ye.error(o instanceof Error ? o.message : "操作失败");
265
+ await le(t.kind, e), x(!1), q(), g();
266
+ } catch (n) {
267
+ be.error(n instanceof Error ? n.message : "操作失败");
278
268
  }
279
269
  return;
280
270
  }
281
- await q(e);
271
+ await te(e);
282
272
  }
283
- };
284
- return /* @__PURE__ */ u("div", { className: B(n.bellWrap, be), children: [
285
- /* @__PURE__ */ r(xe, { count: C, size: "small", overflowCount: 99, offset: [-4, 4], children: /* @__PURE__ */ r(
286
- H,
273
+ }, he = b ? Ee(b.messageType) : "";
274
+ return /* @__PURE__ */ m("div", { className: P(r.bellWrap, Le), children: [
275
+ /* @__PURE__ */ o(Oe, { count: _, size: "small", overflowCount: 99, offset: [-4, 4], children: /* @__PURE__ */ o(
276
+ z,
287
277
  {
288
278
  type: "text",
289
- className: n.bellBtn,
290
- icon: /* @__PURE__ */ r(Fe, { size: 16, "aria-hidden": !0 }),
291
- "aria-label": C > 0 ? `站内信,${C} 条未读` : "站内信",
292
- onClick: () => S(!0)
279
+ className: r.bellBtn,
280
+ icon: /* @__PURE__ */ o(Qe, { size: 16, "aria-hidden": !0 }),
281
+ "aria-label": _ > 0 ? `站内信,${_} 条未读` : "站内信",
282
+ onClick: () => x(!0)
293
283
  }
294
284
  ) }),
295
- /* @__PURE__ */ u(
296
- Ce,
285
+ b && typeof document < "u" ? Ue(
286
+ /* @__PURE__ */ o("div", { className: r.toastHost, "data-testid": "inbox-live-toast-host", children: /* @__PURE__ */ m(
287
+ "div",
288
+ {
289
+ className: P("marsun-inbox-toast", r.toastNotice),
290
+ role: "alert",
291
+ "data-testid": "inbox-live-toast",
292
+ onClick: ye,
293
+ children: [
294
+ /* @__PURE__ */ o(
295
+ "button",
296
+ {
297
+ type: "button",
298
+ className: r.toastClose,
299
+ "aria-label": "关闭",
300
+ onClick: (e) => {
301
+ e.stopPropagation(), Z();
302
+ },
303
+ children: "×"
304
+ }
305
+ ),
306
+ /* @__PURE__ */ m("div", { className: r.toastHead, children: [
307
+ /* @__PURE__ */ o("span", { className: r.toastTitle, children: re(b.title) }),
308
+ he ? /* @__PURE__ */ o(
309
+ oe,
310
+ {
311
+ color: Se(b.messageType),
312
+ className: r.typeTag,
313
+ children: he
314
+ }
315
+ ) : null
316
+ ] }),
317
+ /* @__PURE__ */ m("div", { className: r.toastBody, children: [
318
+ b.summary ? /* @__PURE__ */ o("div", { className: r.toastDesc, children: re(b.summary) }) : null,
319
+ /* @__PURE__ */ o("div", { className: r.toastActions, children: /* @__PURE__ */ o(
320
+ z,
321
+ {
322
+ type: "primary",
323
+ size: "small",
324
+ onClick: (e) => {
325
+ e.stopPropagation(), ye();
326
+ },
327
+ children: "查看"
328
+ }
329
+ ) })
330
+ ] })
331
+ ]
332
+ },
333
+ b.key
334
+ ) }),
335
+ document.body
336
+ ) : null,
337
+ /* @__PURE__ */ m(
338
+ Ie,
297
339
  {
298
- title: Te,
299
- open: K,
300
- onClose: () => S(!1),
340
+ title: ke,
341
+ open: $,
342
+ onClose: () => x(!1),
301
343
  size: 420,
302
344
  destroyOnClose: !1,
303
- className: n.drawer,
345
+ className: r.drawer,
304
346
  styles: {
305
347
  header: { padding: "12px 16px" },
306
348
  body: { padding: "12px 16px" }
307
349
  },
308
350
  children: [
309
- /* @__PURE__ */ r(
310
- Ue,
351
+ /* @__PURE__ */ o(
352
+ Xe,
311
353
  {
312
- className: n.typeTabs,
354
+ className: r.typeTabs,
313
355
  size: "small",
314
- activeKey: V || "all",
315
- onChange: (e) => Ne(e === "all" ? "" : e),
316
- stateOption: ke,
356
+ activeKey: W || "all",
357
+ onChange: (e) => xe(e === "all" ? "" : e),
358
+ stateOption: Ae,
317
359
  isInner: !0
318
360
  }
319
361
  ),
320
- /* @__PURE__ */ r("div", { className: n.filterRow, children: /* @__PURE__ */ r(
321
- ze,
362
+ /* @__PURE__ */ o("div", { className: r.filterRow, children: /* @__PURE__ */ o(
363
+ Ye,
322
364
  {
323
365
  size: "small",
324
- value: I,
325
- onChange: (e) => Ee(e),
366
+ value: F,
367
+ onChange: (e) => Ce(e),
326
368
  options: [
327
369
  { value: "all", label: "全部" },
328
370
  { value: "unread", label: "未读" },
@@ -330,117 +372,117 @@ const gt = Pe(function({
330
372
  ]
331
373
  }
332
374
  ) }),
333
- /* @__PURE__ */ u("div", { className: n.toastPrefs, "data-testid": "inbox-toast-prefs", children: [
334
- /* @__PURE__ */ r("div", { className: n.toastPrefsTitle, children: "消息提示" }),
335
- /* @__PURE__ */ r("p", { className: n.toastPrefsHint, children: "本机浏览器偏好,非租户策略" }),
336
- /* @__PURE__ */ u(pe, { size: 12, wrap: !0, children: [
337
- /* @__PURE__ */ r(
338
- Z,
375
+ /* @__PURE__ */ m("div", { className: r.toastPrefs, "data-testid": "inbox-toast-prefs", children: [
376
+ /* @__PURE__ */ o("div", { className: r.toastPrefsTitle, children: "消息提示" }),
377
+ /* @__PURE__ */ o("p", { className: r.toastPrefsHint, children: "本机浏览器偏好,非租户策略" }),
378
+ /* @__PURE__ */ m(Te, { size: 12, wrap: !0, children: [
379
+ /* @__PURE__ */ o(
380
+ ne,
339
381
  {
340
- checked: P.alert,
341
- onChange: (e) => J("alert", e.target.checked),
382
+ checked: A.alert,
383
+ onChange: (e) => ee("alert", e.target.checked),
342
384
  children: "预警弹出"
343
385
  }
344
386
  ),
345
- /* @__PURE__ */ r(
346
- Z,
387
+ /* @__PURE__ */ o(
388
+ ne,
347
389
  {
348
- checked: P.action,
349
- onChange: (e) => J("action", e.target.checked),
390
+ checked: A.action,
391
+ onChange: (e) => ee("action", e.target.checked),
350
392
  children: "行动弹出"
351
393
  }
352
394
  ),
353
- /* @__PURE__ */ r(
354
- Z,
395
+ /* @__PURE__ */ o(
396
+ ne,
355
397
  {
356
- checked: P.remind,
357
- onChange: (e) => J("remind", e.target.checked),
398
+ checked: A.remind,
399
+ onChange: (e) => ee("remind", e.target.checked),
358
400
  children: "提醒弹出"
359
401
  }
360
402
  )
361
403
  ] })
362
404
  ] }),
363
- $ ? /* @__PURE__ */ r("p", { className: n.error, children: $ }) : null,
364
- /* @__PURE__ */ r("div", { className: B("inbox-bell-list-pane", n.listPane), children: /* @__PURE__ */ r(Ge, { spinning: re && _.length === 0, children: !re && !$ && _.length === 0 ? /* @__PURE__ */ r(Ke, { description: "暂无站内信" }) : _.length === 0 ? null : /* @__PURE__ */ u(
365
- $e,
405
+ j ? /* @__PURE__ */ o("p", { className: r.error, children: j }) : null,
406
+ /* @__PURE__ */ o("div", { className: P("inbox-bell-list-pane", r.listPane), children: /* @__PURE__ */ o(Je, { spinning: se && O.length === 0, children: !se && !j && O.length === 0 ? /* @__PURE__ */ o(qe, { description: "暂无站内信" }) : O.length === 0 ? null : /* @__PURE__ */ m(
407
+ Ze,
366
408
  {
367
- wrapperClassName: B("inbox-bell-list-scroll", n.listScroll),
368
- className: n.listViewport,
409
+ wrapperClassName: P("inbox-bell-list-scroll", r.listScroll),
410
+ className: r.listViewport,
369
411
  "data-testid": "inbox-bell-list-scroll",
370
- onScroll: Be,
412
+ onScroll: _e,
371
413
  children: [
372
- /* @__PURE__ */ r("ul", { className: n.list, children: _.map((e) => {
373
- const t = ve(e.messageType), o = String(e.levelLabel || e.level || "").trim(), a = !!o, l = De(e.bodyHtml), c = _e(
374
- Ae(e)
375
- ), i = Me(e), w = Ye(e), y = !!c.primary;
376
- return /* @__PURE__ */ r("li", { children: /* @__PURE__ */ u(
414
+ /* @__PURE__ */ o("ul", { className: r.list, children: O.map((e) => {
415
+ const t = Ee(e.messageType), n = String(e.levelLabel || e.level || "").trim(), l = !!n, i = ze(e.bodyHtml), s = Ge(
416
+ Ke(e)
417
+ ), u = $e(e), v = lt(e), p = !!s.primary;
418
+ return /* @__PURE__ */ o("li", { children: /* @__PURE__ */ m(
377
419
  "div",
378
420
  {
379
- className: B(
380
- n.item,
381
- !e.read && n.itemUnread,
382
- i && n.itemStatic
421
+ className: P(
422
+ r.item,
423
+ !e.read && r.itemUnread,
424
+ u && r.itemStatic
383
425
  ),
384
- role: i ? void 0 : "button",
385
- tabIndex: i ? void 0 : 0,
386
- onClick: i ? void 0 : () => void q(e),
387
- onKeyDown: i ? void 0 : (N) => {
388
- (N.key === "Enter" || N.key === " ") && (N.preventDefault(), q(e));
426
+ role: u ? void 0 : "button",
427
+ tabIndex: u ? void 0 : 0,
428
+ onClick: u ? void 0 : () => void te(e),
429
+ onKeyDown: u ? void 0 : (c) => {
430
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), te(e));
389
431
  },
390
432
  children: [
391
- /* @__PURE__ */ u("div", { className: n.itemHeader, children: [
392
- /* @__PURE__ */ u("span", { className: n.itemHeaderLeft, children: [
393
- /* @__PURE__ */ r("span", { className: n.itemTitle, title: e.title || "(无标题)", children: e.title || "(无标题)" }),
394
- t ? /* @__PURE__ */ r(
395
- U,
433
+ /* @__PURE__ */ m("div", { className: r.itemHeader, children: [
434
+ /* @__PURE__ */ m("span", { className: r.itemHeaderLeft, children: [
435
+ /* @__PURE__ */ o("span", { className: r.itemTitle, title: e.title || "(无标题)", children: e.title || "(无标题)" }),
436
+ t ? /* @__PURE__ */ o(
437
+ oe,
396
438
  {
397
- color: ee(e.messageType),
398
- className: n.typeTag,
439
+ color: Se(e.messageType),
440
+ className: r.typeTag,
399
441
  children: t
400
442
  }
401
443
  ) : null
402
444
  ] }),
403
- /* @__PURE__ */ r("span", { className: n.itemTime, children: e.createdAt || "" })
445
+ /* @__PURE__ */ o("span", { className: r.itemTime, children: e.createdAt || "" })
404
446
  ] }),
405
- /* @__PURE__ */ r("div", { className: n.itemBody, children: l ? /* @__PURE__ */ r(
447
+ /* @__PURE__ */ o("div", { className: r.itemBody, children: i ? /* @__PURE__ */ o(
406
448
  "div",
407
449
  {
408
- className: n.itemBodyHtml,
409
- dangerouslySetInnerHTML: { __html: l }
450
+ className: r.itemBodyHtml,
451
+ dangerouslySetInnerHTML: { __html: i }
410
452
  }
411
- ) : e.summary ? /* @__PURE__ */ r("span", { className: n.itemSummary, children: F(e.summary) }) : null }),
412
- w ? /* @__PURE__ */ r("span", { className: n.itemMeta, children: w }) : null,
413
- a ? /* @__PURE__ */ r("div", { className: n.itemFooterTags, children: /* @__PURE__ */ r(
414
- U,
453
+ ) : e.summary ? /* @__PURE__ */ o("span", { className: r.itemSummary, children: re(e.summary) }) : null }),
454
+ v ? /* @__PURE__ */ o("span", { className: r.itemMeta, children: v }) : null,
455
+ l ? /* @__PURE__ */ o("div", { className: r.itemFooterTags, children: /* @__PURE__ */ o(
456
+ oe,
415
457
  {
416
- color: Je(e.levelColor),
417
- className: n.typeTag,
418
- children: o
458
+ color: st(e.levelColor),
459
+ className: r.typeTag,
460
+ children: n
419
461
  }
420
462
  ) }) : null,
421
- y && c.primary ? /* @__PURE__ */ r(
463
+ p && s.primary ? /* @__PURE__ */ o(
422
464
  "div",
423
465
  {
424
- className: n.itemActions,
425
- onClick: (N) => N.stopPropagation(),
426
- onKeyDown: (N) => N.stopPropagation(),
427
- children: /* @__PURE__ */ u(pe, { size: 8, wrap: !0, children: [
428
- /* @__PURE__ */ r(
429
- H,
466
+ className: r.itemActions,
467
+ onClick: (c) => c.stopPropagation(),
468
+ onKeyDown: (c) => c.stopPropagation(),
469
+ children: /* @__PURE__ */ m(Te, { size: 8, wrap: !0, children: [
470
+ /* @__PURE__ */ o(
471
+ z,
430
472
  {
431
473
  size: "small",
432
474
  type: "primary",
433
- onClick: () => void me(e, c.primary),
434
- children: c.primary.label
475
+ onClick: () => void ve(e, s.primary),
476
+ children: s.primary.label
435
477
  }
436
478
  ),
437
- c.secondary ? /* @__PURE__ */ r(
438
- H,
479
+ s.secondary ? /* @__PURE__ */ o(
480
+ z,
439
481
  {
440
482
  size: "small",
441
483
  type: "link",
442
- onClick: () => void me(e, c.secondary),
443
- children: c.secondary.label
484
+ onClick: () => void ve(e, s.secondary),
485
+ children: s.secondary.label
444
486
  }
445
487
  ) : null
446
488
  ] })
@@ -450,7 +492,7 @@ const gt = Pe(function({
450
492
  }
451
493
  ) }, e.id);
452
494
  }) }),
453
- Le ? /* @__PURE__ */ r("p", { className: B("inbox-bell-list-footer", n.listFooter), children: "加载中…" }) : null
495
+ Re ? /* @__PURE__ */ o("p", { className: P("inbox-bell-list-footer", r.listFooter), children: "加载中…" }) : null
454
496
  ]
455
497
  }
456
498
  ) }) })
@@ -460,17 +502,17 @@ const gt = Pe(function({
460
502
  ] });
461
503
  });
462
504
  export {
463
- St as DEFAULT_INBOX_TOAST_PREFS,
464
- gt as default,
465
- _e as filterInboxActionsForHost,
466
- bt as inboxSceneLabel,
467
- Me as isInboxButtonDriven,
468
- Tt as isTerminalActionStatus,
469
- Ie as loadInboxToastPrefs,
470
- wt as normalizeInboxActions,
471
- Ae as resolveInboxItemActions,
472
- Nt as resolveInboxSceneKey,
473
- He as saveInboxToastPrefs,
474
- Oe as shouldToastForMessageType
505
+ Mt as DEFAULT_INBOX_TOAST_PREFS,
506
+ Bt as default,
507
+ Ge as filterInboxActionsForHost,
508
+ Pt as inboxSceneLabel,
509
+ $e as isInboxButtonDriven,
510
+ Rt as isTerminalActionStatus,
511
+ je as loadInboxToastPrefs,
512
+ _t as normalizeInboxActions,
513
+ Ke as resolveInboxItemActions,
514
+ At as resolveInboxSceneKey,
515
+ We as saveInboxToastPrefs,
516
+ Ve as shouldToastForMessageType
475
517
  };
476
518
  //# sourceMappingURL=InboxBell.js.map