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.
@@ -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
@@ -2169,15 +2169,14 @@ var MenuManager = defineComponent3({
2169
2169
  ]),
2170
2170
  dialogOpen.value ? h2(
2171
2171
  "div",
2172
- { style: s2.mask, onClick: closeDialog },
2172
+ { style: s2.mask },
2173
2173
  [
2174
2174
  h2(
2175
2175
  "div",
2176
2176
  {
2177
2177
  style: { ...s2.dialog, maxWidth: "520px" },
2178
2178
  role: "dialog",
2179
- "aria-modal": "true",
2180
- onClick: (e) => e.stopPropagation()
2179
+ "aria-modal": "true"
2181
2180
  },
2182
2181
  [
2183
2182
  h2("div", { style: s2.dialogHeader }, [
@@ -2364,15 +2363,6 @@ var MenuManager = defineComponent3({
2364
2363
  )
2365
2364
  ]),
2366
2365
  h2("div", { style: s2.dialogFooter }, [
2367
- h2(
2368
- "button",
2369
- {
2370
- type: "button",
2371
- style: s2.secondaryBtn,
2372
- onClick: closeDialog
2373
- },
2374
- "\u53D6\u6D88"
2375
- ),
2376
2366
  h2(
2377
2367
  "button",
2378
2368
  {
@@ -3564,9 +3554,9 @@ function mapSystemRoleOption(item) {
3564
3554
  }
3565
3555
  function validateUsername(username) {
3566
3556
  const value = username.trim();
3567
- if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
3568
- if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
3569
- 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";
3570
3560
  }
3571
3561
  return null;
3572
3562
  }
@@ -3646,6 +3636,14 @@ function createSystemUserApi(request) {
3646
3636
  signal
3647
3637
  });
3648
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
+ },
3649
3647
  async listGroups(params, signal) {
3650
3648
  const json = await request({
3651
3649
  method: "GET",
@@ -3997,6 +3995,10 @@ var UserManager = defineComponent5({
3997
3995
  const saving = ref4(false);
3998
3996
  const deletingRow = ref4(null);
3999
3997
  const deleting = ref4(false);
3998
+ const resetRow = ref4(null);
3999
+ const resetPassword = ref4("");
4000
+ const resetError = ref4("");
4001
+ const resetting = ref4(false);
4000
4002
  const groups = ref4([]);
4001
4003
  const roles = ref4([]);
4002
4004
  const rolesLoading = ref4(false);
@@ -4157,6 +4159,38 @@ var UserManager = defineComponent5({
4157
4159
  deleting.value = false;
4158
4160
  }
4159
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
+ }
4160
4194
  function groupLabel(row) {
4161
4195
  if (row.groupNames?.length) return row.groupNames.join("\u3001");
4162
4196
  if (!row.groupIds.length) return "\u2014";
@@ -4267,7 +4301,7 @@ var UserManager = defineComponent5({
4267
4301
  h4("th", { style: s4.th }, "\u5F52\u5C5E\u90E8\u95E8"),
4268
4302
  h4("th", { style: s4.th }, "\u7528\u6237\u89D2\u8272"),
4269
4303
  h4("th", { style: { ...s4.th, width: "90px" } }, "\u72B6\u6001"),
4270
- h4("th", { style: { ...s4.th, width: "140px" } }, "\u64CD\u4F5C")
4304
+ h4("th", { style: { ...s4.th, width: "220px" } }, "\u64CD\u4F5C")
4271
4305
  ])
4272
4306
  ]),
4273
4307
  h4(
@@ -4308,6 +4342,15 @@ var UserManager = defineComponent5({
4308
4342
  },
4309
4343
  "\u7F16\u8F91"
4310
4344
  ),
4345
+ h4(
4346
+ "button",
4347
+ {
4348
+ type: "button",
4349
+ style: s4.linkBtn,
4350
+ onClick: () => openResetPassword(row)
4351
+ },
4352
+ "\u91CD\u7F6E\u5BC6\u7801"
4353
+ ),
4311
4354
  h4(
4312
4355
  "button",
4313
4356
  {
@@ -4403,7 +4446,7 @@ var UserManager = defineComponent5({
4403
4446
  h4("input", {
4404
4447
  style: s4.input,
4405
4448
  value: form.username,
4406
- 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",
4407
4450
  required: true,
4408
4451
  onInput: (e) => {
4409
4452
  form.username = e.target.value;
@@ -4622,6 +4665,84 @@ var UserManager = defineComponent5({
4622
4665
  ])
4623
4666
  ]
4624
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
+ )
4625
4746
  ]) : null
4626
4747
  ]);
4627
4748
  }