com-angel-authorization 1.0.26 → 1.0.28
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/dist/index.cjs +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +60 -7
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +61 -8
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +62 -10
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +62 -10
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -457,7 +457,7 @@ function mapMenuResource(item) {
|
|
|
457
457
|
);
|
|
458
458
|
const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
|
|
459
459
|
const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
|
|
460
|
-
const rawParentId = row.parentId ?? row.parent_id;
|
|
460
|
+
const rawParentId = row.parentId ?? row.parent_id ?? (row.parent && typeof row.parent === "object" ? row.parent.resourceId ?? row.parent.resource_id ?? row.parent.id : void 0);
|
|
461
461
|
const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
|
|
462
462
|
const rawDepth = row.depth;
|
|
463
463
|
const parsedDepth = Number(rawDepth);
|
|
@@ -614,7 +614,11 @@ function createMenuResourceApi(request) {
|
|
|
614
614
|
url: `/authorization-resources/${encodeURIComponent(resourceId)}/sub-resources`,
|
|
615
615
|
signal
|
|
616
616
|
});
|
|
617
|
-
return extractRecords(json).map(mapMenuResource).filter((item) => item !== null)
|
|
617
|
+
return extractRecords(json).map(mapMenuResource).filter((item) => item !== null).map((item) => ({
|
|
618
|
+
...item,
|
|
619
|
+
// 子资源接口常不回 parentId,用请求路径上的父级补齐
|
|
620
|
+
parentId: item.parentId ?? resourceId
|
|
621
|
+
}));
|
|
618
622
|
},
|
|
619
623
|
listPermissionPoints(params, signal) {
|
|
620
624
|
return permissionApi.list(params, signal);
|
|
@@ -1218,7 +1222,7 @@ import {
|
|
|
1218
1222
|
useMemo as useMemo3,
|
|
1219
1223
|
useState as useState3
|
|
1220
1224
|
} from "react";
|
|
1221
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1225
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1222
1226
|
var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
|
|
1223
1227
|
var emptyForm2 = () => ({
|
|
1224
1228
|
parentId: null,
|
|
@@ -1253,11 +1257,19 @@ function MenuManager({
|
|
|
1253
1257
|
const [saving, setSaving] = useState3(false);
|
|
1254
1258
|
const [deletingRow, setDeletingRow] = useState3(null);
|
|
1255
1259
|
const [deleting, setDeleting] = useState3(false);
|
|
1260
|
+
const [permissionKeyword, setPermissionKeyword] = useState3("");
|
|
1256
1261
|
const permissionNameMap = useMemo3(() => {
|
|
1257
1262
|
const map = /* @__PURE__ */ new Map();
|
|
1258
1263
|
permissionPoints.forEach((p) => map.set(p.resourceId, p.name || p.identification));
|
|
1259
1264
|
return map;
|
|
1260
1265
|
}, [permissionPoints]);
|
|
1266
|
+
const filteredPermissionPoints = useMemo3(() => {
|
|
1267
|
+
const kw = permissionKeyword.trim().toLowerCase();
|
|
1268
|
+
if (!kw) return permissionPoints;
|
|
1269
|
+
return permissionPoints.filter(
|
|
1270
|
+
(p) => p.name.toLowerCase().includes(kw) || p.identification.toLowerCase().includes(kw)
|
|
1271
|
+
);
|
|
1272
|
+
}, [permissionPoints, permissionKeyword]);
|
|
1261
1273
|
const allKnownMenus = useMemo3(() => {
|
|
1262
1274
|
const map = /* @__PURE__ */ new Map();
|
|
1263
1275
|
records.forEach((row) => map.set(row.resourceId, row));
|
|
@@ -1266,12 +1278,32 @@ function MenuManager({
|
|
|
1266
1278
|
});
|
|
1267
1279
|
return Array.from(map.values());
|
|
1268
1280
|
}, [records, childrenMap]);
|
|
1281
|
+
const resolveRowParentId = useCallback3(
|
|
1282
|
+
(row) => {
|
|
1283
|
+
if (row.parentId) return row.parentId;
|
|
1284
|
+
for (const [parentId, children] of Object.entries(childrenMap)) {
|
|
1285
|
+
if (children.some((child) => child.resourceId === row.resourceId)) {
|
|
1286
|
+
return parentId;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
return null;
|
|
1290
|
+
},
|
|
1291
|
+
[childrenMap]
|
|
1292
|
+
);
|
|
1269
1293
|
const parentOptions = useMemo3(() => {
|
|
1270
|
-
|
|
1294
|
+
const opts = allKnownMenus.filter((row) => !editing || row.resourceId !== editing.resourceId).map((row) => ({
|
|
1271
1295
|
value: row.resourceId,
|
|
1272
1296
|
label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
|
|
1273
1297
|
}));
|
|
1274
|
-
|
|
1298
|
+
if (form.parentId && !opts.some((opt) => opt.value === form.parentId)) {
|
|
1299
|
+
const parent = allKnownMenus.find((row) => row.resourceId === form.parentId);
|
|
1300
|
+
opts.unshift({
|
|
1301
|
+
value: form.parentId,
|
|
1302
|
+
label: parent ? `${parent.name}\uFF08${MENU_TYPE_LABEL[parent.type]}\uFF09` : form.parentId
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
return opts;
|
|
1306
|
+
}, [allKnownMenus, editing, form.parentId]);
|
|
1275
1307
|
const flatRows = useMemo3(() => {
|
|
1276
1308
|
const rows = [];
|
|
1277
1309
|
const walk = (list) => {
|
|
@@ -1351,6 +1383,7 @@ function MenuManager({
|
|
|
1351
1383
|
}, [api, pageSize]);
|
|
1352
1384
|
const openCreate = (parent) => {
|
|
1353
1385
|
setEditing(null);
|
|
1386
|
+
setPermissionKeyword("");
|
|
1354
1387
|
if (parent) {
|
|
1355
1388
|
setForm({
|
|
1356
1389
|
...emptyForm2(),
|
|
@@ -1364,10 +1397,12 @@ function MenuManager({
|
|
|
1364
1397
|
void loadPermissionPoints();
|
|
1365
1398
|
};
|
|
1366
1399
|
const openEdit = (row) => {
|
|
1400
|
+
const parentId = resolveRowParentId(row);
|
|
1367
1401
|
setEditing(row);
|
|
1402
|
+
setPermissionKeyword("");
|
|
1368
1403
|
setForm({
|
|
1369
|
-
parentId
|
|
1370
|
-
depth:
|
|
1404
|
+
parentId,
|
|
1405
|
+
depth: row.depth > 0 ? row.depth : resolveMenuDepth(parentId, allKnownMenus),
|
|
1371
1406
|
type: row.type,
|
|
1372
1407
|
name: row.name,
|
|
1373
1408
|
identification: row.identification,
|
|
@@ -1381,6 +1416,7 @@ function MenuManager({
|
|
|
1381
1416
|
const closeDialog = () => {
|
|
1382
1417
|
if (saving) return;
|
|
1383
1418
|
setDialogOpen(false);
|
|
1419
|
+
setPermissionKeyword("");
|
|
1384
1420
|
};
|
|
1385
1421
|
const handleSubmit = async (event) => {
|
|
1386
1422
|
event.preventDefault();
|
|
@@ -1644,7 +1680,24 @@ function MenuManager({
|
|
|
1644
1680
|
] }),
|
|
1645
1681
|
/* @__PURE__ */ jsxs2("fieldset", { style: styles2.fieldset, children: [
|
|
1646
1682
|
/* @__PURE__ */ jsx3("legend", { style: styles2.label, children: "\u6743\u9650\u6807\u8BC6" }),
|
|
1647
|
-
|
|
1683
|
+
permissionPoints.length > 0 ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1684
|
+
/* @__PURE__ */ jsx3(
|
|
1685
|
+
"input",
|
|
1686
|
+
{
|
|
1687
|
+
style: { ...styles2.input, marginBottom: 8 },
|
|
1688
|
+
value: permissionKeyword,
|
|
1689
|
+
onChange: (e) => setPermissionKeyword(e.target.value),
|
|
1690
|
+
placeholder: "\u641C\u7D22\u6743\u9650\u540D\u79F0 / \u6807\u8BC6"
|
|
1691
|
+
}
|
|
1692
|
+
),
|
|
1693
|
+
/* @__PURE__ */ jsxs2("div", { style: styles2.hint, children: [
|
|
1694
|
+
"\u5DF2\u9009 ",
|
|
1695
|
+
form.permissionPointIds.length,
|
|
1696
|
+
" \u9879",
|
|
1697
|
+
permissionKeyword.trim() ? ` \xB7 \u5339\u914D ${filteredPermissionPoints.length} / ${permissionPoints.length}` : ` \xB7 \u5171 ${permissionPoints.length} \u9879`
|
|
1698
|
+
] })
|
|
1699
|
+
] }) : null,
|
|
1700
|
+
/* @__PURE__ */ jsx3("div", { style: styles2.multiSelect, children: permissionPoints.length === 0 ? /* @__PURE__ */ jsx3("div", { style: styles2.hint, children: "\u6682\u65E0\u6743\u9650\u70B9\uFF0C\u8BF7\u5148\u5728\u6743\u9650\u70B9\u7BA1\u7406\u4E2D\u65B0\u589E" }) : filteredPermissionPoints.length === 0 ? /* @__PURE__ */ jsx3("div", { style: styles2.hint, children: "\u65E0\u5339\u914D\u6743\u9650\u70B9" }) : filteredPermissionPoints.map((p) => /* @__PURE__ */ jsxs2("label", { style: styles2.checkItem, children: [
|
|
1648
1701
|
/* @__PURE__ */ jsx3(
|
|
1649
1702
|
"input",
|
|
1650
1703
|
{
|