com-angel-authorization 1.0.29 → 1.0.31

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.
@@ -503,6 +503,7 @@ type SystemUserApi = {
503
503
  create: (values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
504
504
  update: (userId: string, values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
505
505
  remove: (userId: string, signal?: AbortSignal) => Promise<unknown>;
506
+ resetPassword: (userId: string, password: string, signal?: AbortSignal) => Promise<unknown>;
506
507
  listGroups: (params?: FetchSystemGroupsParams, signal?: AbortSignal) => Promise<SystemGroupOption[]>;
507
508
  listRoleOptions: (params?: FetchSystemRoleOptionsParams, signal?: AbortSignal) => Promise<SystemRoleOption[]>;
508
509
  };
@@ -510,7 +511,7 @@ declare function mapSystemUser(item: unknown): SystemUser | null;
510
511
  declare function mapSystemGroupOption(item: unknown): SystemGroupOption | null;
511
512
  declare function mapSystemRoleOption(item: unknown): SystemRoleOption | null;
512
513
  /**
513
- * 账号校验:不少于 6 位,且同时包含字母与数字。
514
+ * 账号校验:长度大于 1;须含英文字母,可搭配数字;不支持中文或特殊符号。
514
515
  * 通过返回 null,失败返回错误文案。
515
516
  */
516
517
  declare function validateUsername(username: string): string | null;
@@ -503,6 +503,7 @@ type SystemUserApi = {
503
503
  create: (values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
504
504
  update: (userId: string, values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
505
505
  remove: (userId: string, signal?: AbortSignal) => Promise<unknown>;
506
+ resetPassword: (userId: string, password: string, signal?: AbortSignal) => Promise<unknown>;
506
507
  listGroups: (params?: FetchSystemGroupsParams, signal?: AbortSignal) => Promise<SystemGroupOption[]>;
507
508
  listRoleOptions: (params?: FetchSystemRoleOptionsParams, signal?: AbortSignal) => Promise<SystemRoleOption[]>;
508
509
  };
@@ -510,7 +511,7 @@ declare function mapSystemUser(item: unknown): SystemUser | null;
510
511
  declare function mapSystemGroupOption(item: unknown): SystemGroupOption | null;
511
512
  declare function mapSystemRoleOption(item: unknown): SystemRoleOption | null;
512
513
  /**
513
- * 账号校验:不少于 6 位,且同时包含字母与数字。
514
+ * 账号校验:长度大于 1;须含英文字母,可搭配数字;不支持中文或特殊符号。
514
515
  * 通过返回 null,失败返回错误文案。
515
516
  */
516
517
  declare function validateUsername(username: string): string | null;
@@ -1613,11 +1613,10 @@ function MenuManager({
1613
1613
  )
1614
1614
  ] })
1615
1615
  ] }),
1616
- dialogOpen ? /* @__PURE__ */ jsx3("div", { style: styles2.mask, onClick: closeDialog, children: /* @__PURE__ */ jsxs2(
1616
+ dialogOpen ? /* @__PURE__ */ jsx3("div", { style: styles2.mask, children: /* @__PURE__ */ jsxs2(
1617
1617
  "div",
1618
1618
  {
1619
1619
  style: { ...styles2.dialog, maxWidth: 520 },
1620
- onClick: (e) => e.stopPropagation(),
1621
1620
  role: "dialog",
1622
1621
  "aria-modal": "true",
1623
1622
  children: [
@@ -1753,10 +1752,7 @@ function MenuManager({
1753
1752
  opt.label
1754
1753
  ] }, opt.value)) })
1755
1754
  ] }),
1756
- /* @__PURE__ */ jsxs2("div", { style: styles2.dialogFooter, children: [
1757
- /* @__PURE__ */ jsx3("button", { type: "button", style: styles2.secondaryBtn, onClick: closeDialog, children: "\u53D6\u6D88" }),
1758
- /* @__PURE__ */ jsx3("button", { type: "submit", style: styles2.primaryBtn, disabled: saving, children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58" })
1759
- ] })
1755
+ /* @__PURE__ */ jsx3("div", { style: styles2.dialogFooter, children: /* @__PURE__ */ jsx3("button", { type: "submit", style: styles2.primaryBtn, disabled: saving, children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58" }) })
1760
1756
  ] })
1761
1757
  ]
1762
1758
  }
@@ -3029,9 +3025,9 @@ function mapSystemRoleOption(item) {
3029
3025
  }
3030
3026
  function validateUsername(username) {
3031
3027
  const value = username.trim();
3032
- if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
3033
- if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
3034
- return "\u8D26\u53F7\u9700\u540C\u65F6\u5305\u542B\u5B57\u6BCD\u548C\u6570\u5B57";
3028
+ if (value.length <= 1) return "\u8D26\u53F7\u957F\u5EA6\u9700\u5927\u4E8E 1";
3029
+ if (!/^(?=.*[A-Za-z])[A-Za-z0-9]+$/.test(value)) {
3030
+ return "\u8D26\u53F7\u9700\u5305\u542B\u82F1\u6587\u5B57\u6BCD\uFF0C\u53EF\u642D\u914D\u6570\u5B57\uFF0C\u4E0D\u652F\u6301\u4E2D\u6587\u6216\u7279\u6B8A\u7B26\u53F7\u3002";
3035
3031
  }
3036
3032
  return null;
3037
3033
  }
@@ -3111,6 +3107,14 @@ function createSystemUserApi(request) {
3111
3107
  signal
3112
3108
  });
3113
3109
  },
