com-angel-authorization 1.0.16 → 1.0.18

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/vue/index.js CHANGED
@@ -498,7 +498,7 @@ function toStringArray(value) {
498
498
  }).filter(Boolean);
499
499
  }
500
500
  if (typeof value === "string" && value.trim()) {
501
- return value.split(",").map((s5) => s5.trim()).filter(Boolean);
501
+ return value.split(",").map((s6) => s6.trim()).filter(Boolean);
502
502
  }
503
503
  return [];
504
504
  }
@@ -2393,6 +2393,72 @@ function mapRolePermissions(payload) {
2393
2393
  function collectTreeResourceIds(node) {
2394
2394
  return [node.resourceId, ...node.children.flatMap(collectTreeResourceIds)];
2395
2395
  }
2396
+ function buildPermissionTreeIndex(tree) {
2397
+ const parentMap = /* @__PURE__ */ new Map();
2398
+ const nodeMap = /* @__PURE__ */ new Map();
2399
+ const walk = (nodes, parentId) => {
2400
+ for (const node of nodes) {
2401
+ parentMap.set(node.resourceId, parentId);
2402
+ nodeMap.set(node.resourceId, node);
2403
+ if (node.children.length > 0) {
2404
+ walk(node.children, node.resourceId);
2405
+ }
2406
+ }
2407
+ };
2408
+ walk(tree, null);
2409
+ return { parentMap, nodeMap };
2410
+ }
2411
+ function togglePermissionCheck(tree, checked, node) {
2412
+ const next = new Set(checked);
2413
+ const ids = collectTreeResourceIds(node);
2414
+ const shouldCheck = !checked.has(node.resourceId);
2415
+ if (shouldCheck) {
2416
+ ids.forEach((id) => next.add(id));
2417
+ } else {
2418
+ ids.forEach((id) => next.delete(id));
2419
+ }
2420
+ const { parentMap, nodeMap } = buildPermissionTreeIndex(tree);
2421
+ let parentId = parentMap.get(node.resourceId) ?? null;
2422
+ while (parentId) {
2423
+ const parent = nodeMap.get(parentId);
2424
+ if (!parent) break;
2425
+ const allChildrenChecked = parent.children.every(
2426
+ (child) => next.has(child.resourceId)
2427
+ );
2428
+ if (allChildrenChecked && parent.children.length > 0) {
2429
+ next.add(parentId);
2430
+ } else {
2431
+ next.delete(parentId);
2432
+ }
2433
+ parentId = parentMap.get(parentId) ?? null;
2434
+ }
2435
+ return next;
2436
+ }
2437
+ function countCheckedDescendants(node, checked) {
2438
+ let total = 0;
2439
+ let checkedCount = 0;
2440
+ const walk = (n) => {
2441
+ for (const child of n.children) {
2442
+ total += 1;
2443
+ if (checked.has(child.resourceId)) checkedCount += 1;
2444
+ walk(child);
2445
+ }
2446
+ };
2447
+ walk(node);
2448
+ return { total, checkedCount };
2449
+ }
2450
+ function hasCheckedDescendant(node, checked) {
2451
+ for (const child of node.children) {
2452
+ if (checked.has(child.resourceId) || hasCheckedDescendant(child, checked)) {
2453
+ return true;
2454
+ }
2455
+ }
2456
+ return false;
2457
+ }
2458
+ function isPermissionNodeIndeterminate(node, checked) {
2459
+ if (checked.has(node.resourceId) || node.children.length === 0) return false;
2460
+ return hasCheckedDescendant(node, checked);
2461
+ }
2396
2462
  function buildListUrl2(params) {
2397
2463
  const parts = [];
2398
2464
  appendQueryParam(parts, "keyword", params?.keyword ?? "");
@@ -2482,19 +2548,6 @@ function emptyForm3() {
2482
2548
  description: ""
2483
2549
  };
2484
2550
  }
2485
- function countCheckedDescendants(node, checked) {
2486
- let total = 0;
2487
- let checkedCount = 0;
2488
- const walk = (n) => {
2489
- for (const child of n.children) {
2490
- total += 1;
2491
- if (checked.has(child.resourceId)) checkedCount += 1;
2492
- walk(child);
2493
- }
2494
- };
2495
- walk(node);
2496
- return { total, checkedCount };
2497
- }
2498
2551
  var s3 = {
2499
2552
  root: {
2500
2553
  display: "flex",
@@ -2900,15 +2953,11 @@ var RoleManager = defineComponent4({
2900
2953
  };
2901
2954
  }
2902
2955
  function toggleCheck(node) {
2903
- const next = new Set(authChecked.value);
2904
- const ids = collectTreeResourceIds(node);
2905
- const shouldCheck = !authChecked.value.has(node.resourceId);
2906
- if (shouldCheck) {
2907
- ids.forEach((id) => next.add(id));
2908
- } else {
2909
- ids.forEach((id) => next.delete(id));
2910
- }
2911
- authChecked.value = next;
2956
+ authChecked.value = togglePermissionCheck(
2957
+ authTree.value,
2958
+ authChecked.value,
2959
+ node
2960
+ );
2912
2961
  }
2913
2962
  async function saveAuthorize() {
2914
2963
  if (!authRole.value) return;
@@ -2931,11 +2980,10 @@ var RoleManager = defineComponent4({
2931
2980
  const hasChildren = node.children.length > 0;
2932
2981
  const expanded = Boolean(authExpanded.value[node.resourceId]);
2933
2982
  const checked = authChecked.value.has(node.resourceId);
2934
- const { total, checkedCount } = countCheckedDescendants(
2983
+ const indeterminate = isPermissionNodeIndeterminate(
2935
2984
  node,
2936
2985
  authChecked.value
2937
2986
  );
2938
- const indeterminate = hasChildren && checkedCount > 0 && checkedCount < total && !checked;
2939
2987
  return h3("div", { key: node.resourceId }, [
2940
2988
  h3(
2941
2989
  "div",
@@ -3327,97 +3375,1146 @@ var RoleManager = defineComponent4({
3327
3375
  }
3328
3376
  });
3329
3377
 
3330
- // src/vue/SystemAdmin.ts
3331
- import { computed as computed4, defineComponent as defineComponent5, h as h4, ref as ref4, watch as watch4 } from "vue";
3378
+ // src/vue/UserManager.ts
3379
+ import {
3380
+ defineComponent as defineComponent5,
3381
+ h as h4,
3382
+ onMounted as onMounted4,
3383
+ reactive as reactive4,
3384
+ ref as ref4,
3385
+ watch as watch4
3386
+ } from "vue";
3332
3387
 
3333
- // src/admin/menu.ts
3334
- var SYSTEM_ADMIN_MENU = {
3335
- key: "system",
3336
- label: "\u7CFB\u7EDF\u7BA1\u7406",
3337
- children: [
3338
- { key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
3339
- { key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" },
3340
- { key: "role", label: "\u89D2\u8272\u7BA1\u7406" }
3341
- ]
3342
- };
3343
- var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
3388
+ // src/users/index.ts
3389
+ function asIdList(value) {
3390
+ if (!Array.isArray(value)) return [];
3391
+ return value.map((item) => {
3392
+ if (item === void 0 || item === null || item === "") return "";
3393
+ if (typeof item === "object") {
3394
+ const row = item;
3395
+ const id = row.groupId ?? row.roleId ?? row.id;
3396
+ return id === void 0 || id === null ? "" : String(id);
3397
+ }
3398
+ return String(item);
3399
+ }).filter(Boolean);
3400
+ }
3401
+ function asNameList(value) {
3402
+ if (!Array.isArray(value)) return void 0;
3403
+ const names = value.map((item) => {
3404
+ if (item === void 0 || item === null) return "";
3405
+ if (typeof item === "object") {
3406
+ return String(item.name ?? "");
3407
+ }
3408
+ return String(item);
3409
+ }).filter(Boolean);
3410
+ return names.length ? names : void 0;
3411
+ }
3412
+ function mapSystemUser(item) {
3413
+ if (!item || typeof item !== "object") return null;
3414
+ const row = item;
3415
+ const userId = row.userId ?? row.user_id ?? row.id;
3416
+ if (userId === void 0 || userId === null || userId === "") return null;
3417
+ return {
3418
+ userId: String(userId),
3419
+ username: String(row.username ?? row.account ?? ""),
3420
+ name: String(row.name ?? ""),
3421
+ groupIds: asIdList(row.groupIds ?? row.group_ids ?? row.groups),
3422
+ roleIds: asIdList(row.roleIds ?? row.role_ids ?? row.roles),
3423
+ groupNames: asNameList(row.groupNames ?? row.group_names ?? row.groups),
3424
+ roleNames: asNameList(row.roleNames ?? row.role_names ?? row.roles),
3425
+ enabled: Boolean(row.enabled ?? row.enable ?? true)
3426
+ };
3427
+ }
3428
+ function mapSystemGroupOption(item) {
3429
+ if (!item || typeof item !== "object") return null;
3430
+ const row = item;
3431
+ const groupId = row.groupId ?? row.group_id ?? row.id;
3432
+ if (groupId === void 0 || groupId === null || groupId === "") return null;
3433
+ return {
3434
+ groupId: String(groupId),
3435
+ name: String(row.name ?? "")
3436
+ };
3437
+ }
3438
+ function mapSystemRoleOption(item) {
3439
+ if (!item || typeof item !== "object") return null;
3440
+ const row = item;
3441
+ const roleId = row.roleId ?? row.role_id ?? row.id;
3442
+ if (roleId === void 0 || roleId === null || roleId === "") return null;
3443
+ return {
3444
+ roleId: String(roleId),
3445
+ name: String(row.name ?? "")
3446
+ };
3447
+ }
3448
+ function validateUsername(username) {
3449
+ const value = username.trim();
3450
+ if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
3451
+ if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
3452
+ return "\u8D26\u53F7\u9700\u540C\u65F6\u5305\u542B\u5B57\u6BCD\u548C\u6570\u5B57";
3453
+ }
3454
+ return null;
3455
+ }
3456
+ function buildListUrl3(params) {
3457
+ const parts = [];
3458
+ appendQueryParam(parts, "keyword", params?.keyword ?? "");
3459
+ if (params?.enabled !== void 0) {
3460
+ appendQueryParam(parts, "enabled", String(params.enabled));
3461
+ }
3462
+ appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
3463
+ appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
3464
+ appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
3465
+ return parts.length ? `/system/users?${parts.join("&")}` : "/system/users";
3466
+ }
3467
+ function buildKeywordUrl(base, keyword) {
3468
+ const parts = [];
3469
+ appendQueryParam(parts, "keyword", keyword ?? "");
3470
+ return parts.length ? `${base}?${parts.join("&")}` : base;
3471
+ }
3472
+ function buildCreateUserBody(values) {
3473
+ return {
3474
+ username: values.username.trim(),
3475
+ name: values.name.trim(),
3476
+ password: values.password,
3477
+ groupIds: [...new Set(values.groupIds.map(String))],
3478
+ roleIds: [...new Set(values.roleIds.map(String))],
3479
+ enabled: Boolean(values.enabled)
3480
+ };
3481
+ }
3482
+ function buildUpdateUserBody(values) {
3483
+ const body = {
3484
+ username: values.username.trim(),
3485
+ name: values.name.trim(),
3486
+ groupIds: [...new Set(values.groupIds.map(String))],
3487
+ roleIds: [...new Set(values.roleIds.map(String))],
3488
+ enabled: Boolean(values.enabled)
3489
+ };
3490
+ if (values.password.trim()) {
3491
+ body.password = values.password;
3492
+ }
3493
+ return body;
3494
+ }
3495
+ function createSystemUserApi(request) {
3496
+ return {
3497
+ async list(params, signal) {
3498
+ const json = await request({
3499
+ method: "GET",
3500
+ url: buildListUrl3(params),
3501
+ signal
3502
+ });
3503
+ const records = extractRecords(json).map(mapSystemUser).filter((item) => item !== null);
3504
+ return {
3505
+ records,
3506
+ ...extractPagination(json)
3507
+ };
3508
+ },
3509
+ async create(values, signal) {
3510
+ return request({
3511
+ method: "POST",
3512
+ url: "/system/users",
3513
+ body: buildCreateUserBody(values),
3514
+ signal
3515
+ });
3516
+ },
3517
+ async update(userId, values, signal) {
3518
+ return request({
3519
+ method: "PATCH",
3520
+ url: `/system/users/${encodeURIComponent(userId)}`,
3521
+ body: buildUpdateUserBody(values),
3522
+ signal
3523
+ });
3524
+ },
3525
+ async remove(userId, signal) {
3526
+ return request({
3527
+ method: "DELETE",
3528
+ url: `/system/users/${encodeURIComponent(userId)}`,
3529
+ signal
3530
+ });
3531
+ },
3532
+ async listGroups(params, signal) {
3533
+ const json = await request({
3534
+ method: "GET",
3535
+ url: buildKeywordUrl("/system/groups", params?.keyword),
3536
+ signal
3537
+ });
3538
+ return extractRecords(json).map(mapSystemGroupOption).filter((item) => item !== null);
3539
+ },
3540
+ async listRoleOptions(params, signal) {
3541
+ const json = await request({
3542
+ method: "GET",
3543
+ url: buildKeywordUrl("/system/roles", params?.keyword),
3544
+ signal
3545
+ });
3546
+ return extractRecords(json).map(mapSystemRoleOption).filter((item) => item !== null);
3547
+ }
3548
+ };
3549
+ }
3344
3550
 
3345
- // src/vue/SystemAdmin.ts
3551
+ // src/vue/UserManager.ts
3552
+ var PAGE_SIZE_OPTIONS4 = ["10", "20", "50", "100"];
3553
+ function emptyForm4() {
3554
+ return {
3555
+ username: "",
3556
+ name: "",
3557
+ password: "",
3558
+ groupIds: [],
3559
+ roleIds: [],
3560
+ enabled: true
3561
+ };
3562
+ }
3346
3563
  var s4 = {
3347
3564
  root: {
3348
3565
  display: "flex",
3349
- minHeight: "560px",
3566
+ flexDirection: "column",
3567
+ gap: "16px",
3568
+ padding: "16px",
3569
+ color: "#101828",
3570
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif'
3571
+ },
3572
+ toolbar: {
3573
+ display: "flex",
3574
+ alignItems: "center",
3575
+ justifyContent: "space-between",
3576
+ gap: "12px"
3577
+ },
3578
+ title: { margin: "0", fontSize: "18px", fontWeight: "600" },
3579
+ toolbarRight: { display: "flex", alignItems: "center", gap: "8px" },
3580
+ searchBar: {
3581
+ display: "flex",
3582
+ alignItems: "center",
3583
+ gap: "8px",
3584
+ flexWrap: "wrap"
3585
+ },
3586
+ error: {
3587
+ padding: "10px 12px",
3588
+ borderRadius: "8px",
3589
+ background: "#fef3f2",
3590
+ color: "#b42318",
3591
+ fontSize: "13px"
3592
+ },
3593
+ tableWrap: {
3594
+ overflow: "auto",
3350
3595
  border: "1px solid #eaecf0",
3351
- borderRadius: "12px",
3352
- overflow: "hidden",
3353
- background: "#fff",
3354
- fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
3355
- color: "#101828"
3596
+ borderRadius: "10px",
3597
+ background: "#fff"
3356
3598
  },
3357
- sidebar: {
3358
- width: "200px",
3359
- flexShrink: "0",
3360
- borderRight: "1px solid #eaecf0",
3599
+ table: { width: "100%", borderCollapse: "collapse", minWidth: "720px" },
3600
+ th: {
3601
+ textAlign: "left",
3602
+ padding: "12px 14px",
3603
+ fontSize: "13px",
3604
+ fontWeight: "600",
3605
+ color: "#475467",
3361
3606
  background: "#f9fafb",
3362
- padding: "16px 12px"
3607
+ borderBottom: "1px solid #eaecf0"
3363
3608
  },
3364
- sidebarTitle: {
3609
+ td: {
3610
+ padding: "12px 14px",
3365
3611
  fontSize: "14px",
3366
- fontWeight: "600",
3367
- color: "#344054",
3368
- padding: "4px 10px 12px"
3612
+ borderBottom: "1px solid #f2f4f7",
3613
+ verticalAlign: "middle"
3369
3614
  },
3370
- nav: {
3371
- display: "flex",
3372
- flexDirection: "column",
3373
- gap: "4px"
3615
+ empty: {
3616
+ padding: "28px",
3617
+ textAlign: "center",
3618
+ color: "#98a2b3",
3619
+ fontSize: "14px"
3374
3620
  },
3375
- navItem: {
3621
+ linkBtn: {
3376
3622
  border: "none",
3377
3623
  background: "transparent",
3378
- textAlign: "left",
3379
- padding: "10px 12px",
3380
- borderRadius: "8px",
3381
- fontSize: "14px",
3382
- color: "#475467",
3383
- cursor: "pointer"
3384
- },
3385
- navItemActive: {
3386
- background: "#e6f7f9",
3387
3624
  color: "#049BAD",
3388
- fontWeight: "600"
3625
+ cursor: "pointer",
3626
+ padding: "0 8px 0 0",
3627
+ fontSize: "13px"
3389
3628
  },
3390
- content: {
3391
- flex: "1",
3392
- minWidth: "0",
3393
- display: "flex",
3394
- flexDirection: "column",
3395
- background: "#fff"
3629
+ badge: {
3630
+ display: "inline-block",
3631
+ padding: "2px 8px",
3632
+ borderRadius: "999px",
3633
+ fontSize: "12px",
3634
+ fontWeight: "500"
3396
3635
  },
3397
- contentHeader: {
3636
+ badgeOn: { background: "#ecfdf3", color: "#027a48" },
3637
+ badgeOff: { background: "#f2f4f7", color: "#667085" },
3638
+ pagination: {
3398
3639
  display: "flex",
3399
3640
  alignItems: "center",
3400
3641
  justifyContent: "space-between",
3401
- gap: "12px",
3402
- padding: "12px 16px",
3403
- borderBottom: "1px solid #f2f4f7"
3642
+ gap: "12px"
3404
3643
  },
3405
- breadcrumb: {
3644
+ pageSize: {
3406
3645
  display: "flex",
3407
3646
  alignItems: "center",
3408
3647
  gap: "8px",
3409
- fontSize: "13px"
3648
+ fontSize: "13px",
3649
+ color: "#475467"
3410
3650
  },
3411
- breadcrumbParent: { color: "#98a2b3" },
3412
- breadcrumbSep: { color: "#d0d5dd" },
3413
- breadcrumbCurrent: { color: "#344054", fontWeight: "600" },
3414
- panel: {
3415
- flex: "1",
3416
- minHeight: "0",
3417
- overflow: "auto"
3418
- }
3651
+ pageBtns: { display: "flex", gap: "8px" },
3652
+ primaryBtn: {
3653
+ border: "none",
3654
+ background: "#049BAD",
3655
+ color: "#fff",
3656
+ borderRadius: "8px",
3657
+ padding: "8px 14px",
3658
+ cursor: "pointer",
3659
+ fontSize: "14px"
3660
+ },
3661
+ secondaryBtn: {
3662
+ border: "1px solid #d0d5dd",
3663
+ background: "#fff",
3664
+ color: "#344054",
3665
+ borderRadius: "8px",
3666
+ padding: "8px 14px",
3667
+ cursor: "pointer",
3668
+ fontSize: "14px"
3669
+ },
3670
+ dangerBtn: {
3671
+ border: "none",
3672
+ background: "#d92d20",
3673
+ color: "#fff",
3674
+ borderRadius: "8px",
3675
+ padding: "8px 14px",
3676
+ cursor: "pointer",
3677
+ fontSize: "14px"
3678
+ },
3679
+ select: {
3680
+ border: "1px solid #d0d5dd",
3681
+ borderRadius: "6px",
3682
+ padding: "4px 8px",
3683
+ fontSize: "13px",
3684
+ backgroundColor: "#ffffff",
3685
+ color: "#101828"
3686
+ },
3687
+ mask: {
3688
+ position: "fixed",
3689
+ inset: "0",
3690
+ background: "rgba(16, 24, 40, 0.45)",
3691
+ display: "flex",
3692
+ alignItems: "center",
3693
+ justifyContent: "center",
3694
+ zIndex: "1000",
3695
+ padding: "16px"
3696
+ },
3697
+ dialog: {
3698
+ width: "100%",
3699
+ maxWidth: "480px",
3700
+ background: "#fff",
3701
+ borderRadius: "12px",
3702
+ boxShadow: "0 20px 40px rgba(16,24,40,0.18)",
3703
+ maxHeight: "90vh",
3704
+ overflow: "auto"
3705
+ },
3706
+ dialogHeader: {
3707
+ display: "flex",
3708
+ alignItems: "center",
3709
+ justifyContent: "space-between",
3710
+ padding: "14px 16px",
3711
+ borderBottom: "1px solid #eaecf0",
3712
+ position: "sticky",
3713
+ top: "0",
3714
+ background: "#fff",
3715
+ zIndex: "1"
3716
+ },
3717
+ dialogTitle: { margin: "0", fontSize: "16px", fontWeight: "600" },
3718
+ iconBtn: {
3719
+ border: "none",
3720
+ background: "transparent",
3721
+ fontSize: "22px",
3722
+ lineHeight: "1",
3723
+ cursor: "pointer",
3724
+ color: "#667085"
3725
+ },
3726
+ form: {
3727
+ display: "flex",
3728
+ flexDirection: "column",
3729
+ gap: "12px",
3730
+ padding: "16px"
3731
+ },
3732
+ confirmBody: {
3733
+ display: "flex",
3734
+ flexDirection: "column",
3735
+ gap: "16px",
3736
+ padding: "16px"
3737
+ },
3738
+ confirmText: {
3739
+ margin: "0",
3740
+ fontSize: "14px",
3741
+ color: "#344054",
3742
+ lineHeight: "1.6"
3743
+ },
3744
+ field: { display: "flex", flexDirection: "column", gap: "6px" },
3745
+ fieldset: {
3746
+ border: "1px solid #eaecf0",
3747
+ borderRadius: "8px",
3748
+ margin: "0",
3749
+ padding: "10px 12px 12px"
3750
+ },
3751
+ label: { fontSize: "13px", color: "#344054", fontWeight: "500" },
3752
+ input: {
3753
+ border: "1px solid #d0d5dd",
3754
+ borderRadius: "8px",
3755
+ padding: "8px 10px",
3756
+ fontSize: "14px",
3757
+ outline: "none",
3758
+ backgroundColor: "#ffffff",
3759
+ color: "#101828",
3760
+ boxSizing: "border-box",
3761
+ width: "100%"
3762
+ },
3763
+ multiSelect: {
3764
+ display: "flex",
3765
+ flexDirection: "column",
3766
+ gap: "6px",
3767
+ maxHeight: "160px",
3768
+ overflow: "auto"
3769
+ },
3770
+ checkItem: {
3771
+ display: "flex",
3772
+ alignItems: "center",
3773
+ gap: "8px",
3774
+ fontSize: "14px",
3775
+ color: "#101828",
3776
+ cursor: "pointer"
3777
+ },
3778
+ control: {
3779
+ width: "16px",
3780
+ height: "16px",
3781
+ accentColor: "#049BAD",
3782
+ cursor: "pointer",
3783
+ colorScheme: "light",
3784
+ backgroundColor: "#ffffff"
3785
+ },
3786
+ hint: { fontSize: "13px", color: "#98a2b3", padding: "4px 0" },
3787
+ switchRow: {
3788
+ display: "flex",
3789
+ alignItems: "center",
3790
+ justifyContent: "space-between",
3791
+ gap: "12px"
3792
+ },
3793
+ switchTrack: {
3794
+ width: "44px",
3795
+ height: "24px",
3796
+ borderRadius: "999px",
3797
+ border: "none",
3798
+ padding: "2px",
3799
+ background: "#d0d5dd",
3800
+ cursor: "pointer",
3801
+ position: "relative",
3802
+ transition: "background 0.15s ease"
3803
+ },
3804
+ switchTrackOn: { background: "#049BAD" },
3805
+ switchThumb: {
3806
+ display: "block",
3807
+ width: "20px",
3808
+ height: "20px",
3809
+ borderRadius: "50%",
3810
+ background: "#fff",
3811
+ boxShadow: "0 1px 2px rgba(16,24,40,0.2)",
3812
+ transform: "translateX(0)",
3813
+ transition: "transform 0.15s ease"
3814
+ },
3815
+ switchThumbOn: { transform: "translateX(20px)" },
3816
+ dialogFooter: {
3817
+ display: "flex",
3818
+ justifyContent: "flex-end",
3819
+ gap: "8px",
3820
+ paddingTop: "4px"
3821
+ }
3822
+ };
3823
+ var UserManager = defineComponent5({
3824
+ name: "UserManager",
3825
+ props: {
3826
+ api: {
3827
+ type: Object,
3828
+ required: true
3829
+ },
3830
+ title: {
3831
+ type: String,
3832
+ default: "\u7528\u6237\u7BA1\u7406"
3833
+ },
3834
+ pageSize: {
3835
+ type: String,
3836
+ default: "20"
3837
+ }
3838
+ },
3839
+ setup(props, { slots }) {
3840
+ const records = ref4([]);
3841
+ const loading = ref4(false);
3842
+ const error = ref4("");
3843
+ const keyword = ref4("");
3844
+ const keywordInput = ref4("");
3845
+ const enabledFilter = ref4("all");
3846
+ const pageSize = ref4(props.pageSize);
3847
+ const pageToken = ref4("");
3848
+ const hasPreviousPage = ref4(false);
3849
+ const hasNextPage = ref4(false);
3850
+ const dialogOpen = ref4(false);
3851
+ const editing = ref4(null);
3852
+ const form = reactive4(emptyForm4());
3853
+ const formError = ref4("");
3854
+ const saving = ref4(false);
3855
+ const deletingRow = ref4(null);
3856
+ const deleting = ref4(false);
3857
+ const groups = ref4([]);
3858
+ const roles = ref4([]);
3859
+ const optionsLoading = ref4(false);
3860
+ function enabledParam() {
3861
+ if (enabledFilter.value === "all") return void 0;
3862
+ return enabledFilter.value === "true";
3863
+ }
3864
+ async function loadList(direction = "current", token = pageToken.value) {
3865
+ loading.value = true;
3866
+ error.value = "";
3867
+ try {
3868
+ const result = await props.api.list({
3869
+ keyword: keyword.value,
3870
+ enabled: enabledParam(),
3871
+ pagination: {
3872
+ pageToken: token,
3873
+ pageSize: pageSize.value,
3874
+ pageDirection: direction
3875
+ }
3876
+ });
3877
+ records.value = result.records;
3878
+ pageToken.value = result.pageToken;
3879
+ hasPreviousPage.value = result.hasPreviousPage;
3880
+ hasNextPage.value = result.hasNextPage;
3881
+ } catch (err) {
3882
+ error.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u5931\u8D25";
3883
+ } finally {
3884
+ loading.value = false;
3885
+ }
3886
+ }
3887
+ async function loadOptions() {
3888
+ optionsLoading.value = true;
3889
+ try {
3890
+ const [groupList, roleList] = await Promise.all([
3891
+ props.api.listGroups(),
3892
+ props.api.listRoleOptions()
3893
+ ]);
3894
+ groups.value = groupList;
3895
+ roles.value = roleList;
3896
+ } catch (err) {
3897
+ formError.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u90E8\u95E8/\u89D2\u8272\u5931\u8D25";
3898
+ } finally {
3899
+ optionsLoading.value = false;
3900
+ }
3901
+ }
3902
+ function handleSearch() {
3903
+ pageToken.value = "";
3904
+ keyword.value = keywordInput.value.trim();
3905
+ }
3906
+ function handleReset() {
3907
+ keywordInput.value = "";
3908
+ keyword.value = "";
3909
+ enabledFilter.value = "all";
3910
+ pageToken.value = "";
3911
+ }
3912
+ function openCreate() {
3913
+ editing.value = null;
3914
+ Object.assign(form, emptyForm4());
3915
+ formError.value = "";
3916
+ dialogOpen.value = true;
3917
+ void loadOptions();
3918
+ }
3919
+ function openEdit(row) {
3920
+ editing.value = row;
3921
+ Object.assign(form, {
3922
+ username: row.username,
3923
+ name: row.name,
3924
+ password: "",
3925
+ groupIds: [...row.groupIds],
3926
+ roleIds: [...row.roleIds],
3927
+ enabled: row.enabled
3928
+ });
3929
+ formError.value = "";
3930
+ dialogOpen.value = true;
3931
+ void loadOptions();
3932
+ }
3933
+ function closeDialog() {
3934
+ if (!saving.value) dialogOpen.value = false;
3935
+ }
3936
+ function toggleId(field, id) {
3937
+ const exists = form[field].includes(id);
3938
+ form[field] = exists ? form[field].filter((x) => x !== id) : [...form[field], id];
3939
+ }
3940
+ async function handleSubmit(event) {
3941
+ event.preventDefault();
3942
+ const usernameError = validateUsername(form.username);
3943
+ if (usernameError) {
3944
+ formError.value = usernameError;
3945
+ return;
3946
+ }
3947
+ if (!form.name.trim()) {
3948
+ formError.value = "\u8BF7\u586B\u5199\u7528\u6237\u540D";
3949
+ return;
3950
+ }
3951
+ if (!editing.value && !form.password.trim()) {
3952
+ formError.value = "\u8BF7\u586B\u5199\u521D\u59CB\u5BC6\u7801";
3953
+ return;
3954
+ }
3955
+ saving.value = true;
3956
+ formError.value = "";
3957
+ error.value = "";
3958
+ try {
3959
+ if (editing.value) {
3960
+ await props.api.update(editing.value.userId, { ...form });
3961
+ } else {
3962
+ await props.api.create({ ...form });
3963
+ }
3964
+ dialogOpen.value = false;
3965
+ await loadList("current", "");
3966
+ } catch (err) {
3967
+ formError.value = err instanceof Error ? err.message : "\u4FDD\u5B58\u5931\u8D25";
3968
+ } finally {
3969
+ saving.value = false;
3970
+ }
3971
+ }
3972
+ function askDelete(row) {
3973
+ deletingRow.value = row;
3974
+ }
3975
+ function closeDeleteDialog() {
3976
+ if (!deleting.value) deletingRow.value = null;
3977
+ }
3978
+ async function confirmDelete() {
3979
+ if (!deletingRow.value) return;
3980
+ deleting.value = true;
3981
+ error.value = "";
3982
+ try {
3983
+ await props.api.remove(deletingRow.value.userId);
3984
+ deletingRow.value = null;
3985
+ await loadList("current", "");
3986
+ } catch (err) {
3987
+ error.value = err instanceof Error ? err.message : "\u5220\u9664\u5931\u8D25";
3988
+ } finally {
3989
+ deleting.value = false;
3990
+ }
3991
+ }
3992
+ function groupLabel(row) {
3993
+ if (row.groupNames?.length) return row.groupNames.join("\u3001");
3994
+ if (!row.groupIds.length) return "\u2014";
3995
+ const map = new Map(groups.value.map((g) => [g.groupId, g.name]));
3996
+ return row.groupIds.map((id) => map.get(id) || id).join("\u3001");
3997
+ }
3998
+ function roleLabel(row) {
3999
+ if (row.roleNames?.length) return row.roleNames.join("\u3001");
4000
+ if (!row.roleIds.length) return "\u2014";
4001
+ const map = new Map(roles.value.map((r) => [r.roleId, r.name]));
4002
+ return row.roleIds.map((id) => map.get(id) || id).join("\u3001");
4003
+ }
4004
+ onMounted4(() => {
4005
+ void loadList("current", "");
4006
+ void (async () => {
4007
+ try {
4008
+ const [groupList, roleList] = await Promise.all([
4009
+ props.api.listGroups(),
4010
+ props.api.listRoleOptions()
4011
+ ]);
4012
+ groups.value = groupList;
4013
+ roles.value = roleList;
4014
+ } catch {
4015
+ }
4016
+ })();
4017
+ });
4018
+ watch4(
4019
+ () => [
4020
+ props.api,
4021
+ pageSize.value,
4022
+ keyword.value,
4023
+ enabledFilter.value
4024
+ ],
4025
+ () => {
4026
+ pageToken.value = "";
4027
+ void loadList("current", "");
4028
+ }
4029
+ );
4030
+ return () => h4("div", { style: s4.root }, [
4031
+ h4("div", { style: s4.toolbar }, [
4032
+ h4("h2", { style: s4.title }, props.title),
4033
+ h4("div", { style: s4.toolbarRight }, [
4034
+ slots.toolbarExtra?.(),
4035
+ h4(
4036
+ "button",
4037
+ { type: "button", style: s4.primaryBtn, onClick: openCreate },
4038
+ "\u65B0\u589E\u7528\u6237"
4039
+ )
4040
+ ])
4041
+ ]),
4042
+ h4("div", { style: s4.searchBar }, [
4043
+ h4("input", {
4044
+ style: { ...s4.input, maxWidth: "240px" },
4045
+ value: keywordInput.value,
4046
+ placeholder: "\u641C\u7D22\u8D26\u53F7 / \u7528\u6237\u540D",
4047
+ onInput: (e) => {
4048
+ keywordInput.value = e.target.value;
4049
+ },
4050
+ onKeydown: (e) => {
4051
+ if (e.key === "Enter") handleSearch();
4052
+ }
4053
+ }),
4054
+ h4(
4055
+ "select",
4056
+ {
4057
+ style: s4.select,
4058
+ value: enabledFilter.value,
4059
+ onChange: (e) => {
4060
+ pageToken.value = "";
4061
+ enabledFilter.value = e.target.value;
4062
+ }
4063
+ },
4064
+ [
4065
+ h4("option", { value: "all" }, "\u5168\u90E8\u72B6\u6001"),
4066
+ h4("option", { value: "true" }, "\u5DF2\u542F\u7528"),
4067
+ h4("option", { value: "false" }, "\u5DF2\u7981\u7528")
4068
+ ]
4069
+ ),
4070
+ h4(
4071
+ "button",
4072
+ { type: "button", style: s4.secondaryBtn, onClick: handleSearch },
4073
+ "\u67E5\u8BE2"
4074
+ ),
4075
+ h4(
4076
+ "button",
4077
+ { type: "button", style: s4.secondaryBtn, onClick: handleReset },
4078
+ "\u91CD\u7F6E"
4079
+ )
4080
+ ]),
4081
+ error.value ? h4("div", { style: s4.error }, error.value) : null,
4082
+ h4("div", { style: s4.tableWrap }, [
4083
+ h4("table", { style: s4.table }, [
4084
+ h4("thead", [
4085
+ h4("tr", [
4086
+ h4("th", { style: s4.th }, "\u8D26\u53F7"),
4087
+ h4("th", { style: s4.th }, "\u7528\u6237\u540D"),
4088
+ h4("th", { style: s4.th }, "\u5F52\u5C5E\u90E8\u95E8"),
4089
+ h4("th", { style: s4.th }, "\u7528\u6237\u89D2\u8272"),
4090
+ h4("th", { style: { ...s4.th, width: "90px" } }, "\u72B6\u6001"),
4091
+ h4("th", { style: { ...s4.th, width: "140px" } }, "\u64CD\u4F5C")
4092
+ ])
4093
+ ]),
4094
+ h4(
4095
+ "tbody",
4096
+ loading.value ? [
4097
+ h4("tr", [
4098
+ h4("td", { colspan: 6, style: s4.empty }, "\u52A0\u8F7D\u4E2D\u2026")
4099
+ ])
4100
+ ] : records.value.length === 0 ? [
4101
+ h4("tr", [
4102
+ h4("td", { colspan: 6, style: s4.empty }, "\u6682\u65E0\u6570\u636E")
4103
+ ])
4104
+ ] : records.value.map(
4105
+ (row) => h4("tr", { key: row.userId }, [
4106
+ h4("td", { style: s4.td }, row.username),
4107
+ h4("td", { style: s4.td }, row.name),
4108
+ h4("td", { style: s4.td }, groupLabel(row)),
4109
+ h4("td", { style: s4.td }, roleLabel(row)),
4110
+ h4("td", { style: s4.td }, [
4111
+ h4(
4112
+ "span",
4113
+ {
4114
+ style: {
4115
+ ...s4.badge,
4116
+ ...row.enabled ? s4.badgeOn : s4.badgeOff
4117
+ }
4118
+ },
4119
+ row.enabled ? "\u542F\u7528" : "\u7981\u7528"
4120
+ )
4121
+ ]),
4122
+ h4("td", { style: s4.td }, [
4123
+ h4(
4124
+ "button",
4125
+ {
4126
+ type: "button",
4127
+ style: s4.linkBtn,
4128
+ onClick: () => openEdit(row)
4129
+ },
4130
+ "\u7F16\u8F91"
4131
+ ),
4132
+ h4(
4133
+ "button",
4134
+ {
4135
+ type: "button",
4136
+ style: { ...s4.linkBtn, color: "#d92d20" },
4137
+ onClick: () => askDelete(row)
4138
+ },
4139
+ "\u5220\u9664"
4140
+ )
4141
+ ])
4142
+ ])
4143
+ )
4144
+ )
4145
+ ])
4146
+ ]),
4147
+ h4("div", { style: s4.pagination }, [
4148
+ h4("label", { style: s4.pageSize }, [
4149
+ "\u6BCF\u9875",
4150
+ h4(
4151
+ "select",
4152
+ {
4153
+ style: s4.select,
4154
+ value: pageSize.value,
4155
+ onChange: (e) => {
4156
+ pageSize.value = e.target.value;
4157
+ }
4158
+ },
4159
+ PAGE_SIZE_OPTIONS4.map(
4160
+ (size) => h4("option", { key: size, value: size }, size)
4161
+ )
4162
+ )
4163
+ ]),
4164
+ h4("div", { style: s4.pageBtns }, [
4165
+ h4(
4166
+ "button",
4167
+ {
4168
+ type: "button",
4169
+ style: s4.secondaryBtn,
4170
+ disabled: !hasPreviousPage.value || loading.value,
4171
+ onClick: () => void loadList("previous")
4172
+ },
4173
+ "\u4E0A\u4E00\u9875"
4174
+ ),
4175
+ h4(
4176
+ "button",
4177
+ {
4178
+ type: "button",
4179
+ style: s4.secondaryBtn,
4180
+ disabled: !hasNextPage.value || loading.value,
4181
+ onClick: () => void loadList("next")
4182
+ },
4183
+ "\u4E0B\u4E00\u9875"
4184
+ )
4185
+ ])
4186
+ ]),
4187
+ dialogOpen.value ? h4("div", { style: s4.mask, onClick: closeDialog }, [
4188
+ h4(
4189
+ "div",
4190
+ {
4191
+ style: { ...s4.dialog, maxWidth: "560px" },
4192
+ role: "dialog",
4193
+ "aria-modal": "true",
4194
+ onClick: (e) => e.stopPropagation()
4195
+ },
4196
+ [
4197
+ h4("div", { style: s4.dialogHeader }, [
4198
+ h4(
4199
+ "h3",
4200
+ { style: s4.dialogTitle },
4201
+ editing.value ? "\u7F16\u8F91\u7528\u6237" : "\u65B0\u589E\u7528\u6237"
4202
+ ),
4203
+ h4(
4204
+ "button",
4205
+ {
4206
+ type: "button",
4207
+ style: s4.iconBtn,
4208
+ "aria-label": "\u5173\u95ED",
4209
+ onClick: closeDialog
4210
+ },
4211
+ "\xD7"
4212
+ )
4213
+ ]),
4214
+ h4(
4215
+ "form",
4216
+ {
4217
+ style: s4.form,
4218
+ onSubmit: (e) => void handleSubmit(e)
4219
+ },
4220
+ [
4221
+ formError.value ? h4("div", { style: s4.error }, formError.value) : null,
4222
+ h4("label", { style: s4.field }, [
4223
+ h4("span", { style: s4.label }, "\u8D26\u53F7"),
4224
+ h4("input", {
4225
+ style: s4.input,
4226
+ value: form.username,
4227
+ placeholder: "\u81F3\u5C116\u4F4D\uFF0C\u9700\u542B\u5B57\u6BCD\u548C\u6570\u5B57",
4228
+ required: true,
4229
+ onInput: (e) => {
4230
+ form.username = e.target.value;
4231
+ }
4232
+ })
4233
+ ]),
4234
+ h4("label", { style: s4.field }, [
4235
+ h4("span", { style: s4.label }, "\u7528\u6237\u540D"),
4236
+ h4("input", {
4237
+ style: s4.input,
4238
+ value: form.name,
4239
+ placeholder: "\u8BF7\u8F93\u5165\u7528\u6237\u540D",
4240
+ required: true,
4241
+ onInput: (e) => {
4242
+ form.name = e.target.value;
4243
+ }
4244
+ })
4245
+ ]),
4246
+ h4("label", { style: s4.field }, [
4247
+ h4(
4248
+ "span",
4249
+ { style: s4.label },
4250
+ editing.value ? "\u5BC6\u7801\uFF08\u7559\u7A7A\u5219\u4E0D\u4FEE\u6539\uFF09" : "\u521D\u59CB\u5BC6\u7801"
4251
+ ),
4252
+ h4("input", {
4253
+ style: s4.input,
4254
+ type: "password",
4255
+ value: form.password,
4256
+ placeholder: editing.value ? "\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539\u5BC6\u7801" : "\u8BF7\u8F93\u5165\u521D\u59CB\u5BC6\u7801",
4257
+ required: !editing.value,
4258
+ autocomplete: "new-password",
4259
+ onInput: (e) => {
4260
+ form.password = e.target.value;
4261
+ }
4262
+ })
4263
+ ]),
4264
+ h4("fieldset", { style: s4.fieldset }, [
4265
+ h4("legend", { style: s4.label }, "\u5F52\u5C5E\u90E8\u95E8"),
4266
+ h4("div", { style: s4.multiSelect }, [
4267
+ optionsLoading.value ? h4("div", { style: s4.hint }, "\u52A0\u8F7D\u4E2D\u2026") : groups.value.length === 0 ? h4("div", { style: s4.hint }, "\u6682\u65E0\u90E8\u95E8\u6570\u636E") : groups.value.map(
4268
+ (g) => h4(
4269
+ "label",
4270
+ {
4271
+ key: g.groupId,
4272
+ style: s4.checkItem
4273
+ },
4274
+ [
4275
+ h4("input", {
4276
+ type: "checkbox",
4277
+ style: s4.control,
4278
+ checked: form.groupIds.includes(
4279
+ g.groupId
4280
+ ),
4281
+ onChange: () => toggleId("groupIds", g.groupId)
4282
+ }),
4283
+ h4("span", g.name || g.groupId)
4284
+ ]
4285
+ )
4286
+ )
4287
+ ])
4288
+ ]),
4289
+ h4("fieldset", { style: s4.fieldset }, [
4290
+ h4("legend", { style: s4.label }, "\u7528\u6237\u89D2\u8272"),
4291
+ h4("div", { style: s4.multiSelect }, [
4292
+ optionsLoading.value ? h4("div", { style: s4.hint }, "\u52A0\u8F7D\u4E2D\u2026") : roles.value.length === 0 ? h4("div", { style: s4.hint }, "\u6682\u65E0\u89D2\u8272\u6570\u636E") : roles.value.map(
4293
+ (r) => h4(
4294
+ "label",
4295
+ {
4296
+ key: r.roleId,
4297
+ style: s4.checkItem
4298
+ },
4299
+ [
4300
+ h4("input", {
4301
+ type: "checkbox",
4302
+ style: s4.control,
4303
+ checked: form.roleIds.includes(
4304
+ r.roleId
4305
+ ),
4306
+ onChange: () => toggleId("roleIds", r.roleId)
4307
+ }),
4308
+ h4("span", r.name || r.roleId)
4309
+ ]
4310
+ )
4311
+ )
4312
+ ])
4313
+ ]),
4314
+ h4("div", { style: s4.switchRow }, [
4315
+ h4("span", { style: s4.label }, "\u662F\u5426\u542F\u7528"),
4316
+ h4(
4317
+ "button",
4318
+ {
4319
+ type: "button",
4320
+ role: "switch",
4321
+ "aria-checked": form.enabled,
4322
+ style: {
4323
+ ...s4.switchTrack,
4324
+ ...form.enabled ? s4.switchTrackOn : {}
4325
+ },
4326
+ onClick: () => {
4327
+ form.enabled = !form.enabled;
4328
+ }
4329
+ },
4330
+ [
4331
+ h4("span", {
4332
+ style: {
4333
+ ...s4.switchThumb,
4334
+ ...form.enabled ? s4.switchThumbOn : {}
4335
+ }
4336
+ })
4337
+ ]
4338
+ )
4339
+ ]),
4340
+ h4("div", { style: s4.dialogFooter }, [
4341
+ h4(
4342
+ "button",
4343
+ {
4344
+ type: "button",
4345
+ style: s4.secondaryBtn,
4346
+ onClick: closeDialog
4347
+ },
4348
+ "\u53D6\u6D88"
4349
+ ),
4350
+ h4(
4351
+ "button",
4352
+ {
4353
+ type: "submit",
4354
+ style: s4.primaryBtn,
4355
+ disabled: saving.value
4356
+ },
4357
+ saving.value ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"
4358
+ )
4359
+ ])
4360
+ ]
4361
+ )
4362
+ ]
4363
+ )
4364
+ ]) : null,
4365
+ deletingRow.value ? h4("div", { style: s4.mask, onClick: closeDeleteDialog }, [
4366
+ h4(
4367
+ "div",
4368
+ {
4369
+ style: { ...s4.dialog, maxWidth: "420px" },
4370
+ role: "dialog",
4371
+ "aria-modal": "true",
4372
+ onClick: (e) => e.stopPropagation()
4373
+ },
4374
+ [
4375
+ h4("div", { style: s4.dialogHeader }, [
4376
+ h4("h3", { style: s4.dialogTitle }, "\u786E\u8BA4\u5220\u9664"),
4377
+ h4(
4378
+ "button",
4379
+ {
4380
+ type: "button",
4381
+ style: s4.iconBtn,
4382
+ "aria-label": "\u5173\u95ED",
4383
+ onClick: closeDeleteDialog
4384
+ },
4385
+ "\xD7"
4386
+ )
4387
+ ]),
4388
+ h4("div", { style: s4.confirmBody }, [
4389
+ h4("p", { style: s4.confirmText }, [
4390
+ "\u786E\u8BA4\u5220\u9664\u7528\u6237\u300C",
4391
+ h4("strong", deletingRow.value.name),
4392
+ "\u300D\uFF08",
4393
+ deletingRow.value.username,
4394
+ "\uFF09\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002"
4395
+ ]),
4396
+ h4("div", { style: s4.dialogFooter }, [
4397
+ h4(
4398
+ "button",
4399
+ {
4400
+ type: "button",
4401
+ style: s4.secondaryBtn,
4402
+ disabled: deleting.value,
4403
+ onClick: closeDeleteDialog
4404
+ },
4405
+ "\u53D6\u6D88"
4406
+ ),
4407
+ h4(
4408
+ "button",
4409
+ {
4410
+ type: "button",
4411
+ style: s4.dangerBtn,
4412
+ disabled: deleting.value,
4413
+ onClick: () => void confirmDelete()
4414
+ },
4415
+ deleting.value ? "\u5220\u9664\u4E2D\u2026" : "\u786E\u8BA4\u5220\u9664"
4416
+ )
4417
+ ])
4418
+ ])
4419
+ ]
4420
+ )
4421
+ ]) : null
4422
+ ]);
4423
+ }
4424
+ });
4425
+
4426
+ // src/vue/SystemAdmin.ts
4427
+ import { computed as computed4, defineComponent as defineComponent6, h as h5, ref as ref5, watch as watch5 } from "vue";
4428
+
4429
+ // src/admin/menu.ts
4430
+ var SYSTEM_ADMIN_MENU = {
4431
+ key: "system",
4432
+ label: "\u7CFB\u7EDF\u7BA1\u7406",
4433
+ children: [
4434
+ { key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
4435
+ { key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" },
4436
+ { key: "role", label: "\u89D2\u8272\u7BA1\u7406" },
4437
+ { key: "user", label: "\u7528\u6237\u7BA1\u7406" }
4438
+ ]
4439
+ };
4440
+ var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
4441
+
4442
+ // src/vue/SystemAdmin.ts
4443
+ var s5 = {
4444
+ root: {
4445
+ display: "flex",
4446
+ minHeight: "560px",
4447
+ border: "1px solid #eaecf0",
4448
+ borderRadius: "12px",
4449
+ overflow: "hidden",
4450
+ background: "#fff",
4451
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
4452
+ color: "#101828"
4453
+ },
4454
+ sidebar: {
4455
+ width: "200px",
4456
+ flexShrink: "0",
4457
+ borderRight: "1px solid #eaecf0",
4458
+ background: "#f9fafb",
4459
+ padding: "16px 12px"
4460
+ },
4461
+ sidebarTitle: {
4462
+ fontSize: "14px",
4463
+ fontWeight: "600",
4464
+ color: "#344054",
4465
+ padding: "4px 10px 12px"
4466
+ },
4467
+ nav: {
4468
+ display: "flex",
4469
+ flexDirection: "column",
4470
+ gap: "4px"
4471
+ },
4472
+ navItem: {
4473
+ border: "none",
4474
+ background: "transparent",
4475
+ textAlign: "left",
4476
+ padding: "10px 12px",
4477
+ borderRadius: "8px",
4478
+ fontSize: "14px",
4479
+ color: "#475467",
4480
+ cursor: "pointer"
4481
+ },
4482
+ navItemActive: {
4483
+ background: "#e6f7f9",
4484
+ color: "#049BAD",
4485
+ fontWeight: "600"
4486
+ },
4487
+ content: {
4488
+ flex: "1",
4489
+ minWidth: "0",
4490
+ display: "flex",
4491
+ flexDirection: "column",
4492
+ background: "#fff"
4493
+ },
4494
+ contentHeader: {
4495
+ display: "flex",
4496
+ alignItems: "center",
4497
+ justifyContent: "space-between",
4498
+ gap: "12px",
4499
+ padding: "12px 16px",
4500
+ borderBottom: "1px solid #f2f4f7"
4501
+ },
4502
+ breadcrumb: {
4503
+ display: "flex",
4504
+ alignItems: "center",
4505
+ gap: "8px",
4506
+ fontSize: "13px"
4507
+ },
4508
+ breadcrumbParent: { color: "#98a2b3" },
4509
+ breadcrumbSep: { color: "#d0d5dd" },
4510
+ breadcrumbCurrent: { color: "#344054", fontWeight: "600" },
4511
+ panel: {
4512
+ flex: "1",
4513
+ minHeight: "0",
4514
+ overflow: "auto"
4515
+ }
3419
4516
  };
3420
- var SystemAdmin = defineComponent5({
4517
+ var SystemAdmin = defineComponent6({
3421
4518
  name: "SystemAdmin",
3422
4519
  props: {
3423
4520
  menuApi: {
@@ -3432,6 +4529,10 @@ var SystemAdmin = defineComponent5({
3432
4529
  type: Object,
3433
4530
  required: true
3434
4531
  },
4532
+ userApi: {
4533
+ type: Object,
4534
+ required: true
4535
+ },
3435
4536
  defaultActiveKey: {
3436
4537
  type: String,
3437
4538
  default: SYSTEM_ADMIN_DEFAULT_KEY
@@ -3450,8 +4551,8 @@ var SystemAdmin = defineComponent5({
3450
4551
  activeKeyChange: (_key) => true
3451
4552
  },
3452
4553
  setup(props, { emit, slots }) {
3453
- const innerKey = ref4(props.defaultActiveKey);
3454
- watch4(
4554
+ const innerKey = ref5(props.defaultActiveKey);
4555
+ watch5(
3455
4556
  () => props.defaultActiveKey,
3456
4557
  (value) => {
3457
4558
  if (props.activeKey === void 0) innerKey.value = value;
@@ -3468,22 +4569,22 @@ var SystemAdmin = defineComponent5({
3468
4569
  emit("update:activeKey", key);
3469
4570
  emit("activeKeyChange", key);
3470
4571
  }
3471
- return () => h4("div", { style: s4.root }, [
3472
- h4("aside", { style: s4.sidebar }, [
3473
- h4("div", { style: s4.sidebarTitle }, props.title),
3474
- h4(
4572
+ return () => h5("div", { style: s5.root }, [
4573
+ h5("aside", { style: s5.sidebar }, [
4574
+ h5("div", { style: s5.sidebarTitle }, props.title),
4575
+ h5(
3475
4576
  "nav",
3476
- { style: s4.nav },
4577
+ { style: s5.nav },
3477
4578
  SYSTEM_ADMIN_MENU.children.map((item) => {
3478
4579
  const active = item.key === activeKey.value;
3479
- return h4(
4580
+ return h5(
3480
4581
  "button",
3481
4582
  {
3482
4583
  key: item.key,
3483
4584
  type: "button",
3484
4585
  style: {
3485
- ...s4.navItem,
3486
- ...active ? s4.navItemActive : {}
4586
+ ...s5.navItem,
4587
+ ...active ? s5.navItemActive : {}
3487
4588
  },
3488
4589
  onClick: () => setActiveKey(item.key)
3489
4590
  },
@@ -3492,20 +4593,20 @@ var SystemAdmin = defineComponent5({
3492
4593
  })
3493
4594
  )
3494
4595
  ]),
3495
- h4("main", { style: s4.content }, [
3496
- h4("div", { style: s4.contentHeader }, [
3497
- h4("div", { style: s4.breadcrumb }, [
3498
- h4("span", { style: s4.breadcrumbParent }, props.title),
3499
- h4("span", { style: s4.breadcrumbSep }, "/"),
3500
- h4("span", { style: s4.breadcrumbCurrent }, activeLabel.value)
4596
+ h5("main", { style: s5.content }, [
4597
+ h5("div", { style: s5.contentHeader }, [
4598
+ h5("div", { style: s5.breadcrumb }, [
4599
+ h5("span", { style: s5.breadcrumbParent }, props.title),
4600
+ h5("span", { style: s5.breadcrumbSep }, "/"),
4601
+ h5("span", { style: s5.breadcrumbCurrent }, activeLabel.value)
3501
4602
  ]),
3502
4603
  slots.toolbarExtra?.()
3503
4604
  ]),
3504
- h4("div", { style: s4.panel }, [
3505
- activeKey.value === "menu" ? h4(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : activeKey.value === "resource" ? h4(ResourceManager, {
4605
+ h5("div", { style: s5.panel }, [
4606
+ activeKey.value === "menu" ? h5(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : activeKey.value === "resource" ? h5(ResourceManager, {
3506
4607
  api: props.resourceApi,
3507
4608
  title: "\u6743\u9650\u70B9\u7BA1\u7406"
3508
- }) : h4(RoleManager, { api: props.roleApi, title: "\u89D2\u8272\u7BA1\u7406" })
4609
+ }) : activeKey.value === "role" ? h5(RoleManager, { api: props.roleApi, title: "\u89D2\u8272\u7BA1\u7406" }) : h5(UserManager, { api: props.userApi, title: "\u7528\u6237\u7BA1\u7406" })
3509
4610
  ])
3510
4611
  ])
3511
4612
  ]);
@@ -3537,36 +4638,49 @@ export {
3537
4638
  SYSTEM_ADMIN_DEFAULT_KEY,
3538
4639
  SYSTEM_ADMIN_MENU,
3539
4640
  SystemAdmin,
4641
+ UserManager,
3540
4642
  appendQueryParam,
3541
4643
  buildCreateBody,
3542
4644
  buildCreateMenuBody,
3543
4645
  buildCreateRoleBody,
4646
+ buildCreateUserBody,
4647
+ buildPermissionTreeIndex,
3544
4648
  buildSavePermissionsBody,
3545
4649
  buildUpdateBody,
3546
4650
  buildUpdateMenuBody,
3547
4651
  buildUpdateRoleBody,
4652
+ buildUpdateUserBody,
3548
4653
  collectTreeResourceIds,
4654
+ countCheckedDescendants,
3549
4655
  createAuthorizationResourceApi,
3550
4656
  createDefaultResourceRequest,
3551
4657
  createMenuResourceApi,
3552
4658
  createPermissionPlugin,
3553
4659
  createPermissionStore,
3554
4660
  createSystemRoleApi,
4661
+ createSystemUserApi,
3555
4662
  createVPermission,
3556
4663
  extractPagination,
3557
4664
  extractRecords,
3558
4665
  getAppClientId,
3559
4666
  getDeviceWorkerId,
4667
+ hasCheckedDescendant,
3560
4668
  isMenuLeaf,
4669
+ isPermissionNodeIndeterminate,
3561
4670
  mapAuthorizationResource,
3562
4671
  mapMenuResource,
3563
4672
  mapPermissionTreeNode,
3564
4673
  mapRolePermissions,
4674
+ mapSystemGroupOption,
3565
4675
  mapSystemRole,
4676
+ mapSystemRoleOption,
4677
+ mapSystemUser,
3566
4678
  resolveMenuDepth,
3567
4679
  snowyflake,
4680
+ togglePermissionCheck,
3568
4681
  useHasPermission,
3569
4682
  useHasRole,
3570
- usePermission
4683
+ usePermission,
4684
+ validateUsername
3571
4685
  };
3572
4686
  //# sourceMappingURL=index.js.map