com-angel-authorization 1.0.30 → 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;
@@ -3025,9 +3025,9 @@ function mapSystemRoleOption(item) {
3025
3025
  }
3026
3026
  function validateUsername(username) {
3027
3027
  const value = username.trim();
3028
- if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
3029
- if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
3030
- 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";
3031
3031
  }
3032
3032
  return null;
3033
3033
  }
@@ -3107,6 +3107,14 @@ function createSystemUserApi(request) {
3107
3107
  signal
3108
3108
  });
3109
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
+ },
3110
3118
  async listGroups(params, signal) {
3111
3119
  const json = await request({
3112
3120
  method: "GET",
@@ -3160,6 +3168,10 @@ function UserManager({
3160
3168
  const [saving, setSaving] = useState5(false);
3161
3169
  const [deletingRow, setDeletingRow] = useState5(null);
3162
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);
3163
3175
  const [groups, setGroups] = useState5([]);
3164
3176
  const [roles, setRoles] = useState5([]);
3165
3177
  const [rolesLoading, setRolesLoading] = useState5(false);
@@ -3323,6 +3335,38 @@ function UserManager({
3323
3335
  setDeleting(false);
3324
3336
  }
3325
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
+ };
3326
3370
  const groupLabel = (row) => {
3327
3371
  if (row.groupNames?.length) return row.groupNames.join("\u3001");
3328
3372
  if (!row.groupIds.length) return "\u2014";
@@ -3415,7 +3459,7 @@ function UserManager({
3415
3459
  /* @__PURE__ */ jsx5("th", { style: styles4.th, children: "\u5F52\u5C5E\u90E8\u95E8" }),
3416
3460
  /* @__PURE__ */ jsx5("th", { style: styles4.th, children: "\u7528\u6237\u89D2\u8272" }),
3417
3461
  /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 90 }, children: "\u72B6\u6001" }),
3418
- /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 140 }, children: "\u64CD\u4F5C" })
3462
+ /* @__PURE__ */ jsx5("th", { style: { ...styles4.th, width: 220 }, children: "\u64CD\u4F5C" })
3419
3463
  ] }) }),
3420
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: [
3421
3465
  /* @__PURE__ */ jsx5("td", { style: styles4.td, children: row.username }),
@@ -3434,6 +3478,15 @@ function UserManager({
3434
3478
  ) }),
3435
3479
  /* @__PURE__ */ jsxs4("td", { style: styles4.td, children: [
3436
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
+ ),
3437
3490
  /* @__PURE__ */ jsx5(
3438
3491
  "button",
3439
3492
  {
@@ -3507,7 +3560,7 @@ function UserManager({
3507
3560
  style: styles4.input,
3508
3561
  value: form.username,
3509
3562
  onChange: (e) => setForm((prev) => ({ ...prev, username: e.target.value })),
3510
- 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",
3511
3564
  required: true
3512
3565
  }
3513
3566
  )
@@ -3682,6 +3735,68 @@ function UserManager({
3682
3735
  ] })
3683
3736
  ]
3684
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
+ }
3685
3800
  ) }) : null
3686
3801
  ] });
3687
3802
  }