3110
+ async resetPassword(userId, password, signal) {
3111
+ return request({
3112
+ method: "POST",
3113
+ url: `/system/users/${encodeURIComponent(userId)}/reset-password`,
3114
+ body: { password },
3115
+ signal
3116
+ });
3117
+ },
3114
3118
  async listGroups(params, signal) {
3115
3119
  const json = await request({
3116
3120
  method: "GET",
@@ -3164,6 +3168,10 @@ function UserManager({
3164
3168
  const [saving, setSaving] = useState5(false);
3165
3169
  const [deletingRow, setDeletingRow] = useState5(null);
3166
3170
  const [deleting, setDeleting] = useState5(false);
3171
+ const [resetRow, setResetRow] = useState5(null);
3172
+ const [resetPassword, setResetPassword] = useState5("");
3173
+ const [resetError, setResetError] = useState5("");
3174
+ const [resetting, setResetting] = useState5(false);
3167
3175
  const [groups, setGroups] = useState5([]);
3168
3176
  const [roles, setRoles] = useState5([]);
3169
3177
  const [rolesLoading, setRolesLoading] = useState5(false);
@@ -3327,6 +3335,38 @@ function UserManager({
3327
3335
  setDeleting(false);
3328
3336
  }
3329
3337
  };
3338
+ const openResetPassword = (row) => {
3339
+ setResetRow(row);
3340
+ setResetPassword("");
3341
+ setResetError("");
3342
+ };
3343
+ const closeResetDialog = () => {
3344
+ if (!resetting) {
3345
+ setResetRow(null);
3346
+ setResetPassword("");
3347
+ setResetError("");
3348
+ }
3349
+ };
3350
+ const confirmResetPassword = async (event) => {
3351
+ event.preventDefault();
3352
+ if (!resetRow) return;
3353
+ if (!resetPassword.trim()) {
3354
+ setResetError("\u8BF7\u586B\u5199\u65B0\u5BC6\u7801");
3355
+ return;
3356
+ }
3357
+ setResetting(true);
3358
+ setResetError("");
3359
+ setError("");
3360
+ try {
3361
+ await api.resetPassword(resetRow.userId, resetPassword);
3362
+ setResetRow(null);
3363
+ setResetPassword("");
3364
+ } catch (err) {
3365
+ setResetError(err instanceof Error ? err.message : "\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25");
3366
+ } finally {
3367
+ setResetting(false);
3368
+ }
3369
+ };
3330
3370
  const groupLabel = (row) => {
3331
3371
  if (row.groupNames?.length) return row.groupNames.join("\u3001");
3332
3372
  if (!row.groupIds.length) return "\u2014";
@@ -3419,7 +3459,7 @@ function UserManager({
3419
3459
  /* @__PURE__ */ jsx5("th", { style: styles4.th, children: "\u5F52\u5C5E\u90E8\u95E8" }),
3420
3460
  /* @__PURE__ */ jsx5("th", { style: styles4.th, children: "\u7528\u6237\u89D2\u8272" }),
3421
3461
  /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 90 }, children: "\u72B6\u6001" }),
3422
- /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 140 }, children: "\u64CD\u4F5C" })
3462
+ /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 220 }, children: "\u64CD\u4F5C" })
3423
3463
  ] }) }),
