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.
@@ -640,6 +640,7 @@ type SystemUserApi = {
640
640
  create: (values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
641
641
  update: (userId: string, values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
642
642
  remove: (userId: string, signal?: AbortSignal) => Promise<unknown>;
643
+ resetPassword: (userId: string, password: string, signal?: AbortSignal) => Promise<unknown>;
643
644
  listGroups: (params?: FetchSystemGroupsParams, signal?: AbortSignal) => Promise<SystemGroupOption[]>;
644
645
  listRoleOptions: (params?: FetchSystemRoleOptionsParams, signal?: AbortSignal) => Promise<SystemRoleOption[]>;
645
646
  };
@@ -647,7 +648,7 @@ declare function mapSystemUser(item: unknown): SystemUser | null;
647
648
  declare function mapSystemGroupOption(item: unknown): SystemGroupOption | null;
648
649
  declare function mapSystemRoleOption(item: unknown): SystemRoleOption | null;
649
650
  /**
650
- * 账号校验:不少于 6 位,且同时包含字母与数字。
651
+ * 账号校验:长度大于 1;须含英文字母,可搭配数字;不支持中文或特殊符号。
651
652
  * 通过返回 null,失败返回错误文案。
652
653
  */
653
654
  declare function validateUsername(username: string): string | null;
@@ -640,6 +640,7 @@ type SystemUserApi = {
640
640
  create: (values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
641
641
  update: (userId: string, values: SystemUserFormValues, signal?: AbortSignal) => Promise<unknown>;
642
642
  remove: (userId: string, signal?: AbortSignal) => Promise<unknown>;
643
+ resetPassword: (userId: string, password: string, signal?: AbortSignal) => Promise<unknown>;
643
644
  listGroups: (params?: FetchSystemGroupsParams, signal?: AbortSignal) => Promise<SystemGroupOption[]>;
644
645
  listRoleOptions: (params?: FetchSystemRoleOptionsParams, signal?: AbortSignal) => Promise<SystemRoleOption[]>;
645
646
  };
@@ -647,7 +648,7 @@ declare function mapSystemUser(item: unknown): SystemUser | null;
647
648
  declare function mapSystemGroupOption(item: unknown): SystemGroupOption | null;
648
649
  declare function mapSystemRoleOption(item: unknown): SystemRoleOption | null;
649
650
  /**
650
- * 账号校验:不少于 6 位,且同时包含字母与数字。
651
+ * 账号校验:长度大于 1;须含英文字母,可搭配数字;不支持中文或特殊符号。
651
652
  * 通过返回 null,失败返回错误文案。
652
653
  */
653
654
  declare function validateUsername(username: string): string | null;
package/dist/vue/index.js CHANGED
@@ -3554,9 +3554,9 @@ function mapSystemRoleOption(item) {
3554
3554
  }
3555
3555
  function validateUsername(username) {
3556
3556
  const value = username.trim();
3557
- if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
3558
- if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
3559
- return "\u8D26\u53F7\u9700\u540C\u65F6\u5305\u542B\u5B57\u6BCD\u548C\u6570\u5B57";
3557
+ if (value.length <= 1) return "\u8D26\u53F7\u957F\u5EA6\u9700\u5927\u4E8E 1";
3558
+ if (!/^(?=.*[A-Za-z])[A-Za-z0-9]+$/.test(value)) {
3559
+ 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";
3560
3560
  }
3561
3561
  return null;
3562
3562
  }
@@ -3636,6 +3636,14 @@ function createSystemUserApi(request) {
3636
3636
  signal
3637
3637
  });
3638
3638
  },
3639
+ async resetPassword(userId, password, signal) {
3640
+ return request({
3641
+ method: "POST",
3642
+ url: `/system/users/${encodeURIComponent(userId)}/reset-password`,
3643
+ body: { password },
3644
+ signal
3645
+ });
3646
+ },
3639
3647
  async listGroups(params, signal) {
3640
3648
  const json = await request({
3641
3649
  method: "GET",
@@ -3987,6 +3995,10 @@ var UserManager = defineComponent5({
3987
3995
  const saving = ref4(false);
3988
3996
  const deletingRow = ref4(null);
3989
3997
  const deleting = ref4(false);
3998
+ const resetRow = ref4(null);
3999
+ const resetPassword = ref4("");
4000
+ const resetError = ref4("");
4001
+ const resetting = ref4(false);
3990
4002
  const groups = ref4([]);
3991
4003
  const roles = ref4([]);
3992
4004
  const rolesLoading = ref4(false);
@@ -4147,6 +4159,38 @@ var UserManager = defineComponent5({
4147
4159
  deleting.value = false;
4148
4160
  }
4149
4161
  }
4162
+ function openResetPassword(row) {
4163
+ resetRow.value = row;
4164
+ resetPassword.value = "";
4165
+ resetError.value = "";
4166
+ }
4167
+ function closeResetDialog() {
4168
+ if (!resetting.value) {
4169
+ resetRow.value = null;
4170
+ resetPassword.value = "";
4171
+ resetError.value = "";
4172
+ }
4173
+ }
4174
+ async function confirmResetPassword(event) {
4175
+ event.preventDefault();
4176
+ if (!resetRow.value) return;
4177
+ if (!resetPassword.value.trim()) {
4178
+ resetError.value = "\u8BF7\u586B\u5199\u65B0\u5BC6\u7801";
4179
+ return;
4180
+ }
4181
+ resetting.value = true;
4182
+ resetError.value = "";
4183
+ error.value = "";
4184
+ try {
4185
+ await props.api.resetPassword(resetRow.value.userId, resetPassword.value);
4186
+ resetRow.value = null;
4187
+ resetPassword.value = "";
4188
+ } catch (err) {
4189
+ resetError.value = err instanceof Error ? err.message : "\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25";
4190
+ } finally {
4191
+ resetting.value = false;
4192
+ }
4193
+ }
4150
4194
  function groupLabel(row) {
4151
4195
  if (row.groupNames?.length) return row.groupNames.join("\u3001");
4152
4196
  if (!row.groupIds.length) return "\u2014";
@@ -4257,7 +4301,7 @@ var UserManager = defineComponent5({
4257
4301
  h4("th", { style: s4.th }, "\u5F52\u5C5E\u90E8\u95E8"),
4258
4302
  h4("th", { style: s4.th }, "\u7528\u6237\u89D2\u8272"),
4259
4303
  h4("th", { style: { ...s4.th, width: "90px" } }, "\u72B6\u6001"),
4260
- h4("th", { style: { ...s4.th, width: "140px" } }, "\u64CD\u4F5C")
4304
+ h4("th", { style: { ...s4.th, width: "220px" } }, "\u64CD\u4F5C")
4261
4305
  ])
4262
4306
  ]),
4263
4307
  h4(
@@ -4298,6 +4342,15 @@ var UserManager = defineComponent5({
4298
4342
  },
4299
4343
  "\u7F16\u8F91"
4300
4344
  ),
4345
+ h4(
4346
+ "button",
4347
+ {
4348
+ type: "button",
4349
+ style: s4.linkBtn,
4350
+ onClick: () => openResetPassword(row)
4351
+ },
4352
+ "\u91CD\u7F6E\u5BC6\u7801"
4353
+ ),
4301
4354
  h4(
4302
4355
  "button",
4303
4356
  {
@@ -4393,7 +4446,7 @@ var UserManager = defineComponent5({
4393
4446
  h4("input", {
4394
4447
  style: s4.input,
4395
4448
  value: form.username,
4396
- placeholder: "\u81F3\u5C116\u4F4D\uFF0C\u9700\u542B\u5B57\u6BCD\u548C\u6570\u5B57",
4449
+ 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",
4397
4450
  required: true,
4398
4451
  onInput: (e) => {
4399
4452
  form.username = e.target.value;
@@ -4612,6 +4665,84 @@ var UserManager = defineComponent5({
4612
4665
  ])
4613
4666
  ]
4614
4667
  )
4668
+ ]) : null,
4669
+ resetRow.value ? h4("div", { style: s4.mask, onClick: closeResetDialog }, [
4670
+ h4(
4671
+ "div",
4672
+ {
4673
+ style: { ...s4.dialog, maxWidth: "420px" },
4674
+ role: "dialog",
4675
+ "aria-modal": "true",
4676
+ onClick: (e) => e.stopPropagation()
4677
+ },
4678
+ [
4679
+ h4("div", { style: s4.dialogHeader }, [
4680
+ h4("h3", { style: s4.dialogTitle }, "\u91CD\u7F6E\u5BC6\u7801"),
4681
+ h4(
4682
+ "button",
4683
+ {
4684
+ type: "button",
4685
+ style: s4.iconBtn,
4686
+ "aria-label": "\u5173\u95ED",
4687
+ onClick: closeResetDialog
4688
+ },
4689
+ "\xD7"
4690
+ )
4691
+ ]),
4692
+ h4(
4693
+ "form",
4694
+ {
4695
+ style: s4.form,
4696
+ onSubmit: (e) => void confirmResetPassword(e)
4697
+ },
4698
+ [
4699
+ resetError.value ? h4("div", { style: s4.error }, resetError.value) : null,
4700
+ h4("p", { style: s4.confirmText }, [
4701
+ "\u4E3A\u7528\u6237\u300C",
4702
+ h4("strong", resetRow.value.name),
4703
+ "\u300D\uFF08",
4704
+ resetRow.value.username,
4705
+ "\uFF09\u8BBE\u7F6E\u65B0\u5BC6\u7801"
4706
+ ]),
4707
+ h4("label", { style: s4.field }, [
4708
+ h4("span", { style: s4.label }, "\u65B0\u5BC6\u7801"),
4709
+ h4("input", {
4710
+ style: s4.input,
4711
+ type: "password",
4712
+ value: resetPassword.value,
4713
+ placeholder: "\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801",
4714
+ required: true,
4715
+ autocomplete: "new-password",
4716
+ onInput: (e) => {
4717
+ resetPassword.value = e.target.value;
4718
+ }
4719
+ })
4720
+ ]),
4721
+ h4("div", { style: s4.dialogFooter }, [
4722
+ h4(
4723
+ "button",
4724
+ {
4725
+ type: "button",
4726
+ style: s4.secondaryBtn,
4727
+ disabled: resetting.value,
4728
+ onClick: closeResetDialog
4729
+ },
4730
+ "\u53D6\u6D88"
4731
+ ),
4732
+ h4(
4733
+ "button",
4734
+ {
4735
+ type: "submit",
4736
+ style: s4.primaryBtn,
4737
+ disabled: resetting.value
4738
+ },
4739
+ resetting.value ? "\u63D0\u4EA4\u4E2D\u2026" : "\u786E\u8BA4\u91CD\u7F6E"
4740
+ )
4741
+ ])
4742
+ ]
4743
+ )
4744
+ ]
4745
+ )
4615
4746
  ]) : null
4616
4747
  ]);
4617
4748
  }