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