com-angel-authorization 1.0.5 → 1.0.7
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.
- package/README.md +77 -0
- package/dist/index.cjs +157 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -6
- package/dist/index.d.ts +85 -6
- package/dist/index.js +144 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +929 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +109 -6
- package/dist/react/index.d.ts +109 -6
- package/dist/react/index.js +918 -3
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +1133 -3
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +180 -6
- package/dist/vue/index.d.ts +180 -6
- package/dist/vue/index.js +1125 -3
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -310,16 +310,35 @@ import {
|
|
|
310
310
|
|
|
311
311
|
// src/resources/types.ts
|
|
312
312
|
var RESOURCE_TYPE_API = "api";
|
|
313
|
+
var MENU_TYPE_PAGE = "page";
|
|
314
|
+
var MENU_TYPE_MENU = "menu";
|
|
315
|
+
var MENU_TYPE_BUTTON = "button";
|
|
316
|
+
var MENU_LIST_TYPE_PARAM = "page,menu,button";
|
|
317
|
+
var ROOT_PARENT_ID = "0";
|
|
313
318
|
var RESOURCE_STATUS_ENABLED = 1;
|
|
314
319
|
var RESOURCE_STATUS_DISABLED = 0;
|
|
315
320
|
var RESOURCE_STATUS_OPTIONS = [
|
|
316
321
|
{ label: "\u542F\u7528", value: RESOURCE_STATUS_ENABLED },
|
|
317
322
|
{ label: "\u7981\u7528", value: RESOURCE_STATUS_DISABLED }
|
|
318
323
|
];
|
|
324
|
+
var MENU_VISIBILITY_OPTIONS = [
|
|
325
|
+
{ label: "\u663E\u793A", value: RESOURCE_STATUS_ENABLED },
|
|
326
|
+
{ label: "\u9690\u85CF", value: RESOURCE_STATUS_DISABLED }
|
|
327
|
+
];
|
|
319
328
|
var RESOURCE_PRIVATE_OPTIONS = [
|
|
320
329
|
{ label: "\u662F", value: true },
|
|
321
330
|
{ label: "\u5426", value: false }
|
|
322
331
|
];
|
|
332
|
+
var MENU_TYPE_OPTIONS = [
|
|
333
|
+
{ label: "\u76EE\u5F55", value: MENU_TYPE_PAGE },
|
|
334
|
+
{ label: "\u83DC\u5355", value: MENU_TYPE_MENU },
|
|
335
|
+
{ label: "\u6309\u94AE", value: MENU_TYPE_BUTTON }
|
|
336
|
+
];
|
|
337
|
+
var MENU_TYPE_LABEL = {
|
|
338
|
+
page: "\u76EE\u5F55",
|
|
339
|
+
menu: "\u83DC\u5355",
|
|
340
|
+
button: "\u6309\u94AE"
|
|
341
|
+
};
|
|
323
342
|
|
|
324
343
|
// src/utils/snowflake.ts
|
|
325
344
|
var DEVICE_WORKER_ID_KEY = "hgams_device_worker_id";
|
|
@@ -464,6 +483,29 @@ function toBoolean(value) {
|
|
|
464
483
|
}
|
|
465
484
|
return false;
|
|
466
485
|
}
|
|
486
|
+
function toStringArray(value) {
|
|
487
|
+
if (Array.isArray(value)) {
|
|
488
|
+
return value.map((item) => {
|
|
489
|
+
if (item && typeof item === "object") {
|
|
490
|
+
const row = item;
|
|
491
|
+
const id = row.resourceId ?? row.resource_id ?? row.id;
|
|
492
|
+
return id === void 0 || id === null ? "" : String(id);
|
|
493
|
+
}
|
|
494
|
+
return String(item ?? "");
|
|
495
|
+
}).filter(Boolean);
|
|
496
|
+
}
|
|
497
|
+
if (typeof value === "string" && value.trim()) {
|
|
498
|
+
return value.split(",").map((s4) => s4.trim()).filter(Boolean);
|
|
499
|
+
}
|
|
500
|
+
return [];
|
|
501
|
+
}
|
|
502
|
+
function toMenuType(value) {
|
|
503
|
+
const v = String(value ?? "").toLowerCase();
|
|
504
|
+
if (v === MENU_TYPE_PAGE || v === MENU_TYPE_MENU || v === MENU_TYPE_BUTTON) {
|
|
505
|
+
return v;
|
|
506
|
+
}
|
|
507
|
+
return MENU_TYPE_MENU;
|
|
508
|
+
}
|
|
467
509
|
function mapAuthorizationResource(item) {
|
|
468
510
|
if (!item || typeof item !== "object") return null;
|
|
469
511
|
const row = item;
|
|
@@ -479,9 +521,31 @@ function mapAuthorizationResource(item) {
|
|
|
479
521
|
description: String(row.description ?? row.desc ?? "")
|
|
480
522
|
};
|
|
481
523
|
}
|
|
482
|
-
function
|
|
524
|
+
function mapMenuResource(item) {
|
|
525
|
+
if (!item || typeof item !== "object") return null;
|
|
526
|
+
const row = item;
|
|
527
|
+
const resourceId = row.resourceId ?? row.resource_id ?? row.id;
|
|
528
|
+
if (resourceId === void 0 || resourceId === null || resourceId === "") return null;
|
|
529
|
+
const permissionPointIds = toStringArray(
|
|
530
|
+
row.permissionPointIds ?? row.permission_point_ids ?? row.permissionPoints ?? row.permissions
|
|
531
|
+
);
|
|
532
|
+
const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
|
|
533
|
+
const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
|
|
534
|
+
const parentId = row.parentId ?? row.parent_id ?? ROOT_PARENT_ID;
|
|
535
|
+
return {
|
|
536
|
+
resourceId: String(resourceId),
|
|
537
|
+
parentId: parentId === void 0 || parentId === null ? ROOT_PARENT_ID : String(parentId),
|
|
538
|
+
type: toMenuType(row.type),
|
|
539
|
+
name: String(row.name ?? ""),
|
|
540
|
+
identification: String(row.identification ?? row.identity ?? row.path ?? ""),
|
|
541
|
+
permissionPointIds,
|
|
542
|
+
permissionPointNames,
|
|
543
|
+
status: toResourceStatus(row.status)
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function buildListUrl(type, params) {
|
|
483
547
|
const parts = [];
|
|
484
|
-
appendQueryParam(parts, "type",
|
|
548
|
+
appendQueryParam(parts, "type", type);
|
|
485
549
|
appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
|
|
486
550
|
appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
|
|
487
551
|
appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
|
|
@@ -508,12 +572,33 @@ function buildUpdateBody(values) {
|
|
|
508
572
|
description: values.description.trim()
|
|
509
573
|
};
|
|
510
574
|
}
|
|
575
|
+
function buildCreateMenuBody(values, resourceId = getAppClientId()) {
|
|
576
|
+
return {
|
|
577
|
+
resourceId,
|
|
578
|
+
parentId: values.parentId || ROOT_PARENT_ID,
|
|
579
|
+
type: values.type,
|
|
580
|
+
name: values.name.trim(),
|
|
581
|
+
identification: values.identification.trim(),
|
|
582
|
+
permissionPointIds: [...values.permissionPointIds],
|
|
583
|
+
status: values.status
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function buildUpdateMenuBody(values) {
|
|
587
|
+
return {
|
|
588
|
+
parentId: values.parentId || ROOT_PARENT_ID,
|
|
589
|
+
type: values.type,
|
|
590
|
+
name: values.name.trim(),
|
|
591
|
+
identification: values.identification.trim(),
|
|
592
|
+
permissionPointIds: [...values.permissionPointIds],
|
|
593
|
+
status: values.status
|
|
594
|
+
};
|
|
595
|
+
}
|
|
511
596
|
function createAuthorizationResourceApi(request) {
|
|
512
597
|
return {
|
|
513
598
|
async list(params, signal) {
|
|
514
599
|
const json = await request({
|
|
515
600
|
method: "GET",
|
|
516
|
-
url: buildListUrl(params),
|
|
601
|
+
url: buildListUrl(RESOURCE_TYPE_API, params),
|
|
517
602
|
signal
|
|
518
603
|
});
|
|
519
604
|
const records = extractRecords(json).map(mapAuthorizationResource).filter((item) => item !== null);
|
|
@@ -548,6 +633,50 @@ function createAuthorizationResourceApi(request) {
|
|
|
548
633
|
}
|
|
549
634
|
};
|
|
550
635
|
}
|
|
636
|
+
function createMenuResourceApi(request) {
|
|
637
|
+
const permissionApi = createAuthorizationResourceApi(request);
|
|
638
|
+
return {
|
|
639
|
+
async list(params, signal) {
|
|
640
|
+
const json = await request({
|
|
641
|
+
method: "GET",
|
|
642
|
+
url: buildListUrl(MENU_LIST_TYPE_PARAM, params),
|
|
643
|
+
signal
|
|
644
|
+
});
|
|
645
|
+
const records = extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
|
|
646
|
+
const pagination = extractPagination(json);
|
|
647
|
+
return {
|
|
648
|
+
records,
|
|
649
|
+
...pagination
|
|
650
|
+
};
|
|
651
|
+
},
|
|
652
|
+
listPermissionPoints(params, signal) {
|
|
653
|
+
return permissionApi.list(params, signal);
|
|
654
|
+
},
|
|
655
|
+
async create(values, signal) {
|
|
656
|
+
return request({
|
|
657
|
+
method: "POST",
|
|
658
|
+
url: "/authorization-resources",
|
|
659
|
+
body: buildCreateMenuBody(values),
|
|
660
|
+
signal
|
|
661
|
+
});
|
|
662
|
+
},
|
|
663
|
+
async update(resourceId, values, signal) {
|
|
664
|
+
return request({
|
|
665
|
+
method: "PATCH",
|
|
666
|
+
url: `/authorization-resources/${encodeURIComponent(resourceId)}`,
|
|
667
|
+
body: buildUpdateMenuBody(values),
|
|
668
|
+
signal
|
|
669
|
+
});
|
|
670
|
+
},
|
|
671
|
+
async remove(resourceId, signal) {
|
|
672
|
+
return request({
|
|
673
|
+
method: "DELETE",
|
|
674
|
+
url: `/authorization-resources/${encodeURIComponent(resourceId)}`,
|
|
675
|
+
signal
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
551
680
|
function createDefaultResourceRequest(options = {}) {
|
|
552
681
|
const baseUrl = (options.baseUrl ?? "").replace(/\/+$/, "");
|
|
553
682
|
const credentials = options.credentials ?? "include";
|
|
@@ -1248,8 +1377,993 @@ var ResourceManager = defineComponent2({
|
|
|
1248
1377
|
]);
|
|
1249
1378
|
}
|
|
1250
1379
|
});
|
|
1380
|
+
|
|
1381
|
+
// src/vue/MenuManager.ts
|
|
1382
|
+
import {
|
|
1383
|
+
computed as computed3,
|
|
1384
|
+
defineComponent as defineComponent3,
|
|
1385
|
+
h as h2,
|
|
1386
|
+
onMounted as onMounted2,
|
|
1387
|
+
reactive as reactive2,
|
|
1388
|
+
ref as ref2,
|
|
1389
|
+
watch as watch2
|
|
1390
|
+
} from "vue";
|
|
1391
|
+
var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
|
|
1392
|
+
function emptyForm2() {
|
|
1393
|
+
return {
|
|
1394
|
+
parentId: ROOT_PARENT_ID,
|
|
1395
|
+
type: MENU_TYPE_MENU,
|
|
1396
|
+
name: "",
|
|
1397
|
+
identification: "",
|
|
1398
|
+
permissionPointIds: [],
|
|
1399
|
+
status: RESOURCE_STATUS_ENABLED
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
var s2 = {
|
|
1403
|
+
root: {
|
|
1404
|
+
display: "flex",
|
|
1405
|
+
flexDirection: "column",
|
|
1406
|
+
gap: "16px",
|
|
1407
|
+
padding: "16px",
|
|
1408
|
+
color: "#101828",
|
|
1409
|
+
fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif'
|
|
1410
|
+
},
|
|
1411
|
+
toolbar: {
|
|
1412
|
+
display: "flex",
|
|
1413
|
+
alignItems: "center",
|
|
1414
|
+
justifyContent: "space-between",
|
|
1415
|
+
gap: "12px"
|
|
1416
|
+
},
|
|
1417
|
+
title: { margin: "0", fontSize: "18px", fontWeight: "600" },
|
|
1418
|
+
toolbarRight: { display: "flex", alignItems: "center", gap: "8px" },
|
|
1419
|
+
error: {
|
|
1420
|
+
padding: "10px 12px",
|
|
1421
|
+
borderRadius: "8px",
|
|
1422
|
+
background: "#fef3f2",
|
|
1423
|
+
color: "#b42318",
|
|
1424
|
+
fontSize: "13px"
|
|
1425
|
+
},
|
|
1426
|
+
tableWrap: {
|
|
1427
|
+
overflow: "auto",
|
|
1428
|
+
border: "1px solid #eaecf0",
|
|
1429
|
+
borderRadius: "10px",
|
|
1430
|
+
background: "#fff"
|
|
1431
|
+
},
|
|
1432
|
+
table: { width: "100%", borderCollapse: "collapse", minWidth: "820px" },
|
|
1433
|
+
th: {
|
|
1434
|
+
textAlign: "left",
|
|
1435
|
+
padding: "12px 14px",
|
|
1436
|
+
fontSize: "13px",
|
|
1437
|
+
fontWeight: "600",
|
|
1438
|
+
color: "#475467",
|
|
1439
|
+
background: "#f9fafb",
|
|
1440
|
+
borderBottom: "1px solid #eaecf0"
|
|
1441
|
+
},
|
|
1442
|
+
td: {
|
|
1443
|
+
padding: "12px 14px",
|
|
1444
|
+
fontSize: "14px",
|
|
1445
|
+
borderBottom: "1px solid #f2f4f7",
|
|
1446
|
+
verticalAlign: "middle"
|
|
1447
|
+
},
|
|
1448
|
+
empty: {
|
|
1449
|
+
padding: "28px",
|
|
1450
|
+
textAlign: "center",
|
|
1451
|
+
color: "#98a2b3",
|
|
1452
|
+
fontSize: "14px"
|
|
1453
|
+
},
|
|
1454
|
+
code: {
|
|
1455
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
|
1456
|
+
fontSize: "13px",
|
|
1457
|
+
background: "#f2f4f7",
|
|
1458
|
+
padding: "2px 6px",
|
|
1459
|
+
borderRadius: "4px"
|
|
1460
|
+
},
|
|
1461
|
+
badge: {
|
|
1462
|
+
display: "inline-block",
|
|
1463
|
+
padding: "2px 8px",
|
|
1464
|
+
borderRadius: "999px",
|
|
1465
|
+
fontSize: "12px",
|
|
1466
|
+
fontWeight: "500"
|
|
1467
|
+
},
|
|
1468
|
+
linkBtn: {
|
|
1469
|
+
border: "none",
|
|
1470
|
+
background: "transparent",
|
|
1471
|
+
color: "#049BAD",
|
|
1472
|
+
cursor: "pointer",
|
|
1473
|
+
padding: "0 8px 0 0",
|
|
1474
|
+
fontSize: "13px"
|
|
1475
|
+
},
|
|
1476
|
+
pagination: {
|
|
1477
|
+
display: "flex",
|
|
1478
|
+
alignItems: "center",
|
|
1479
|
+
justifyContent: "space-between",
|
|
1480
|
+
gap: "12px"
|
|
1481
|
+
},
|
|
1482
|
+
pageSize: {
|
|
1483
|
+
display: "flex",
|
|
1484
|
+
alignItems: "center",
|
|
1485
|
+
gap: "8px",
|
|
1486
|
+
fontSize: "13px",
|
|
1487
|
+
color: "#475467"
|
|
1488
|
+
},
|
|
1489
|
+
pageBtns: { display: "flex", gap: "8px" },
|
|
1490
|
+
primaryBtn: {
|
|
1491
|
+
border: "none",
|
|
1492
|
+
background: "#049BAD",
|
|
1493
|
+
color: "#fff",
|
|
1494
|
+
borderRadius: "8px",
|
|
1495
|
+
padding: "8px 14px",
|
|
1496
|
+
cursor: "pointer",
|
|
1497
|
+
fontSize: "14px"
|
|
1498
|
+
},
|
|
1499
|
+
secondaryBtn: {
|
|
1500
|
+
border: "1px solid #d0d5dd",
|
|
1501
|
+
background: "#fff",
|
|
1502
|
+
color: "#344054",
|
|
1503
|
+
borderRadius: "8px",
|
|
1504
|
+
padding: "8px 14px",
|
|
1505
|
+
cursor: "pointer",
|
|
1506
|
+
fontSize: "14px"
|
|
1507
|
+
},
|
|
1508
|
+
dangerBtn: {
|
|
1509
|
+
border: "none",
|
|
1510
|
+
background: "#d92d20",
|
|
1511
|
+
color: "#fff",
|
|
1512
|
+
borderRadius: "8px",
|
|
1513
|
+
padding: "8px 14px",
|
|
1514
|
+
cursor: "pointer",
|
|
1515
|
+
fontSize: "14px"
|
|
1516
|
+
},
|
|
1517
|
+
select: {
|
|
1518
|
+
border: "1px solid #d0d5dd",
|
|
1519
|
+
borderRadius: "6px",
|
|
1520
|
+
padding: "4px 8px",
|
|
1521
|
+
fontSize: "13px",
|
|
1522
|
+
backgroundColor: "#ffffff",
|
|
1523
|
+
color: "#101828"
|
|
1524
|
+
},
|
|
1525
|
+
mask: {
|
|
1526
|
+
position: "fixed",
|
|
1527
|
+
inset: "0",
|
|
1528
|
+
background: "rgba(16, 24, 40, 0.45)",
|
|
1529
|
+
display: "flex",
|
|
1530
|
+
alignItems: "center",
|
|
1531
|
+
justifyContent: "center",
|
|
1532
|
+
zIndex: "1000",
|
|
1533
|
+
padding: "16px"
|
|
1534
|
+
},
|
|
1535
|
+
dialog: {
|
|
1536
|
+
width: "100%",
|
|
1537
|
+
maxWidth: "480px",
|
|
1538
|
+
background: "#fff",
|
|
1539
|
+
borderRadius: "12px",
|
|
1540
|
+
boxShadow: "0 20px 40px rgba(16,24,40,0.18)",
|
|
1541
|
+
maxHeight: "90vh",
|
|
1542
|
+
overflow: "auto"
|
|
1543
|
+
},
|
|
1544
|
+
dialogHeader: {
|
|
1545
|
+
display: "flex",
|
|
1546
|
+
alignItems: "center",
|
|
1547
|
+
justifyContent: "space-between",
|
|
1548
|
+
padding: "14px 16px",
|
|
1549
|
+
borderBottom: "1px solid #eaecf0",
|
|
1550
|
+
position: "sticky",
|
|
1551
|
+
top: "0",
|
|
1552
|
+
background: "#fff",
|
|
1553
|
+
zIndex: "1"
|
|
1554
|
+
},
|
|
1555
|
+
dialogTitle: { margin: "0", fontSize: "16px", fontWeight: "600" },
|
|
1556
|
+
iconBtn: {
|
|
1557
|
+
border: "none",
|
|
1558
|
+
background: "transparent",
|
|
1559
|
+
fontSize: "22px",
|
|
1560
|
+
lineHeight: "1",
|
|
1561
|
+
cursor: "pointer",
|
|
1562
|
+
color: "#667085"
|
|
1563
|
+
},
|
|
1564
|
+
form: { display: "flex", flexDirection: "column", gap: "12px", padding: "16px" },
|
|
1565
|
+
confirmBody: {
|
|
1566
|
+
display: "flex",
|
|
1567
|
+
flexDirection: "column",
|
|
1568
|
+
gap: "16px",
|
|
1569
|
+
padding: "16px"
|
|
1570
|
+
},
|
|
1571
|
+
confirmText: {
|
|
1572
|
+
margin: "0",
|
|
1573
|
+
fontSize: "14px",
|
|
1574
|
+
color: "#344054",
|
|
1575
|
+
lineHeight: "1.6"
|
|
1576
|
+
},
|
|
1577
|
+
field: { display: "flex", flexDirection: "column", gap: "6px" },
|
|
1578
|
+
fieldset: {
|
|
1579
|
+
margin: "0",
|
|
1580
|
+
padding: "0",
|
|
1581
|
+
border: "none",
|
|
1582
|
+
display: "flex",
|
|
1583
|
+
flexDirection: "column",
|
|
1584
|
+
gap: "8px"
|
|
1585
|
+
},
|
|
1586
|
+
label: { fontSize: "13px", color: "#344054", fontWeight: "500" },
|
|
1587
|
+
input: {
|
|
1588
|
+
border: "1px solid #d0d5dd",
|
|
1589
|
+
borderRadius: "8px",
|
|
1590
|
+
padding: "8px 10px",
|
|
1591
|
+
fontSize: "14px",
|
|
1592
|
+
outline: "none",
|
|
1593
|
+
backgroundColor: "#ffffff",
|
|
1594
|
+
color: "#101828",
|
|
1595
|
+
boxSizing: "border-box",
|
|
1596
|
+
width: "100%"
|
|
1597
|
+
},
|
|
1598
|
+
radioGroup: { display: "flex", flexWrap: "wrap", gap: "16px" },
|
|
1599
|
+
radioItem: {
|
|
1600
|
+
display: "flex",
|
|
1601
|
+
alignItems: "center",
|
|
1602
|
+
gap: "6px",
|
|
1603
|
+
fontSize: "14px",
|
|
1604
|
+
color: "#344054",
|
|
1605
|
+
cursor: "pointer"
|
|
1606
|
+
},
|
|
1607
|
+
multiSelect: {
|
|
1608
|
+
maxHeight: "160px",
|
|
1609
|
+
overflow: "auto",
|
|
1610
|
+
border: "1px solid #eaecf0",
|
|
1611
|
+
borderRadius: "8px",
|
|
1612
|
+
padding: "8px",
|
|
1613
|
+
background: "#f9fafb"
|
|
1614
|
+
},
|
|
1615
|
+
checkItem: {
|
|
1616
|
+
display: "flex",
|
|
1617
|
+
alignItems: "center",
|
|
1618
|
+
gap: "8px",
|
|
1619
|
+
padding: "6px 4px",
|
|
1620
|
+
fontSize: "13px",
|
|
1621
|
+
color: "#344054",
|
|
1622
|
+
cursor: "pointer"
|
|
1623
|
+
},
|
|
1624
|
+
hint: { fontSize: "13px", color: "#98a2b3", padding: "8px" },
|
|
1625
|
+
dialogFooter: {
|
|
1626
|
+
display: "flex",
|
|
1627
|
+
justifyContent: "flex-end",
|
|
1628
|
+
gap: "8px",
|
|
1629
|
+
paddingTop: "4px"
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
var MenuManager = defineComponent3({
|
|
1633
|
+
name: "MenuManager",
|
|
1634
|
+
props: {
|
|
1635
|
+
api: {
|
|
1636
|
+
type: Object,
|
|
1637
|
+
required: true
|
|
1638
|
+
},
|
|
1639
|
+
title: {
|
|
1640
|
+
type: String,
|
|
1641
|
+
default: "\u83DC\u5355\u7BA1\u7406"
|
|
1642
|
+
},
|
|
1643
|
+
pageSize: {
|
|
1644
|
+
type: String,
|
|
1645
|
+
default: "20"
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1648
|
+
setup(props, { slots }) {
|
|
1649
|
+
const records = ref2([]);
|
|
1650
|
+
const permissionPoints = ref2([]);
|
|
1651
|
+
const loading = ref2(false);
|
|
1652
|
+
const error = ref2("");
|
|
1653
|
+
const pageSize = ref2(props.pageSize);
|
|
1654
|
+
const pageToken = ref2("");
|
|
1655
|
+
const hasPreviousPage = ref2(false);
|
|
1656
|
+
const hasNextPage = ref2(false);
|
|
1657
|
+
const dialogOpen = ref2(false);
|
|
1658
|
+
const editing = ref2(null);
|
|
1659
|
+
const form = reactive2(emptyForm2());
|
|
1660
|
+
const saving = ref2(false);
|
|
1661
|
+
const deletingRow = ref2(null);
|
|
1662
|
+
const deleting = ref2(false);
|
|
1663
|
+
const permissionNameMap = computed3(() => {
|
|
1664
|
+
const map = /* @__PURE__ */ new Map();
|
|
1665
|
+
permissionPoints.value.forEach(
|
|
1666
|
+
(p) => map.set(p.resourceId, p.name || p.identification)
|
|
1667
|
+
);
|
|
1668
|
+
return map;
|
|
1669
|
+
});
|
|
1670
|
+
const parentOptions = computed3(
|
|
1671
|
+
() => records.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
|
|
1672
|
+
value: row.resourceId,
|
|
1673
|
+
label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
|
|
1674
|
+
}))
|
|
1675
|
+
);
|
|
1676
|
+
async function loadList(direction = "current", token = pageToken.value) {
|
|
1677
|
+
loading.value = true;
|
|
1678
|
+
error.value = "";
|
|
1679
|
+
try {
|
|
1680
|
+
const result = await props.api.list({
|
|
1681
|
+
pagination: {
|
|
1682
|
+
pageToken: token,
|
|
1683
|
+
pageSize: pageSize.value,
|
|
1684
|
+
pageDirection: direction
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
records.value = result.records;
|
|
1688
|
+
pageToken.value = result.pageToken;
|
|
1689
|
+
hasPreviousPage.value = result.hasPreviousPage;
|
|
1690
|
+
hasNextPage.value = result.hasNextPage;
|
|
1691
|
+
} catch (err) {
|
|
1692
|
+
error.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u5931\u8D25";
|
|
1693
|
+
} finally {
|
|
1694
|
+
loading.value = false;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
async function loadPermissionPoints() {
|
|
1698
|
+
try {
|
|
1699
|
+
const result = await props.api.listPermissionPoints({
|
|
1700
|
+
pagination: { pageSize: "200", pageDirection: "current" }
|
|
1701
|
+
});
|
|
1702
|
+
permissionPoints.value = result.records;
|
|
1703
|
+
} catch {
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
function openCreate() {
|
|
1707
|
+
editing.value = null;
|
|
1708
|
+
Object.assign(form, emptyForm2());
|
|
1709
|
+
dialogOpen.value = true;
|
|
1710
|
+
void loadPermissionPoints();
|
|
1711
|
+
}
|
|
1712
|
+
function openEdit(row) {
|
|
1713
|
+
editing.value = row;
|
|
1714
|
+
Object.assign(form, {
|
|
1715
|
+
parentId: row.parentId || ROOT_PARENT_ID,
|
|
1716
|
+
type: row.type,
|
|
1717
|
+
name: row.name,
|
|
1718
|
+
identification: row.identification,
|
|
1719
|
+
permissionPointIds: [...row.permissionPointIds],
|
|
1720
|
+
status: row.status
|
|
1721
|
+
});
|
|
1722
|
+
dialogOpen.value = true;
|
|
1723
|
+
void loadPermissionPoints();
|
|
1724
|
+
}
|
|
1725
|
+
function closeDialog() {
|
|
1726
|
+
if (!saving.value) dialogOpen.value = false;
|
|
1727
|
+
}
|
|
1728
|
+
async function handleSubmit(event) {
|
|
1729
|
+
event.preventDefault();
|
|
1730
|
+
if (!form.name.trim()) {
|
|
1731
|
+
error.value = "\u8BF7\u586B\u5199\u83DC\u5355\u540D\u79F0";
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
saving.value = true;
|
|
1735
|
+
error.value = "";
|
|
1736
|
+
try {
|
|
1737
|
+
if (editing.value) {
|
|
1738
|
+
await props.api.update(editing.value.resourceId, { ...form });
|
|
1739
|
+
} else {
|
|
1740
|
+
await props.api.create({ ...form });
|
|
1741
|
+
}
|
|
1742
|
+
dialogOpen.value = false;
|
|
1743
|
+
await loadList("current", "");
|
|
1744
|
+
} catch (err) {
|
|
1745
|
+
error.value = err instanceof Error ? err.message : "\u4FDD\u5B58\u5931\u8D25";
|
|
1746
|
+
} finally {
|
|
1747
|
+
saving.value = false;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
function askDelete(row) {
|
|
1751
|
+
deletingRow.value = row;
|
|
1752
|
+
}
|
|
1753
|
+
function closeDeleteDialog() {
|
|
1754
|
+
if (!deleting.value) deletingRow.value = null;
|
|
1755
|
+
}
|
|
1756
|
+
async function confirmDelete() {
|
|
1757
|
+
if (!deletingRow.value) return;
|
|
1758
|
+
deleting.value = true;
|
|
1759
|
+
error.value = "";
|
|
1760
|
+
try {
|
|
1761
|
+
await props.api.remove(deletingRow.value.resourceId);
|
|
1762
|
+
deletingRow.value = null;
|
|
1763
|
+
await loadList("current", "");
|
|
1764
|
+
} catch (err) {
|
|
1765
|
+
error.value = err instanceof Error ? err.message : "\u5220\u9664\u5931\u8D25";
|
|
1766
|
+
} finally {
|
|
1767
|
+
deleting.value = false;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function togglePermission(id) {
|
|
1771
|
+
const exists = form.permissionPointIds.includes(id);
|
|
1772
|
+
form.permissionPointIds = exists ? form.permissionPointIds.filter((x) => x !== id) : [...form.permissionPointIds, id];
|
|
1773
|
+
}
|
|
1774
|
+
function renderPermissionLabels(row) {
|
|
1775
|
+
if (row.permissionPointNames?.length) {
|
|
1776
|
+
return row.permissionPointNames.join("\u3001");
|
|
1777
|
+
}
|
|
1778
|
+
if (!row.permissionPointIds.length) return "\u2014";
|
|
1779
|
+
return row.permissionPointIds.map((id) => permissionNameMap.value.get(id) ?? id).join("\u3001");
|
|
1780
|
+
}
|
|
1781
|
+
onMounted2(() => {
|
|
1782
|
+
void loadList("current", "");
|
|
1783
|
+
void loadPermissionPoints();
|
|
1784
|
+
});
|
|
1785
|
+
watch2(
|
|
1786
|
+
() => [props.api, pageSize.value],
|
|
1787
|
+
() => {
|
|
1788
|
+
pageToken.value = "";
|
|
1789
|
+
void loadList("current", "");
|
|
1790
|
+
}
|
|
1791
|
+
);
|
|
1792
|
+
return () => h2("div", { style: s2.root }, [
|
|
1793
|
+
h2("div", { style: s2.toolbar }, [
|
|
1794
|
+
h2("h2", { style: s2.title }, props.title),
|
|
1795
|
+
h2("div", { style: s2.toolbarRight }, [
|
|
1796
|
+
slots.toolbarExtra?.(),
|
|
1797
|
+
h2(
|
|
1798
|
+
"button",
|
|
1799
|
+
{ type: "button", style: s2.primaryBtn, onClick: openCreate },
|
|
1800
|
+
"\u65B0\u589E"
|
|
1801
|
+
)
|
|
1802
|
+
])
|
|
1803
|
+
]),
|
|
1804
|
+
error.value ? h2("div", { style: s2.error }, error.value) : null,
|
|
1805
|
+
h2("div", { style: s2.tableWrap }, [
|
|
1806
|
+
h2("table", { style: s2.table }, [
|
|
1807
|
+
h2("thead", [
|
|
1808
|
+
h2("tr", [
|
|
1809
|
+
h2("th", { style: s2.th }, "\u83DC\u5355\u540D\u79F0"),
|
|
1810
|
+
h2("th", { style: s2.th }, "\u8BF7\u6C42\u5730\u5740"),
|
|
1811
|
+
h2("th", { style: { ...s2.th, width: "90px" } }, "\u7C7B\u578B"),
|
|
1812
|
+
h2("th", { style: { ...s2.th, width: "80px" } }, "\u53EF\u89C1"),
|
|
1813
|
+
h2("th", { style: s2.th }, "\u6743\u9650\u6807\u8BC6"),
|
|
1814
|
+
h2("th", { style: { ...s2.th, width: "140px" } }, "\u64CD\u4F5C")
|
|
1815
|
+
])
|
|
1816
|
+
]),
|
|
1817
|
+
h2(
|
|
1818
|
+
"tbody",
|
|
1819
|
+
loading.value ? [
|
|
1820
|
+
h2("tr", [
|
|
1821
|
+
h2("td", { colspan: 6, style: s2.empty }, "\u52A0\u8F7D\u4E2D\u2026")
|
|
1822
|
+
])
|
|
1823
|
+
] : records.value.length === 0 ? [
|
|
1824
|
+
h2("tr", [
|
|
1825
|
+
h2("td", { colspan: 6, style: s2.empty }, "\u6682\u65E0\u6570\u636E")
|
|
1826
|
+
])
|
|
1827
|
+
] : records.value.map(
|
|
1828
|
+
(row) => h2("tr", { key: row.resourceId }, [
|
|
1829
|
+
h2("td", { style: s2.td }, row.name),
|
|
1830
|
+
h2("td", { style: s2.td }, [
|
|
1831
|
+
h2(
|
|
1832
|
+
"code",
|
|
1833
|
+
{ style: s2.code },
|
|
1834
|
+
row.identification || "\u2014"
|
|
1835
|
+
)
|
|
1836
|
+
]),
|
|
1837
|
+
h2("td", { style: s2.td }, MENU_TYPE_LABEL[row.type]),
|
|
1838
|
+
h2("td", { style: s2.td }, [
|
|
1839
|
+
h2(
|
|
1840
|
+
"span",
|
|
1841
|
+
{
|
|
1842
|
+
style: {
|
|
1843
|
+
...s2.badge,
|
|
1844
|
+
background: row.status === RESOURCE_STATUS_ENABLED ? "#e8f7ef" : "#f4f4f5",
|
|
1845
|
+
color: row.status === RESOURCE_STATUS_ENABLED ? "#067647" : "#667085"
|
|
1846
|
+
}
|
|
1847
|
+
},
|
|
1848
|
+
row.status === RESOURCE_STATUS_ENABLED ? "\u663E\u793A" : "\u9690\u85CF"
|
|
1849
|
+
)
|
|
1850
|
+
]),
|
|
1851
|
+
h2("td", { style: s2.td }, renderPermissionLabels(row)),
|
|
1852
|
+
h2("td", { style: s2.td }, [
|
|
1853
|
+
h2(
|
|
1854
|
+
"button",
|
|
1855
|
+
{
|
|
1856
|
+
type: "button",
|
|
1857
|
+
style: s2.linkBtn,
|
|
1858
|
+
onClick: () => openEdit(row)
|
|
1859
|
+
},
|
|
1860
|
+
"\u7F16\u8F91"
|
|
1861
|
+
),
|
|
1862
|
+
h2(
|
|
1863
|
+
"button",
|
|
1864
|
+
{
|
|
1865
|
+
type: "button",
|
|
1866
|
+
style: { ...s2.linkBtn, color: "#d92d20" },
|
|
1867
|
+
onClick: () => askDelete(row)
|
|
1868
|
+
},
|
|
1869
|
+
"\u5220\u9664"
|
|
1870
|
+
)
|
|
1871
|
+
])
|
|
1872
|
+
])
|
|
1873
|
+
)
|
|
1874
|
+
)
|
|
1875
|
+
])
|
|
1876
|
+
]),
|
|
1877
|
+
h2("div", { style: s2.pagination }, [
|
|
1878
|
+
h2("label", { style: s2.pageSize }, [
|
|
1879
|
+
"\u6BCF\u9875",
|
|
1880
|
+
h2(
|
|
1881
|
+
"select",
|
|
1882
|
+
{
|
|
1883
|
+
style: s2.select,
|
|
1884
|
+
value: pageSize.value,
|
|
1885
|
+
onChange: (e) => {
|
|
1886
|
+
pageSize.value = e.target.value;
|
|
1887
|
+
}
|
|
1888
|
+
},
|
|
1889
|
+
PAGE_SIZE_OPTIONS2.map(
|
|
1890
|
+
(size) => h2("option", { key: size, value: size }, size)
|
|
1891
|
+
)
|
|
1892
|
+
)
|
|
1893
|
+
]),
|
|
1894
|
+
h2("div", { style: s2.pageBtns }, [
|
|
1895
|
+
h2(
|
|
1896
|
+
"button",
|
|
1897
|
+
{
|
|
1898
|
+
type: "button",
|
|
1899
|
+
style: s2.secondaryBtn,
|
|
1900
|
+
disabled: !hasPreviousPage.value || loading.value,
|
|
1901
|
+
onClick: () => void loadList("previous")
|
|
1902
|
+
},
|
|
1903
|
+
"\u4E0A\u4E00\u9875"
|
|
1904
|
+
),
|
|
1905
|
+
h2(
|
|
1906
|
+
"button",
|
|
1907
|
+
{
|
|
1908
|
+
type: "button",
|
|
1909
|
+
style: s2.secondaryBtn,
|
|
1910
|
+
disabled: !hasNextPage.value || loading.value,
|
|
1911
|
+
onClick: () => void loadList("next")
|
|
1912
|
+
},
|
|
1913
|
+
"\u4E0B\u4E00\u9875"
|
|
1914
|
+
)
|
|
1915
|
+
])
|
|
1916
|
+
]),
|
|
1917
|
+
dialogOpen.value ? h2(
|
|
1918
|
+
"div",
|
|
1919
|
+
{ style: s2.mask, onClick: closeDialog },
|
|
1920
|
+
[
|
|
1921
|
+
h2(
|
|
1922
|
+
"div",
|
|
1923
|
+
{
|
|
1924
|
+
style: { ...s2.dialog, maxWidth: "520px" },
|
|
1925
|
+
role: "dialog",
|
|
1926
|
+
"aria-modal": "true",
|
|
1927
|
+
onClick: (e) => e.stopPropagation()
|
|
1928
|
+
},
|
|
1929
|
+
[
|
|
1930
|
+
h2("div", { style: s2.dialogHeader }, [
|
|
1931
|
+
h2(
|
|
1932
|
+
"h3",
|
|
1933
|
+
{ style: s2.dialogTitle },
|
|
1934
|
+
editing.value ? "\u7F16\u8F91\u83DC\u5355" : "\u65B0\u589E\u83DC\u5355"
|
|
1935
|
+
),
|
|
1936
|
+
h2(
|
|
1937
|
+
"button",
|
|
1938
|
+
{
|
|
1939
|
+
type: "button",
|
|
1940
|
+
style: s2.iconBtn,
|
|
1941
|
+
"aria-label": "\u5173\u95ED",
|
|
1942
|
+
onClick: closeDialog
|
|
1943
|
+
},
|
|
1944
|
+
"\xD7"
|
|
1945
|
+
)
|
|
1946
|
+
]),
|
|
1947
|
+
h2(
|
|
1948
|
+
"form",
|
|
1949
|
+
{
|
|
1950
|
+
style: s2.form,
|
|
1951
|
+
onSubmit: (e) => void handleSubmit(e)
|
|
1952
|
+
},
|
|
1953
|
+
[
|
|
1954
|
+
h2("label", { style: s2.field }, [
|
|
1955
|
+
h2("span", { style: s2.label }, "\u4E0A\u7EA7\u83DC\u5355"),
|
|
1956
|
+
h2(
|
|
1957
|
+
"select",
|
|
1958
|
+
{
|
|
1959
|
+
style: s2.input,
|
|
1960
|
+
value: form.parentId,
|
|
1961
|
+
onChange: (e) => {
|
|
1962
|
+
form.parentId = e.target.value;
|
|
1963
|
+
}
|
|
1964
|
+
},
|
|
1965
|
+
[
|
|
1966
|
+
h2("option", { value: ROOT_PARENT_ID }, "\u6839\u76EE\u5F55"),
|
|
1967
|
+
...parentOptions.value.map(
|
|
1968
|
+
(opt) => h2(
|
|
1969
|
+
"option",
|
|
1970
|
+
{ key: opt.value, value: opt.value },
|
|
1971
|
+
opt.label
|
|
1972
|
+
)
|
|
1973
|
+
)
|
|
1974
|
+
]
|
|
1975
|
+
)
|
|
1976
|
+
]),
|
|
1977
|
+
h2("fieldset", { style: s2.fieldset }, [
|
|
1978
|
+
h2("legend", { style: s2.label }, "\u83DC\u5355\u7C7B\u578B"),
|
|
1979
|
+
h2(
|
|
1980
|
+
"div",
|
|
1981
|
+
{ style: s2.radioGroup },
|
|
1982
|
+
MENU_TYPE_OPTIONS.map(
|
|
1983
|
+
(opt) => h2("label", { key: opt.value, style: s2.radioItem }, [
|
|
1984
|
+
h2("input", {
|
|
1985
|
+
type: "radio",
|
|
1986
|
+
name: "menu-type",
|
|
1987
|
+
checked: form.type === opt.value,
|
|
1988
|
+
onChange: () => {
|
|
1989
|
+
form.type = opt.value;
|
|
1990
|
+
}
|
|
1991
|
+
}),
|
|
1992
|
+
opt.label
|
|
1993
|
+
])
|
|
1994
|
+
)
|
|
1995
|
+
)
|
|
1996
|
+
]),
|
|
1997
|
+
h2("label", { style: s2.field }, [
|
|
1998
|
+
h2("span", { style: s2.label }, "\u83DC\u5355\u540D\u79F0"),
|
|
1999
|
+
h2("input", {
|
|
2000
|
+
style: s2.input,
|
|
2001
|
+
value: form.name,
|
|
2002
|
+
placeholder: "\u8BF7\u8F93\u5165\u83DC\u5355\u540D\u79F0",
|
|
2003
|
+
required: true,
|
|
2004
|
+
onInput: (e) => {
|
|
2005
|
+
form.name = e.target.value;
|
|
2006
|
+
}
|
|
2007
|
+
})
|
|
2008
|
+
]),
|
|
2009
|
+
h2("label", { style: s2.field }, [
|
|
2010
|
+
h2("span", { style: s2.label }, "\u8BF7\u6C42\u5730\u5740"),
|
|
2011
|
+
h2("input", {
|
|
2012
|
+
style: s2.input,
|
|
2013
|
+
value: form.identification,
|
|
2014
|
+
placeholder: "\u5982 /system/user",
|
|
2015
|
+
onInput: (e) => {
|
|
2016
|
+
form.identification = e.target.value;
|
|
2017
|
+
}
|
|
2018
|
+
})
|
|
2019
|
+
]),
|
|
2020
|
+
h2("fieldset", { style: s2.fieldset }, [
|
|
2021
|
+
h2("legend", { style: s2.label }, "\u6743\u9650\u6807\u8BC6"),
|
|
2022
|
+
h2(
|
|
2023
|
+
"div",
|
|
2024
|
+
{ style: s2.multiSelect },
|
|
2025
|
+
permissionPoints.value.length === 0 ? [
|
|
2026
|
+
h2(
|
|
2027
|
+
"div",
|
|
2028
|
+
{ style: s2.hint },
|
|
2029
|
+
"\u6682\u65E0\u6743\u9650\u70B9\uFF0C\u8BF7\u5148\u5728\u6743\u9650\u70B9\u7BA1\u7406\u4E2D\u65B0\u589E"
|
|
2030
|
+
)
|
|
2031
|
+
] : permissionPoints.value.map(
|
|
2032
|
+
(p) => h2(
|
|
2033
|
+
"label",
|
|
2034
|
+
{ key: p.resourceId, style: s2.checkItem },
|
|
2035
|
+
[
|
|
2036
|
+
h2("input", {
|
|
2037
|
+
type: "checkbox",
|
|
2038
|
+
checked: form.permissionPointIds.includes(
|
|
2039
|
+
p.resourceId
|
|
2040
|
+
),
|
|
2041
|
+
onChange: () => togglePermission(p.resourceId)
|
|
2042
|
+
}),
|
|
2043
|
+
h2("span", [
|
|
2044
|
+
p.name,
|
|
2045
|
+
h2(
|
|
2046
|
+
"code",
|
|
2047
|
+
{
|
|
2048
|
+
style: {
|
|
2049
|
+
...s2.code,
|
|
2050
|
+
marginLeft: "6px"
|
|
2051
|
+
}
|
|
2052
|
+
},
|
|
2053
|
+
p.identification
|
|
2054
|
+
)
|
|
2055
|
+
])
|
|
2056
|
+
]
|
|
2057
|
+
)
|
|
2058
|
+
)
|
|
2059
|
+
)
|
|
2060
|
+
]),
|
|
2061
|
+
h2("fieldset", { style: s2.fieldset }, [
|
|
2062
|
+
h2("legend", { style: s2.label }, "\u72B6\u6001"),
|
|
2063
|
+
h2(
|
|
2064
|
+
"div",
|
|
2065
|
+
{ style: s2.radioGroup },
|
|
2066
|
+
MENU_VISIBILITY_OPTIONS.map(
|
|
2067
|
+
(opt) => h2("label", { key: opt.value, style: s2.radioItem }, [
|
|
2068
|
+
h2("input", {
|
|
2069
|
+
type: "radio",
|
|
2070
|
+
name: "menu-status",
|
|
2071
|
+
checked: form.status === opt.value,
|
|
2072
|
+
onChange: () => {
|
|
2073
|
+
form.status = opt.value;
|
|
2074
|
+
}
|
|
2075
|
+
}),
|
|
2076
|
+
opt.label
|
|
2077
|
+
])
|
|
2078
|
+
)
|
|
2079
|
+
)
|
|
2080
|
+
]),
|
|
2081
|
+
h2("div", { style: s2.dialogFooter }, [
|
|
2082
|
+
h2(
|
|
2083
|
+
"button",
|
|
2084
|
+
{
|
|
2085
|
+
type: "button",
|
|
2086
|
+
style: s2.secondaryBtn,
|
|
2087
|
+
onClick: closeDialog
|
|
2088
|
+
},
|
|
2089
|
+
"\u53D6\u6D88"
|
|
2090
|
+
),
|
|
2091
|
+
h2(
|
|
2092
|
+
"button",
|
|
2093
|
+
{
|
|
2094
|
+
type: "submit",
|
|
2095
|
+
style: s2.primaryBtn,
|
|
2096
|
+
disabled: saving.value
|
|
2097
|
+
},
|
|
2098
|
+
saving.value ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"
|
|
2099
|
+
)
|
|
2100
|
+
])
|
|
2101
|
+
]
|
|
2102
|
+
)
|
|
2103
|
+
]
|
|
2104
|
+
)
|
|
2105
|
+
]
|
|
2106
|
+
) : null,
|
|
2107
|
+
deletingRow.value ? h2(
|
|
2108
|
+
"div",
|
|
2109
|
+
{ style: s2.mask, onClick: closeDeleteDialog },
|
|
2110
|
+
[
|
|
2111
|
+
h2(
|
|
2112
|
+
"div",
|
|
2113
|
+
{
|
|
2114
|
+
style: { ...s2.dialog, maxWidth: "420px" },
|
|
2115
|
+
role: "dialog",
|
|
2116
|
+
"aria-modal": "true",
|
|
2117
|
+
"aria-labelledby": "angel-auth-menu-delete-title",
|
|
2118
|
+
onClick: (e) => e.stopPropagation()
|
|
2119
|
+
},
|
|
2120
|
+
[
|
|
2121
|
+
h2("div", { style: s2.dialogHeader }, [
|
|
2122
|
+
h2(
|
|
2123
|
+
"h3",
|
|
2124
|
+
{
|
|
2125
|
+
id: "angel-auth-menu-delete-title",
|
|
2126
|
+
style: s2.dialogTitle
|
|
2127
|
+
},
|
|
2128
|
+
"\u786E\u8BA4\u5220\u9664"
|
|
2129
|
+
),
|
|
2130
|
+
h2(
|
|
2131
|
+
"button",
|
|
2132
|
+
{
|
|
2133
|
+
type: "button",
|
|
2134
|
+
style: s2.iconBtn,
|
|
2135
|
+
"aria-label": "\u5173\u95ED",
|
|
2136
|
+
onClick: closeDeleteDialog
|
|
2137
|
+
},
|
|
2138
|
+
"\xD7"
|
|
2139
|
+
)
|
|
2140
|
+
]),
|
|
2141
|
+
h2("div", { style: s2.confirmBody }, [
|
|
2142
|
+
h2("p", { style: s2.confirmText }, [
|
|
2143
|
+
"\u786E\u8BA4\u5220\u9664\u83DC\u5355\u300C",
|
|
2144
|
+
h2("strong", deletingRow.value.name),
|
|
2145
|
+
"\u300D\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002"
|
|
2146
|
+
]),
|
|
2147
|
+
h2("div", { style: s2.dialogFooter }, [
|
|
2148
|
+
h2(
|
|
2149
|
+
"button",
|
|
2150
|
+
{
|
|
2151
|
+
type: "button",
|
|
2152
|
+
style: s2.secondaryBtn,
|
|
2153
|
+
disabled: deleting.value,
|
|
2154
|
+
onClick: closeDeleteDialog
|
|
2155
|
+
},
|
|
2156
|
+
"\u53D6\u6D88"
|
|
2157
|
+
),
|
|
2158
|
+
h2(
|
|
2159
|
+
"button",
|
|
2160
|
+
{
|
|
2161
|
+
type: "button",
|
|
2162
|
+
style: s2.dangerBtn,
|
|
2163
|
+
disabled: deleting.value,
|
|
2164
|
+
onClick: () => void confirmDelete()
|
|
2165
|
+
},
|
|
2166
|
+
deleting.value ? "\u5220\u9664\u4E2D\u2026" : "\u786E\u8BA4\u5220\u9664"
|
|
2167
|
+
)
|
|
2168
|
+
])
|
|
2169
|
+
])
|
|
2170
|
+
]
|
|
2171
|
+
)
|
|
2172
|
+
]
|
|
2173
|
+
) : null
|
|
2174
|
+
]);
|
|
2175
|
+
}
|
|
2176
|
+
});
|
|
2177
|
+
|
|
2178
|
+
// src/vue/SystemAdmin.ts
|
|
2179
|
+
import { computed as computed4, defineComponent as defineComponent4, h as h3, ref as ref3, watch as watch3 } from "vue";
|
|
2180
|
+
|
|
2181
|
+
// src/admin/menu.ts
|
|
2182
|
+
var SYSTEM_ADMIN_MENU = {
|
|
2183
|
+
key: "system",
|
|
2184
|
+
label: "\u7CFB\u7EDF\u7BA1\u7406",
|
|
2185
|
+
children: [
|
|
2186
|
+
{ key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
|
|
2187
|
+
{ key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
|
|
2188
|
+
]
|
|
2189
|
+
};
|
|
2190
|
+
var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
|
|
2191
|
+
|
|
2192
|
+
// src/vue/SystemAdmin.ts
|
|
2193
|
+
var s3 = {
|
|
2194
|
+
root: {
|
|
2195
|
+
display: "flex",
|
|
2196
|
+
minHeight: "560px",
|
|
2197
|
+
border: "1px solid #eaecf0",
|
|
2198
|
+
borderRadius: "12px",
|
|
2199
|
+
overflow: "hidden",
|
|
2200
|
+
background: "#fff",
|
|
2201
|
+
fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
|
|
2202
|
+
color: "#101828"
|
|
2203
|
+
},
|
|
2204
|
+
sidebar: {
|
|
2205
|
+
width: "200px",
|
|
2206
|
+
flexShrink: "0",
|
|
2207
|
+
borderRight: "1px solid #eaecf0",
|
|
2208
|
+
background: "#f9fafb",
|
|
2209
|
+
padding: "16px 12px"
|
|
2210
|
+
},
|
|
2211
|
+
sidebarTitle: {
|
|
2212
|
+
fontSize: "14px",
|
|
2213
|
+
fontWeight: "600",
|
|
2214
|
+
color: "#344054",
|
|
2215
|
+
padding: "4px 10px 12px"
|
|
2216
|
+
},
|
|
2217
|
+
nav: {
|
|
2218
|
+
display: "flex",
|
|
2219
|
+
flexDirection: "column",
|
|
2220
|
+
gap: "4px"
|
|
2221
|
+
},
|
|
2222
|
+
navItem: {
|
|
2223
|
+
border: "none",
|
|
2224
|
+
background: "transparent",
|
|
2225
|
+
textAlign: "left",
|
|
2226
|
+
padding: "10px 12px",
|
|
2227
|
+
borderRadius: "8px",
|
|
2228
|
+
fontSize: "14px",
|
|
2229
|
+
color: "#475467",
|
|
2230
|
+
cursor: "pointer"
|
|
2231
|
+
},
|
|
2232
|
+
navItemActive: {
|
|
2233
|
+
background: "#e6f7f9",
|
|
2234
|
+
color: "#049BAD",
|
|
2235
|
+
fontWeight: "600"
|
|
2236
|
+
},
|
|
2237
|
+
content: {
|
|
2238
|
+
flex: "1",
|
|
2239
|
+
minWidth: "0",
|
|
2240
|
+
display: "flex",
|
|
2241
|
+
flexDirection: "column",
|
|
2242
|
+
background: "#fff"
|
|
2243
|
+
},
|
|
2244
|
+
contentHeader: {
|
|
2245
|
+
display: "flex",
|
|
2246
|
+
alignItems: "center",
|
|
2247
|
+
justifyContent: "space-between",
|
|
2248
|
+
gap: "12px",
|
|
2249
|
+
padding: "12px 16px",
|
|
2250
|
+
borderBottom: "1px solid #f2f4f7"
|
|
2251
|
+
},
|
|
2252
|
+
breadcrumb: {
|
|
2253
|
+
display: "flex",
|
|
2254
|
+
alignItems: "center",
|
|
2255
|
+
gap: "8px",
|
|
2256
|
+
fontSize: "13px"
|
|
2257
|
+
},
|
|
2258
|
+
breadcrumbParent: { color: "#98a2b3" },
|
|
2259
|
+
breadcrumbSep: { color: "#d0d5dd" },
|
|
2260
|
+
breadcrumbCurrent: { color: "#344054", fontWeight: "600" },
|
|
2261
|
+
panel: {
|
|
2262
|
+
flex: "1",
|
|
2263
|
+
minHeight: "0",
|
|
2264
|
+
overflow: "auto"
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
var SystemAdmin = defineComponent4({
|
|
2268
|
+
name: "SystemAdmin",
|
|
2269
|
+
props: {
|
|
2270
|
+
menuApi: {
|
|
2271
|
+
type: Object,
|
|
2272
|
+
required: true
|
|
2273
|
+
},
|
|
2274
|
+
resourceApi: {
|
|
2275
|
+
type: Object,
|
|
2276
|
+
required: true
|
|
2277
|
+
},
|
|
2278
|
+
defaultActiveKey: {
|
|
2279
|
+
type: String,
|
|
2280
|
+
default: SYSTEM_ADMIN_DEFAULT_KEY
|
|
2281
|
+
},
|
|
2282
|
+
activeKey: {
|
|
2283
|
+
type: String,
|
|
2284
|
+
default: void 0
|
|
2285
|
+
},
|
|
2286
|
+
title: {
|
|
2287
|
+
type: String,
|
|
2288
|
+
default: SYSTEM_ADMIN_MENU.label
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
emits: {
|
|
2292
|
+
"update:activeKey": (_key) => true,
|
|
2293
|
+
activeKeyChange: (_key) => true
|
|
2294
|
+
},
|
|
2295
|
+
setup(props, { emit, slots }) {
|
|
2296
|
+
const innerKey = ref3(props.defaultActiveKey);
|
|
2297
|
+
watch3(
|
|
2298
|
+
() => props.defaultActiveKey,
|
|
2299
|
+
(value) => {
|
|
2300
|
+
if (props.activeKey === void 0) innerKey.value = value;
|
|
2301
|
+
}
|
|
2302
|
+
);
|
|
2303
|
+
const activeKey = computed4(
|
|
2304
|
+
() => props.activeKey ?? innerKey.value
|
|
2305
|
+
);
|
|
2306
|
+
const activeLabel = computed4(
|
|
2307
|
+
() => SYSTEM_ADMIN_MENU.children.find((item) => item.key === activeKey.value)?.label ?? ""
|
|
2308
|
+
);
|
|
2309
|
+
function setActiveKey(key) {
|
|
2310
|
+
if (props.activeKey === void 0) innerKey.value = key;
|
|
2311
|
+
emit("update:activeKey", key);
|
|
2312
|
+
emit("activeKeyChange", key);
|
|
2313
|
+
}
|
|
2314
|
+
return () => h3("div", { style: s3.root }, [
|
|
2315
|
+
h3("aside", { style: s3.sidebar }, [
|
|
2316
|
+
h3("div", { style: s3.sidebarTitle }, props.title),
|
|
2317
|
+
h3(
|
|
2318
|
+
"nav",
|
|
2319
|
+
{ style: s3.nav },
|
|
2320
|
+
SYSTEM_ADMIN_MENU.children.map((item) => {
|
|
2321
|
+
const active = item.key === activeKey.value;
|
|
2322
|
+
return h3(
|
|
2323
|
+
"button",
|
|
2324
|
+
{
|
|
2325
|
+
key: item.key,
|
|
2326
|
+
type: "button",
|
|
2327
|
+
style: {
|
|
2328
|
+
...s3.navItem,
|
|
2329
|
+
...active ? s3.navItemActive : {}
|
|
2330
|
+
},
|
|
2331
|
+
onClick: () => setActiveKey(item.key)
|
|
2332
|
+
},
|
|
2333
|
+
item.label
|
|
2334
|
+
);
|
|
2335
|
+
})
|
|
2336
|
+
)
|
|
2337
|
+
]),
|
|
2338
|
+
h3("main", { style: s3.content }, [
|
|
2339
|
+
h3("div", { style: s3.contentHeader }, [
|
|
2340
|
+
h3("div", { style: s3.breadcrumb }, [
|
|
2341
|
+
h3("span", { style: s3.breadcrumbParent }, props.title),
|
|
2342
|
+
h3("span", { style: s3.breadcrumbSep }, "/"),
|
|
2343
|
+
h3("span", { style: s3.breadcrumbCurrent }, activeLabel.value)
|
|
2344
|
+
]),
|
|
2345
|
+
slots.toolbarExtra?.()
|
|
2346
|
+
]),
|
|
2347
|
+
h3("div", { style: s3.panel }, [
|
|
2348
|
+
activeKey.value === "menu" ? h3(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : h3(ResourceManager, {
|
|
2349
|
+
api: props.resourceApi,
|
|
2350
|
+
title: "\u6743\u9650\u70B9\u7BA1\u7406"
|
|
2351
|
+
})
|
|
2352
|
+
])
|
|
2353
|
+
])
|
|
2354
|
+
]);
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
1251
2357
|
export {
|
|
1252
2358
|
Can,
|
|
2359
|
+
MENU_LIST_TYPE_PARAM,
|
|
2360
|
+
MENU_TYPE_BUTTON,
|
|
2361
|
+
MENU_TYPE_LABEL,
|
|
2362
|
+
MENU_TYPE_MENU,
|
|
2363
|
+
MENU_TYPE_OPTIONS,
|
|
2364
|
+
MENU_TYPE_PAGE,
|
|
2365
|
+
MENU_VISIBILITY_OPTIONS,
|
|
2366
|
+
MenuManager,
|
|
1253
2367
|
PERMISSION_STORE_KEY,
|
|
1254
2368
|
PermissionStore,
|
|
1255
2369
|
RESOURCE_PRIVATE_OPTIONS,
|
|
@@ -1257,12 +2371,19 @@ export {
|
|
|
1257
2371
|
RESOURCE_STATUS_ENABLED,
|
|
1258
2372
|
RESOURCE_STATUS_OPTIONS,
|
|
1259
2373
|
RESOURCE_TYPE_API,
|
|
2374
|
+
ROOT_PARENT_ID,
|
|
1260
2375
|
ResourceManager,
|
|
2376
|
+
SYSTEM_ADMIN_DEFAULT_KEY,
|
|
2377
|
+
SYSTEM_ADMIN_MENU,
|
|
2378
|
+
SystemAdmin,
|
|
1261
2379
|
appendQueryParam,
|
|
1262
2380
|
buildCreateBody,
|
|
2381
|
+
buildCreateMenuBody,
|
|
1263
2382
|
buildUpdateBody,
|
|
2383
|
+
buildUpdateMenuBody,
|
|
1264
2384
|
createAuthorizationResourceApi,
|
|
1265
2385
|
createDefaultResourceRequest,
|
|
2386
|
+
createMenuResourceApi,
|
|
1266
2387
|
createPermissionPlugin,
|
|
1267
2388
|
createPermissionStore,
|
|
1268
2389
|
createVPermission,
|
|
@@ -1271,6 +2392,7 @@ export {
|
|
|
1271
2392
|
getAppClientId,
|
|
1272
2393
|
getDeviceWorkerId,
|
|
1273
2394
|
mapAuthorizationResource,
|
|
2395
|
+
mapMenuResource,
|
|
1274
2396
|
snowyflake,
|
|
1275
2397
|
useHasPermission,
|
|
1276
2398
|
useHasRole,
|