@yuku123/z-mist-component 0.1.0 → 0.1.1

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.
@@ -0,0 +1,973 @@
1
+ import Re, { useState as i, useEffect as te } from "react";
2
+ import { useNavigate as _e, Routes as Ce, Route as B, Navigate as Se } from "react-router-dom";
3
+ import { Space as H, Input as S, Button as j, message as y, Table as re, Modal as $, Tag as F, Select as Y, Form as k, Card as ge, Switch as Oe } from "antd";
4
+ import { EyeInvisibleOutlined as Ie, EyeOutlined as ve, CopyOutlined as Ae, ReloadOutlined as ne, PlusOutlined as ae, EditOutlined as se, DeleteOutlined as le, ExclamationCircleOutlined as Pe, KeyOutlined as ze, SafetyOutlined as Ne } from "@ant-design/icons";
5
+ import { TableToolbar as ie, SearchInput as we, EmptyState as oe, ErrorState as Ee } from "@yuku123/z-frontend-common/ui";
6
+ import { request as O } from "@yuku123/z-frontend-common";
7
+ var X = { exports: {} }, G = {};
8
+ /**
9
+ * @license React
10
+ * react-jsx-runtime.production.js
11
+ *
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+ var xe;
18
+ function $e() {
19
+ if (xe) return G;
20
+ xe = 1;
21
+ var h = Symbol.for("react.transitional.element"), _ = Symbol.for("react.fragment");
22
+ function T(E, u, c) {
23
+ var g = null;
24
+ if (c !== void 0 && (g = "" + c), u.key !== void 0 && (g = "" + u.key), "key" in u) {
25
+ c = {};
26
+ for (var C in u)
27
+ C !== "key" && (c[C] = u[C]);
28
+ } else c = u;
29
+ return u = c.ref, {
30
+ $$typeof: h,
31
+ type: E,
32
+ key: g,
33
+ ref: u !== void 0 ? u : null,
34
+ props: c
35
+ };
36
+ }
37
+ return G.Fragment = _, G.jsx = T, G.jsxs = T, G;
38
+ }
39
+ var J = {};
40
+ /**
41
+ * @license React
42
+ * react-jsx-runtime.development.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */
49
+ var fe;
50
+ function De() {
51
+ return fe || (fe = 1, process.env.NODE_ENV !== "production" && (function() {
52
+ function h(t) {
53
+ if (t == null) return null;
54
+ if (typeof t == "function")
55
+ return t.$$typeof === ke ? null : t.displayName || t.name || null;
56
+ if (typeof t == "string") return t;
57
+ switch (t) {
58
+ case l:
59
+ return "Fragment";
60
+ case m:
61
+ return "Profiler";
62
+ case v:
63
+ return "StrictMode";
64
+ case V:
65
+ return "Suspense";
66
+ case q:
67
+ return "SuspenseList";
68
+ case o:
69
+ return "Activity";
70
+ case W:
71
+ return "ViewTransition";
72
+ }
73
+ if (typeof t == "object")
74
+ switch (typeof t.tag == "number" && console.error(
75
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
76
+ ), t.$$typeof) {
77
+ case s:
78
+ return "Portal";
79
+ case M:
80
+ return t.displayName || "Context";
81
+ case w:
82
+ return (t._context.displayName || "Context") + ".Consumer";
83
+ case K:
84
+ var a = t.render;
85
+ return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
86
+ case n:
87
+ return a = t.displayName || null, a !== null ? a : h(t.type) || "Memo";
88
+ case r:
89
+ a = t._payload, t = t._init;
90
+ try {
91
+ return h(t(a));
92
+ } catch {
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+ function _(t) {
98
+ return "" + t;
99
+ }
100
+ function T(t) {
101
+ try {
102
+ _(t);
103
+ var a = !1;
104
+ } catch {
105
+ a = !0;
106
+ }
107
+ if (a) {
108
+ a = console;
109
+ var d = a.error, x = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
110
+ return d.call(
111
+ a,
112
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
113
+ x
114
+ ), _(t);
115
+ }
116
+ }
117
+ function E(t) {
118
+ if (t === l) return "<>";
119
+ if (typeof t == "object" && t !== null && t.$$typeof === r)
120
+ return "<...>";
121
+ try {
122
+ var a = h(t);
123
+ return a ? "<" + a + ">" : "<...>";
124
+ } catch {
125
+ return "<...>";
126
+ }
127
+ }
128
+ function u() {
129
+ var t = Z.A;
130
+ return t === null ? null : t.getOwner();
131
+ }
132
+ function c() {
133
+ return Error("react-stack-top-frame");
134
+ }
135
+ function g(t) {
136
+ if (ce.call(t, "key")) {
137
+ var a = Object.getOwnPropertyDescriptor(t, "key").get;
138
+ if (a && a.isReactWarning) return !1;
139
+ }
140
+ return t.key !== void 0;
141
+ }
142
+ function C(t, a) {
143
+ function d() {
144
+ de || (de = !0, console.error(
145
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
146
+ a
147
+ ));
148
+ }
149
+ d.isReactWarning = !0, Object.defineProperty(t, "key", {
150
+ get: d,
151
+ configurable: !0
152
+ });
153
+ }
154
+ function I() {
155
+ var t = h(this.type);
156
+ return ue[t] || (ue[t] = !0, console.error(
157
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
158
+ )), t = this.props.ref, t !== void 0 ? t : null;
159
+ }
160
+ function A(t, a, d, x, L, N) {
161
+ var f = d.ref;
162
+ return t = {
163
+ $$typeof: D,
164
+ type: t,
165
+ key: a,
166
+ props: d,
167
+ _owner: x
168
+ }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(t, "ref", {
169
+ enumerable: !1,
170
+ get: I
171
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
172
+ configurable: !1,
173
+ enumerable: !1,
174
+ writable: !0,
175
+ value: 0
176
+ }), Object.defineProperty(t, "_debugInfo", {
177
+ configurable: !1,
178
+ enumerable: !1,
179
+ writable: !0,
180
+ value: null
181
+ }), Object.defineProperty(t, "_debugStack", {
182
+ configurable: !1,
183
+ enumerable: !1,
184
+ writable: !0,
185
+ value: L
186
+ }), Object.defineProperty(t, "_debugTask", {
187
+ configurable: !1,
188
+ enumerable: !1,
189
+ writable: !0,
190
+ value: N
191
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
192
+ }
193
+ function z(t, a, d, x, L, N) {
194
+ var f = a.children;
195
+ if (f !== void 0)
196
+ if (x)
197
+ if (be(f)) {
198
+ for (x = 0; x < f.length; x++)
199
+ R(f[x]);
200
+ Object.freeze && Object.freeze(f);
201
+ } else
202
+ console.error(
203
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
204
+ );
205
+ else R(f);
206
+ if (ce.call(a, "key")) {
207
+ f = h(t);
208
+ var U = Object.keys(a).filter(function(Te) {
209
+ return Te !== "key";
210
+ });
211
+ x = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", me[f + x] || (U = 0 < U.length ? "{" + U.join(": ..., ") + ": ...}" : "{}", console.error(
212
+ `A props object containing a "key" prop is being spread into JSX:
213
+ let props = %s;
214
+ <%s {...props} />
215
+ React keys must be passed directly to JSX without using spread:
216
+ let props = %s;
217
+ <%s key={someKey} {...props} />`,
218
+ x,
219
+ f,
220
+ U,
221
+ f
222
+ ), me[f + x] = !0);
223
+ }
224
+ if (f = null, d !== void 0 && (T(d), f = "" + d), g(a) && (T(a.key), f = "" + a.key), "key" in a) {
225
+ d = {};
226
+ for (var ee in a)
227
+ ee !== "key" && (d[ee] = a[ee]);
228
+ } else d = a;
229
+ return f && C(
230
+ d,
231
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
232
+ ), A(
233
+ t,
234
+ f,
235
+ d,
236
+ u(),
237
+ L,
238
+ N
239
+ );
240
+ }
241
+ function R(t) {
242
+ p(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === r && (t._payload.status === "fulfilled" ? p(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
243
+ }
244
+ function p(t) {
245
+ return typeof t == "object" && t !== null && t.$$typeof === D;
246
+ }
247
+ var b = Re, D = Symbol.for("react.transitional.element"), s = Symbol.for("react.portal"), l = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), w = Symbol.for("react.consumer"), M = Symbol.for("react.context"), K = Symbol.for("react.forward_ref"), V = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), n = Symbol.for("react.memo"), r = Symbol.for("react.lazy"), o = Symbol.for("react.activity"), W = Symbol.for("react.view_transition"), ke = Symbol.for("react.client.reference"), Z = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ce = Object.prototype.hasOwnProperty, be = Array.isArray, Q = console.createTask ? console.createTask : function() {
248
+ return null;
249
+ };
250
+ b = {
251
+ react_stack_bottom_frame: function(t) {
252
+ return t();
253
+ }
254
+ };
255
+ var de, ue = {}, pe = b.react_stack_bottom_frame.bind(
256
+ b,
257
+ c
258
+ )(), he = Q(E(c)), me = {};
259
+ J.Fragment = l, J.jsx = function(t, a, d) {
260
+ var x = 1e4 > Z.recentlyCreatedOwnerStacks++;
261
+ if (x) {
262
+ var L = Error.stackTraceLimit;
263
+ Error.stackTraceLimit = 10;
264
+ var N = Error("react-stack-top-frame");
265
+ Error.stackTraceLimit = L;
266
+ } else N = pe;
267
+ return z(
268
+ t,
269
+ a,
270
+ d,
271
+ !1,
272
+ N,
273
+ x ? Q(E(t)) : he
274
+ );
275
+ }, J.jsxs = function(t, a, d) {
276
+ var x = 1e4 > Z.recentlyCreatedOwnerStacks++;
277
+ if (x) {
278
+ var L = Error.stackTraceLimit;
279
+ Error.stackTraceLimit = 10;
280
+ var N = Error("react-stack-top-frame");
281
+ Error.stackTraceLimit = L;
282
+ } else N = pe;
283
+ return z(
284
+ t,
285
+ a,
286
+ d,
287
+ !0,
288
+ N,
289
+ x ? Q(E(t)) : he
290
+ );
291
+ };
292
+ })()), J;
293
+ }
294
+ var je;
295
+ function Le() {
296
+ return je || (je = 1, process.env.NODE_ENV === "production" ? X.exports = $e() : X.exports = De()), X.exports;
297
+ }
298
+ var e = Le();
299
+ function Fe({ value: h, displayValue: _ = "••••••", copyable: T = !0 }) {
300
+ const [E, u] = i(!1), c = () => {
301
+ h && (navigator.clipboard.writeText(h), y.success("已复制到剪贴板"));
302
+ };
303
+ return /* @__PURE__ */ e.jsxs(H, { children: [
304
+ /* @__PURE__ */ e.jsx(
305
+ S,
306
+ {
307
+ value: E ? h : _,
308
+ readOnly: !0,
309
+ style: { width: 200 }
310
+ }
311
+ ),
312
+ /* @__PURE__ */ e.jsx(
313
+ j,
314
+ {
315
+ size: "small",
316
+ icon: E ? /* @__PURE__ */ e.jsx(Ie, {}) : /* @__PURE__ */ e.jsx(ve, {}),
317
+ onClick: () => u(!E)
318
+ }
319
+ ),
320
+ T && /* @__PURE__ */ e.jsx(
321
+ j,
322
+ {
323
+ size: "small",
324
+ icon: /* @__PURE__ */ e.jsx(Ae, {}),
325
+ onClick: c
326
+ }
327
+ )
328
+ ] });
329
+ }
330
+ function Ue() {
331
+ const h = _e(), [_, T] = i([]), [E, u] = i(!1), [c, g] = i(""), [C, I] = i(!1), [A, z] = i(null), R = async (s) => {
332
+ u(!0);
333
+ try {
334
+ const l = s ? `/secret/search?keyword=${encodeURIComponent(s)}` : "/secret/list", v = await O.get(l);
335
+ v.success && T(v.data || []);
336
+ } catch {
337
+ y.error("获取密钥列表失败");
338
+ } finally {
339
+ u(!1);
340
+ }
341
+ };
342
+ te(() => {
343
+ R();
344
+ }, []);
345
+ const p = (s) => {
346
+ $.confirm({
347
+ title: "确认删除",
348
+ icon: /* @__PURE__ */ e.jsx(Pe, {}),
349
+ content: `确定要删除密钥 "${s.secretName}" 吗?`,
350
+ onOk: async () => {
351
+ try {
352
+ const l = await O.delete(
353
+ `/secret?secretKey=${encodeURIComponent(s.secretKey)}&group=${encodeURIComponent(s.group || "DEFAULT_GROUP")}&namespace=${encodeURIComponent(s.namespace || "")}`
354
+ );
355
+ l.success ? (y.success("删除成功"), R(c)) : y.error(l.message || "删除失败");
356
+ } catch {
357
+ y.error("删除失败");
358
+ }
359
+ }
360
+ });
361
+ }, b = (s) => {
362
+ $.confirm({
363
+ title: "立即轮换密钥?",
364
+ content: `将重新生成 "${s.secretKey}" 的值并自增版本`,
365
+ onOk: async () => {
366
+ const l = await O.post(
367
+ `/secret/rotate?secretKey=${encodeURIComponent(s.secretKey)}&group=${encodeURIComponent(s.group || "DEFAULT_GROUP")}&namespace=${encodeURIComponent(s.namespace || "")}&newValueLength=32`
368
+ );
369
+ l.success ? (y.success("轮换成功"), R(c)) : y.error(l.message || "轮换失败");
370
+ }
371
+ });
372
+ }, D = [
373
+ {
374
+ title: "密钥名称",
375
+ dataIndex: "secretName",
376
+ key: "secretName"
377
+ },
378
+ {
379
+ title: "密钥标识",
380
+ dataIndex: "secretKey",
381
+ key: "secretKey"
382
+ },
383
+ {
384
+ title: "分组",
385
+ dataIndex: "group",
386
+ key: "group",
387
+ width: 120
388
+ },
389
+ {
390
+ title: "命名空间",
391
+ dataIndex: "namespace",
392
+ key: "namespace",
393
+ width: 110
394
+ },
395
+ {
396
+ title: "密钥类型",
397
+ dataIndex: "secretType",
398
+ key: "secretType",
399
+ width: 110,
400
+ render: (s) => {
401
+ const l = {
402
+ text: "blue",
403
+ password: "red",
404
+ cert: "green",
405
+ key: "purple",
406
+ api_key: "orange"
407
+ };
408
+ return /* @__PURE__ */ e.jsx(F, { color: l[s] || "default", children: s });
409
+ }
410
+ },
411
+ {
412
+ title: "版本",
413
+ dataIndex: "keyVersion",
414
+ key: "keyVersion",
415
+ width: 80
416
+ },
417
+ {
418
+ title: "过期",
419
+ dataIndex: "expireTime",
420
+ key: "expireTime",
421
+ width: 170,
422
+ render: (s) => {
423
+ if (!s) return /* @__PURE__ */ e.jsx("span", { style: { color: "#999" }, children: "-" });
424
+ const l = new Date(s), v = Math.floor((l - /* @__PURE__ */ new Date()) / (1e3 * 60 * 60 * 24));
425
+ let m = "default";
426
+ return v < 0 ? m = "red" : v < 7 ? m = "orange" : v < 30 ? m = "gold" : m = "green", /* @__PURE__ */ e.jsxs(F, { color: m, children: [
427
+ l.toLocaleDateString(),
428
+ v >= 0 && ` (${v}d)`
429
+ ] });
430
+ }
431
+ },
432
+ {
433
+ title: "创建时间",
434
+ dataIndex: "gmtCreate",
435
+ key: "gmtCreate",
436
+ width: 170,
437
+ render: (s) => s ? new Date(s).toLocaleString() : "-"
438
+ },
439
+ {
440
+ title: "操作",
441
+ key: "action",
442
+ width: 320,
443
+ fixed: "right",
444
+ render: (s, l) => /* @__PURE__ */ e.jsxs(H, { size: "small", children: [
445
+ /* @__PURE__ */ e.jsx(
446
+ j,
447
+ {
448
+ type: "link",
449
+ icon: /* @__PURE__ */ e.jsx(ve, {}),
450
+ onClick: () => h(`/z-mist/secret/detail/${l.id}`),
451
+ children: "详情"
452
+ }
453
+ ),
454
+ /* @__PURE__ */ e.jsx(
455
+ j,
456
+ {
457
+ type: "link",
458
+ icon: /* @__PURE__ */ e.jsx(se, {}),
459
+ onClick: () => h(`/z-mist/secret/edit/${l.id}`),
460
+ children: "编辑"
461
+ }
462
+ ),
463
+ /* @__PURE__ */ e.jsx(
464
+ j,
465
+ {
466
+ type: "link",
467
+ onClick: () => b(l),
468
+ children: "轮换"
469
+ }
470
+ ),
471
+ /* @__PURE__ */ e.jsx(
472
+ j,
473
+ {
474
+ type: "link",
475
+ danger: !0,
476
+ icon: /* @__PURE__ */ e.jsx(le, {}),
477
+ onClick: () => p(l),
478
+ children: "删除"
479
+ }
480
+ )
481
+ ] })
482
+ }
483
+ ];
484
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
485
+ /* @__PURE__ */ e.jsx("div", { style: { marginBottom: 16, display: "flex", justifyContent: "space-between" }, children: /* @__PURE__ */ e.jsx("h2", { children: "密钥管理" }) }),
486
+ /* @__PURE__ */ e.jsx(
487
+ ie,
488
+ {
489
+ left: /* @__PURE__ */ e.jsx(
490
+ we,
491
+ {
492
+ placeholder: "搜索密钥标识/名称/描述/应用",
493
+ value: c,
494
+ onChange: g,
495
+ onSearch: (s) => {
496
+ g(s), R(s);
497
+ },
498
+ width: 320
499
+ }
500
+ ),
501
+ right: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
502
+ /* @__PURE__ */ e.jsx(j, { icon: /* @__PURE__ */ e.jsx(ne, {}), onClick: () => {
503
+ g(""), R("");
504
+ }, children: "重置" }),
505
+ /* @__PURE__ */ e.jsx(
506
+ j,
507
+ {
508
+ type: "primary",
509
+ icon: /* @__PURE__ */ e.jsx(ae, {}),
510
+ onClick: () => h("/z-mist/secret/add"),
511
+ children: "新增密钥"
512
+ }
513
+ )
514
+ ] })
515
+ }
516
+ ),
517
+ /* @__PURE__ */ e.jsx(
518
+ re,
519
+ {
520
+ columns: D,
521
+ dataSource: _,
522
+ loading: E,
523
+ rowKey: "id",
524
+ pagination: { pageSize: 10, showSizeChanger: !0 },
525
+ scroll: { x: 1200 },
526
+ locale: { emptyText: /* @__PURE__ */ e.jsx(oe, { title: "暂无密钥", description: "点右上角「新增密钥」创建第一个" }) }
527
+ }
528
+ ),
529
+ /* @__PURE__ */ e.jsx(
530
+ $,
531
+ {
532
+ title: "密钥详情 - " + ((A == null ? void 0 : A.secretName) || ""),
533
+ open: C,
534
+ onCancel: () => I(!1),
535
+ footer: null,
536
+ width: 500,
537
+ children: A && /* @__PURE__ */ e.jsx(
538
+ Fe,
539
+ {
540
+ value: A.secretValue,
541
+ displayValue: "••••••••"
542
+ }
543
+ )
544
+ }
545
+ )
546
+ ] });
547
+ }
548
+ const { Option: ye } = Y;
549
+ function Ye() {
550
+ const [h, _] = i([]), [T, E] = i(0), [u, c] = i(!1), [g, C] = i(1), [I, A] = i(20), [z, R] = i(""), [p, b] = i(null), [D, s] = i(!1), [l, v] = i(null), [m] = k.useForm();
551
+ te(() => {
552
+ w();
553
+ }, [g, I]);
554
+ const w = async (r) => {
555
+ c(!0);
556
+ try {
557
+ const o = typeof r == "string" ? r : z, W = await O.get(`/app/page?current=${g}&size=${I}&appName=${encodeURIComponent(o)}`);
558
+ W.success && (_(W.data || []), E(W.total || 0)), b(null);
559
+ } catch (o) {
560
+ b(o);
561
+ } finally {
562
+ c(!1);
563
+ }
564
+ }, M = () => {
565
+ v(null), m.resetFields(), m.setFieldsValue({ appType: "server", enabled: 1, namespace: "" }), s(!0);
566
+ }, K = (r) => {
567
+ v(r), m.setFieldsValue(r), s(!0);
568
+ }, V = (r) => {
569
+ $.confirm({
570
+ title: "确认删除",
571
+ content: `确定要删除应用 "${r.appName}" 吗?`,
572
+ onOk: async () => {
573
+ const o = await O.delete(`/app/${r.id}`);
574
+ o.success ? (y.success("删除成功"), w()) : y.error(o.message || "删除失败");
575
+ }
576
+ });
577
+ }, q = (r) => {
578
+ $.confirm({
579
+ title: "重置 appSecret",
580
+ content: `将重新生成 "${r.appName}" 的 appSecret,旧密钥立即失效`,
581
+ onOk: async () => {
582
+ const o = await O.post(`/app/${r.id}/reset-secret`);
583
+ o.success ? ($.info({
584
+ title: "新密钥生成成功",
585
+ content: /* @__PURE__ */ e.jsxs("div", { children: [
586
+ /* @__PURE__ */ e.jsxs("p", { children: [
587
+ "应用: ",
588
+ o.data.appName
589
+ ] }),
590
+ /* @__PURE__ */ e.jsx("p", { children: "新 appSecret (仅显示一次,请妥善保存):" }),
591
+ /* @__PURE__ */ e.jsx(S.TextArea, { rows: 3, value: o.data.newSecret, readOnly: !0 })
592
+ ] })
593
+ }), w()) : y.error(o.message || "重置失败");
594
+ }
595
+ });
596
+ }, n = async () => {
597
+ const r = await m.validateFields();
598
+ try {
599
+ const o = l ? await O.put(`/app/${l.id}`, r) : await O.post("/app", r);
600
+ o.success ? (y.success(l ? "更新成功" : "创建成功"), s(!1), w()) : y.error(o.message || "操作失败");
601
+ } catch {
602
+ y.error("操作失败");
603
+ }
604
+ };
605
+ return /* @__PURE__ */ e.jsxs("div", { children: [
606
+ /* @__PURE__ */ e.jsxs(ge, { children: [
607
+ p && /* @__PURE__ */ e.jsx("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ e.jsx(Ee, { error: p, title: "获取应用列表失败", onRetry: () => w() }) }),
608
+ /* @__PURE__ */ e.jsx(
609
+ ie,
610
+ {
611
+ left: /* @__PURE__ */ e.jsx(
612
+ we,
613
+ {
614
+ placeholder: "搜索应用名",
615
+ value: z,
616
+ onChange: R,
617
+ onSearch: (r) => w(r),
618
+ width: 240
619
+ }
620
+ ),
621
+ right: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
622
+ /* @__PURE__ */ e.jsx(j, { icon: /* @__PURE__ */ e.jsx(ne, {}), onClick: () => w(), children: "刷新" }),
623
+ /* @__PURE__ */ e.jsx(j, { type: "primary", icon: /* @__PURE__ */ e.jsx(ae, {}), onClick: M, children: "新建应用" })
624
+ ] })
625
+ }
626
+ ),
627
+ /* @__PURE__ */ e.jsx(
628
+ re,
629
+ {
630
+ loading: u,
631
+ rowKey: "id",
632
+ dataSource: h,
633
+ pagination: {
634
+ current: g,
635
+ pageSize: I,
636
+ total: T,
637
+ showSizeChanger: !0,
638
+ onChange: (r, o) => {
639
+ C(r), A(o);
640
+ }
641
+ },
642
+ columns: [
643
+ { title: "ID", dataIndex: "id", width: 60 },
644
+ { title: "应用名", dataIndex: "appName" },
645
+ {
646
+ title: "appSecret 指纹",
647
+ dataIndex: "appSecret",
648
+ ellipsis: !0,
649
+ render: (r) => r ? /* @__PURE__ */ e.jsxs("code", { children: [
650
+ r.substring(0, 8),
651
+ "...",
652
+ r.substring(r.length - 4)
653
+ ] }) : "-"
654
+ },
655
+ {
656
+ title: "类型",
657
+ dataIndex: "appType",
658
+ width: 80,
659
+ render: (r) => /* @__PURE__ */ e.jsx(F, { color: r === "server" ? "blue" : "green", children: r })
660
+ },
661
+ { title: "命名空间", dataIndex: "namespace", width: 120 },
662
+ {
663
+ title: "启用",
664
+ dataIndex: "enabled",
665
+ width: 80,
666
+ render: (r) => /* @__PURE__ */ e.jsx(F, { color: r === 1 ? "green" : "red", children: r === 1 ? "是" : "否" })
667
+ },
668
+ {
669
+ title: "创建时间",
670
+ dataIndex: "gmtCreate",
671
+ width: 170,
672
+ render: (r) => r ? new Date(r).toLocaleString() : "-"
673
+ },
674
+ {
675
+ title: "操作",
676
+ width: 280,
677
+ fixed: "right",
678
+ render: (r, o) => /* @__PURE__ */ e.jsxs(H, { size: "small", children: [
679
+ /* @__PURE__ */ e.jsx(
680
+ j,
681
+ {
682
+ type: "link",
683
+ icon: /* @__PURE__ */ e.jsx(se, {}),
684
+ onClick: () => K(o),
685
+ children: "编辑"
686
+ }
687
+ ),
688
+ /* @__PURE__ */ e.jsx(
689
+ j,
690
+ {
691
+ type: "link",
692
+ icon: /* @__PURE__ */ e.jsx(ze, {}),
693
+ onClick: () => q(o),
694
+ children: "重置密钥"
695
+ }
696
+ ),
697
+ /* @__PURE__ */ e.jsx(
698
+ j,
699
+ {
700
+ type: "link",
701
+ danger: !0,
702
+ icon: /* @__PURE__ */ e.jsx(le, {}),
703
+ onClick: () => V(o),
704
+ children: "删除"
705
+ }
706
+ )
707
+ ] })
708
+ }
709
+ ],
710
+ locale: { emptyText: /* @__PURE__ */ e.jsx(oe, { title: "暂无应用", description: "点「新建应用」注册第一个调用方" }) }
711
+ }
712
+ )
713
+ ] }),
714
+ /* @__PURE__ */ e.jsx(
715
+ $,
716
+ {
717
+ title: l ? "编辑应用" : "新建应用",
718
+ open: D,
719
+ onCancel: () => s(!1),
720
+ onOk: n,
721
+ width: 500,
722
+ destroyOnClose: !0,
723
+ children: /* @__PURE__ */ e.jsxs(k, { form: m, layout: "vertical", children: [
724
+ /* @__PURE__ */ e.jsx(k.Item, { name: "appName", label: "应用名", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(S, { placeholder: "如: z-trade-biz" }) }),
725
+ /* @__PURE__ */ e.jsx(k.Item, { name: "appType", label: "应用类型", children: /* @__PURE__ */ e.jsxs(Y, { children: [
726
+ /* @__PURE__ */ e.jsx(ye, { value: "server", children: "server (服务端)" }),
727
+ /* @__PURE__ */ e.jsx(ye, { value: "client", children: "client (客户端)" })
728
+ ] }) }),
729
+ /* @__PURE__ */ e.jsx(k.Item, { name: "namespace", label: "命名空间", children: /* @__PURE__ */ e.jsx(S, { placeholder: "如: prod/dev" }) }),
730
+ /* @__PURE__ */ e.jsx(k.Item, { name: "enabled", label: "启用", valuePropName: "checked", children: /* @__PURE__ */ e.jsx(Oe, {}) }),
731
+ /* @__PURE__ */ e.jsx(k.Item, { name: "description", label: "描述", children: /* @__PURE__ */ e.jsx(S.TextArea, { rows: 2 }) })
732
+ ] })
733
+ }
734
+ )
735
+ ] });
736
+ }
737
+ const { Option: P } = Y;
738
+ function Me() {
739
+ const [h, _] = i([]), [T, E] = i(0), [u, c] = i(!1), [g, C] = i(1), [I, A] = i(20), [z, R] = i(null), [p, b] = i({ secretKey: "", authorizedApp: "", authorizedEnv: "", namespace: "" }), [D, s] = i(!1), [l, v] = i(null), [m] = k.useForm();
740
+ te(() => {
741
+ w();
742
+ }, [g, I]);
743
+ const w = async () => {
744
+ c(!0);
745
+ try {
746
+ const n = new URLSearchParams({
747
+ current: g,
748
+ size: I,
749
+ secretKey: p.secretKey,
750
+ authorizedApp: p.authorizedApp,
751
+ authorizedEnv: p.authorizedEnv,
752
+ namespace: p.namespace
753
+ }), r = await O.get(`/acl/page?${n}`);
754
+ r.success && (_(r.data || []), E(r.total || 0)), R(null);
755
+ } catch (n) {
756
+ R(n);
757
+ } finally {
758
+ c(!1);
759
+ }
760
+ }, M = () => {
761
+ v(null), m.resetFields(), m.setFieldsValue({
762
+ permissionLevel: "read",
763
+ group: "DEFAULT_GROUP",
764
+ namespace: "",
765
+ authorizedEnv: "prod"
766
+ }), s(!0);
767
+ }, K = (n) => {
768
+ v(n), m.setFieldsValue(n), s(!0);
769
+ }, V = (n) => {
770
+ $.confirm({
771
+ title: "确认删除授权",
772
+ content: `将撤销 ${n.authorizedApp} 对 ${n.secretKey} 的访问权限`,
773
+ onOk: async () => {
774
+ const r = await O.delete(`/acl/${n.id}`);
775
+ r.success ? (y.success("删除成功"), w()) : y.error(r.message || "删除失败");
776
+ }
777
+ });
778
+ }, q = async () => {
779
+ const n = await m.validateFields();
780
+ try {
781
+ const r = l ? await O.put(`/acl/${l.id}`, n) : await O.post("/acl", n);
782
+ r.success ? (y.success(l ? "更新成功" : "创建成功"), s(!1), w()) : y.error(r.message || "操作失败");
783
+ } catch {
784
+ y.error("操作失败");
785
+ }
786
+ };
787
+ return /* @__PURE__ */ e.jsxs("div", { children: [
788
+ /* @__PURE__ */ e.jsxs(ge, { children: [
789
+ z && /* @__PURE__ */ e.jsx("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ e.jsx(Ee, { error: z, title: "获取授权列表失败", onRetry: () => w() }) }),
790
+ /* @__PURE__ */ e.jsx(
791
+ ie,
792
+ {
793
+ left: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
794
+ /* @__PURE__ */ e.jsx(
795
+ S,
796
+ {
797
+ placeholder: "密钥标识",
798
+ allowClear: !0,
799
+ value: p.secretKey,
800
+ onChange: (n) => b({ ...p, secretKey: n.target.value }),
801
+ style: { width: 180 }
802
+ }
803
+ ),
804
+ /* @__PURE__ */ e.jsx(
805
+ S,
806
+ {
807
+ placeholder: "授权应用",
808
+ allowClear: !0,
809
+ value: p.authorizedApp,
810
+ onChange: (n) => b({ ...p, authorizedApp: n.target.value }),
811
+ style: { width: 180 }
812
+ }
813
+ ),
814
+ /* @__PURE__ */ e.jsxs(
815
+ Y,
816
+ {
817
+ placeholder: "环境",
818
+ allowClear: !0,
819
+ value: p.authorizedEnv || void 0,
820
+ onChange: (n) => b({ ...p, authorizedEnv: n || "" }),
821
+ style: { width: 120 },
822
+ children: [
823
+ /* @__PURE__ */ e.jsx(P, { value: "dev", children: "dev" }),
824
+ /* @__PURE__ */ e.jsx(P, { value: "test", children: "test" }),
825
+ /* @__PURE__ */ e.jsx(P, { value: "pre", children: "pre" }),
826
+ /* @__PURE__ */ e.jsx(P, { value: "prod", children: "prod" })
827
+ ]
828
+ }
829
+ ),
830
+ /* @__PURE__ */ e.jsx(
831
+ S,
832
+ {
833
+ placeholder: "命名空间",
834
+ allowClear: !0,
835
+ value: p.namespace,
836
+ onChange: (n) => b({ ...p, namespace: n.target.value }),
837
+ style: { width: 140 }
838
+ }
839
+ )
840
+ ] }),
841
+ right: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
842
+ /* @__PURE__ */ e.jsx(j, { type: "primary", icon: /* @__PURE__ */ e.jsx(Ne, {}), onClick: () => {
843
+ C(1), w();
844
+ }, children: "查询" }),
845
+ /* @__PURE__ */ e.jsx(j, { icon: /* @__PURE__ */ e.jsx(ne, {}), onClick: w, children: "刷新" }),
846
+ /* @__PURE__ */ e.jsx(j, { type: "primary", icon: /* @__PURE__ */ e.jsx(ae, {}), onClick: M, children: "新建授权" })
847
+ ] })
848
+ }
849
+ ),
850
+ /* @__PURE__ */ e.jsx(
851
+ re,
852
+ {
853
+ loading: u,
854
+ rowKey: "id",
855
+ dataSource: h,
856
+ pagination: {
857
+ current: g,
858
+ pageSize: I,
859
+ total: T,
860
+ showSizeChanger: !0,
861
+ onChange: (n, r) => {
862
+ C(n), A(r);
863
+ }
864
+ },
865
+ columns: [
866
+ { title: "ID", dataIndex: "id", width: 60 },
867
+ { title: "密钥", dataIndex: "secretKey", ellipsis: !0 },
868
+ { title: "分组", dataIndex: "group", width: 110 },
869
+ { title: "命名空间", dataIndex: "namespace", width: 110 },
870
+ {
871
+ title: "授权应用",
872
+ dataIndex: "authorizedApp",
873
+ render: (n) => /* @__PURE__ */ e.jsx(F, { color: "blue", children: n })
874
+ },
875
+ {
876
+ title: "环境",
877
+ dataIndex: "authorizedEnv",
878
+ width: 80,
879
+ render: (n) => n ? /* @__PURE__ */ e.jsx(F, { children: n }) : /* @__PURE__ */ e.jsx(F, { color: "default", children: "ALL" })
880
+ },
881
+ {
882
+ title: "权限级别",
883
+ dataIndex: "permissionLevel",
884
+ width: 100,
885
+ render: (n) => /* @__PURE__ */ e.jsx(F, { color: n === "decrypt" ? "orange" : "green", children: n })
886
+ },
887
+ {
888
+ title: "过期时间",
889
+ dataIndex: "expireTime",
890
+ width: 170,
891
+ render: (n) => n ? new Date(n).toLocaleString() : "永久"
892
+ },
893
+ {
894
+ title: "创建时间",
895
+ dataIndex: "gmtCreate",
896
+ width: 170,
897
+ render: (n) => n ? new Date(n).toLocaleString() : "-"
898
+ },
899
+ {
900
+ title: "操作",
901
+ width: 150,
902
+ fixed: "right",
903
+ render: (n, r) => /* @__PURE__ */ e.jsxs(H, { size: "small", children: [
904
+ /* @__PURE__ */ e.jsx(
905
+ j,
906
+ {
907
+ type: "link",
908
+ icon: /* @__PURE__ */ e.jsx(se, {}),
909
+ onClick: () => K(r),
910
+ children: "编辑"
911
+ }
912
+ ),
913
+ /* @__PURE__ */ e.jsx(
914
+ j,
915
+ {
916
+ type: "link",
917
+ danger: !0,
918
+ icon: /* @__PURE__ */ e.jsx(le, {}),
919
+ onClick: () => V(r),
920
+ children: "删除"
921
+ }
922
+ )
923
+ ] })
924
+ }
925
+ ],
926
+ locale: { emptyText: /* @__PURE__ */ e.jsx(oe, { title: "暂无授权", description: "点「新建授权」给应用开一把钥匙" }) }
927
+ }
928
+ )
929
+ ] }),
930
+ /* @__PURE__ */ e.jsx(
931
+ $,
932
+ {
933
+ title: l ? "编辑授权" : "新建授权",
934
+ open: D,
935
+ onCancel: () => s(!1),
936
+ onOk: q,
937
+ width: 500,
938
+ destroyOnClose: !0,
939
+ children: /* @__PURE__ */ e.jsxs(k, { form: m, layout: "vertical", children: [
940
+ /* @__PURE__ */ e.jsx(k.Item, { name: "secretKey", label: "密钥标识", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(S, { placeholder: "如: db_password" }) }),
941
+ /* @__PURE__ */ e.jsx(k.Item, { name: "group", label: "分组", children: /* @__PURE__ */ e.jsx(S, { placeholder: "DEFAULT_GROUP" }) }),
942
+ /* @__PURE__ */ e.jsx(k.Item, { name: "namespace", label: "命名空间", children: /* @__PURE__ */ e.jsx(S, { placeholder: "prod/test/dev" }) }),
943
+ /* @__PURE__ */ e.jsx(k.Item, { name: "authorizedApp", label: "授权应用名", rules: [{ required: !0 }], children: /* @__PURE__ */ e.jsx(S, { placeholder: "如: z-trade-biz" }) }),
944
+ /* @__PURE__ */ e.jsx(k.Item, { name: "authorizedEnv", label: "授权环境", children: /* @__PURE__ */ e.jsxs(Y, { children: [
945
+ /* @__PURE__ */ e.jsx(P, { value: "dev", children: "dev" }),
946
+ /* @__PURE__ */ e.jsx(P, { value: "test", children: "test" }),
947
+ /* @__PURE__ */ e.jsx(P, { value: "pre", children: "pre" }),
948
+ /* @__PURE__ */ e.jsx(P, { value: "prod", children: "prod" })
949
+ ] }) }),
950
+ /* @__PURE__ */ e.jsx(k.Item, { name: "permissionLevel", label: "权限级别", children: /* @__PURE__ */ e.jsxs(Y, { children: [
951
+ /* @__PURE__ */ e.jsx(P, { value: "read", children: "read (仅读取密文)" }),
952
+ /* @__PURE__ */ e.jsx(P, { value: "decrypt", children: "decrypt (读取并解密)" })
953
+ ] }) })
954
+ ] })
955
+ }
956
+ )
957
+ ] });
958
+ }
959
+ function Be() {
960
+ return /* @__PURE__ */ e.jsxs(Ce, { children: [
961
+ /* @__PURE__ */ e.jsx(B, { index: !0, element: /* @__PURE__ */ e.jsx(Se, { to: "secret", replace: !0 }) }),
962
+ /* @__PURE__ */ e.jsx(B, { path: "secret", element: /* @__PURE__ */ e.jsx(Ue, {}) }),
963
+ /* @__PURE__ */ e.jsx(B, { path: "app", element: /* @__PURE__ */ e.jsx(Ye, {}) }),
964
+ /* @__PURE__ */ e.jsx(B, { path: "acl", element: /* @__PURE__ */ e.jsx(Me, {}) })
965
+ ] });
966
+ }
967
+ export {
968
+ Me as A,
969
+ Be as M,
970
+ Ue as S,
971
+ Ye as a,
972
+ e as j
973
+ };