3424
3464
  /* @__PURE__ */ jsx5("tbody", { children: loading ? /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5("td", { colSpan: 6, style: styles4.empty, children: "\u52A0\u8F7D\u4E2D\u2026" }) }) : records.length === 0 ? /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5("td", { colSpan: 6, style: styles4.empty, children: "\u6682\u65E0\u6570\u636E" }) }) : records.map((row) => /* @__PURE__ */ jsxs4("tr", { children: [
3425
3465
  /* @__PURE__ */ jsx5("td", { style: styles4.td, children: row.username }),
@@ -3438,6 +3478,15 @@ function UserManager({
3438
3478
  ) }),
3439
3479
  /* @__PURE__ */ jsxs4("td", { style: styles4.td, children: [
3440
3480
  /* @__PURE__ */ jsx5("button", { type: "button", style: styles4.linkBtn, onClick: () => openEdit(row), children: "\u7F16\u8F91" }),
3481
+ /* @__PURE__ */ jsx5(
3482
+ "button",
3483
+ {
3484
+ type: "button",
3485
+ style: styles4.linkBtn,
3486
+ onClick: () => openResetPassword(row),
3487
+ children: "\u91CD\u7F6E\u5BC6\u7801"
3488
+ }
3489
+ ),
3441
3490
  /* @__PURE__ */ jsx5(
3442
3491
  "button",
3443
3492
  {
@@ -3511,7 +3560,7 @@ function UserManager({
3511
3560
  style: styles4.input,
3512
3561
  value: form.username,
3513
3562
  onChange: (e) => setForm((prev) => ({ ...prev, username: e.target.value })),
3514
- placeholder: "\u81F3\u5C116\u4F4D\uFF0C\u9700\u542B\u5B57\u6BCD\u548C\u6570\u5B57",
3563
+ placeholder: "\u8D26\u53F7\u9700\u5305\u542B\u82F1\u6587\u5B57\u6BCD\uFF0C\u53EF\u642D\u914D\u6570\u5B57\uFF0C\u4E0D\u652F\u6301\u4E2D\u6587\u6216\u7279\u6B8A\u7B26\u53F7\u3002",
3515
3564
  required: true
3516
3565
  }
3517
3566
  )
@@ -3686,6 +3735,68 @@ function UserManager({
3686
3735
  ] })
3687
3736
  ]
3688
3737
  }
3738
+ ) }) : null,
3739
+ resetRow ? /* @__PURE__ */ jsx5("div", { style: styles4.mask, onClick: closeResetDialog, children: /* @__PURE__ */ jsxs4(
3740
+ "div",
3741
+ {
3742
+ style: { ...styles4.dialog, maxWidth: 420 },
3743
+ onClick: (e) => e.stopPropagation(),
3744
+ role: "dialog",
3745
+ "aria-modal": "true",
3746
+ children: [
3747
+ /* @__PURE__ */ jsxs4("div", { style: styles4.dialogHeader, children: [
3748
+ /* @__PURE__ */ jsx5("h3", { style: styles4.dialogTitle, children: "\u91CD\u7F6E\u5BC6\u7801" }),
3749
+ /* @__PURE__ */ jsx5(
3750
+ "button",
3751
+ {
3752
+ type: "button",
3753
+ style: styles4.iconBtn,
3754
+ onClick: closeResetDialog,
3755
+ "aria-label": "\u5173\u95ED",
3756
+ children: "\xD7"
3757
+ }
3758
+ )
3759
+ ] }),
3760
+ /* @__PURE__ */ jsxs4("form", { style: styles4.form, onSubmit: (e) => void confirmResetPassword(e), children: [
3761
+ resetError ? /* @__PURE__ */ jsx5("div", { style: styles4.error, children: resetError }) : null,
3762
+ /* @__PURE__ */ jsxs4("p", { style: styles4.confirmText, children: [
3763
+ "\u4E3A\u7528\u6237\u300C",
3764
+ /* @__PURE__ */ jsx5("strong", { children: resetRow.name }),
3765
+ "\u300D\uFF08",
3766
+ resetRow.username,
3767
+ "\uFF09\u8BBE\u7F6E\u65B0\u5BC6\u7801"
3768
+ ] }),
3769
+ /* @__PURE__ */ jsxs4("label", { style: styles4.field, children: [
3770
+ /* @__PURE__ */ jsx5("span", { style: styles4.label, children: "\u65B0\u5BC6\u7801" }),
3771
+ /* @__PURE__ */ jsx5(
3772
+ "input",
3773
+ {
3774
+ style: styles4.input,
3775
+ type: "password",
3776
+ value: resetPassword,
3777
+ onChange: (e) => setResetPassword(e.target.value),
3778
+ placeholder: "\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801",
3779
+ required: true,
3780
+ autoComplete: "new-password"
3781
+ }
3782
+ )
3783
+ ] }),
3784
+ /* @__PURE__ */ jsxs4("div", { style: styles4.dialogFooter, children: [
3785
+ /* @__PURE__ */ jsx5(
3786
+ "button",
3787
+ {
3788
+ type: "button",
3789
+ style: styles4.secondaryBtn,
3790
+ onClick: closeResetDialog,
3791
+ disabled: resetting,
3792
+ children: "\u53D6\u6D88"
3793
+ }
3794
+ ),
3795
+ /* @__PURE__ */ jsx5("button", { type: "submit", style: styles4.primaryBtn, disabled: resetting, children: resetting ? "\u63D0\u4EA4\u4E2D\u2026" : "\u786E\u8BA4\u91CD\u7F6E" })
3796
+ ] })
3797
+ ] })
3798
+ ]
3799
+ }
3689
3800
  ) }) : null
3690
3801
  ] });
3691
3802
  }