com-angel-authorization 1.0.30 → 1.0.32

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
  {
@@ -4389,11 +4442,14 @@ var UserManager = defineComponent5({
4389
4442
  [
4390
4443
  formError.value ? h4("div", { style: s4.error }, formError.value) : null,
4391
4444
  h4("label", { style: s4.field }, [
4392
- h4("span", { style: s4.label }, "\u8D26\u53F7"),
4445
+ h4("span", { style: s4.label }, [
4446
+ "\u8D26\u53F7 ",
4447
+ h4("span", { style: s4.required }, "*")
4448
+ ]),
4393
4449
  h4("input", {
4394
4450
  style: s4.input,
4395
4451
  value: form.username,
4396
- placeholder: "\u81F3\u5C116\u4F4D\uFF0C\u9700\u542B\u5B57\u6BCD\u548C\u6570\u5B57",
4452
+ 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
4453
  required: true,
4398
4454
  onInput: (e) => {
4399
4455
  form.username = e.target.value;
@@ -4401,7 +4457,10 @@ var UserManager = defineComponent5({
4401
4457
  })
4402
4458
  ]),
4403
4459
  h4("label", { style: s4.field }, [
4404
- h4("span", { style: s4.label }, "\u7528\u6237\u540D"),
4460
+ h4("span", { style: s4.label }, [
4461
+ "\u7528\u6237\u540D ",
4462
+ h4("span", { style: s4.required }, "*")
4463
+ ]),
4405
4464
  h4("input", {
4406
4465
  style: s4.input,
4407
4466
  value: form.name,
@@ -4412,24 +4471,23 @@ var UserManager = defineComponent5({
4412
4471
  }
4413
4472
  })
4414
4473
  ]),
4415
- h4("label", { style: s4.field }, [
4416
- h4(
4417
- "span",
4418
- { style: s4.label },
4419
- editing.value ? "\u5BC6\u7801\uFF08\u7559\u7A7A\u5219\u4E0D\u4FEE\u6539\uFF09" : "\u521D\u59CB\u5BC6\u7801"
4420
- ),
4474
+ !editing.value ? h4("label", { style: s4.field }, [
4475
+ h4("span", { style: s4.label }, [
4476
+ "\u521D\u59CB\u5BC6\u7801 ",
4477
+ h4("span", { style: s4.required }, "*")
4478
+ ]),
4421
4479
  h4("input", {
4422
4480
  style: s4.input,
4423
4481
  type: "password",
4424
4482
  value: form.password,
4425
- placeholder: editing.value ? "\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539\u5BC6\u7801" : "\u8BF7\u8F93\u5165\u521D\u59CB\u5BC6\u7801",
4426
- required: !editing.value,
4483
+ placeholder: "\u8BF7\u8F93\u5165\u521D\u59CB\u5BC6\u7801",
4484
+ required: true,
4427
4485
  autocomplete: "new-password",
4428
4486
  onInput: (e) => {
4429
4487
  form.password = e.target.value;
4430
4488
  }
4431
4489
  })
4432
- ]),
4490
+ ]) : null,
4433
4491
  h4("fieldset", { style: s4.fieldset }, [
4434
4492
  h4("legend", { style: s4.label }, [
4435
4493
  "\u5F52\u5C5E\u90E8\u95E8 ",
@@ -4612,6 +4670,84 @@ var UserManager = defineComponent5({
4612
4670
  ])
4613
4671
  ]
4614
4672
  )
4673
+ ]) : null,
4674
+ resetRow.value ? h4("div", { style: s4.mask, onClick: closeResetDialog }, [
4675
+ h4(
4676
+ "div",
4677
+ {
4678
+ style: { ...s4.dialog, maxWidth: "420px" },
4679
+ role: "dialog",
4680
+ "aria-modal": "true",
4681
+ onClick: (e) => e.stopPropagation()
4682
+ },
4683
+ [
4684
+ h4("div", { style: s4.dialogHeader }, [
4685
+ h4("h3", { style: s4.dialogTitle }, "\u91CD\u7F6E\u5BC6\u7801"),
4686
+ h4(
4687
+ "button",
4688
+ {
4689
+ type: "button",
4690
+ style: s4.iconBtn,
4691
+ "aria-label": "\u5173\u95ED",
4692
+ onClick: closeResetDialog
4693
+ },
4694
+ "\xD7"
4695
+ )
4696
+ ]),
4697
+ h4(
4698
+ "form",
4699
+ {
4700
+ style: s4.form,
4701
+ onSubmit: (e) => void confirmResetPassword(e)
4702
+ },
4703
+ [
4704
+ resetError.value ? h4("div", { style: s4.error }, resetError.value) : null,
4705
+ h4("p", { style: s4.confirmText }, [
4706
+ "\u4E3A\u7528\u6237\u300C",
4707
+ h4("strong", resetRow.value.name),
4708
+ "\u300D\uFF08",
4709
+ resetRow.value.username,
4710
+ "\uFF09\u8BBE\u7F6E\u65B0\u5BC6\u7801"
4711
+ ]),
4712
+ h4("label", { style: s4.field }, [
4713
+ h4("span", { style: s4.label }, "\u65B0\u5BC6\u7801"),
4714
+ h4("input", {
4715
+ style: s4.input,
4716
+ type: "password",
4717
+ value: resetPassword.value,
4718
+ placeholder: "\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801",
4719
+ required: true,
4720
+ autocomplete: "new-password",
4721
+ onInput: (e) => {
4722
+ resetPassword.value = e.target.value;
4723
+ }
4724
+ })
4725
+ ]),
4726
+ h4("div", { style: s4.dialogFooter }, [
4727
+ h4(
4728
+ "button",
4729
+ {
4730
+ type: "button",
4731
+ style: s4.secondaryBtn,
4732
+ disabled: resetting.value,
4733
+ onClick: closeResetDialog
4734
+ },
4735
+ "\u53D6\u6D88"
4736
+ ),
4737
+ h4(
4738
+ "button",
4739
+ {
4740
+ type: "submit",
4741
+ style: s4.primaryBtn,
4742
+ disabled: resetting.value
4743
+ },
4744
+ resetting.value ? "\u63D0\u4EA4\u4E2D\u2026" : "\u786E\u8BA4\u91CD\u7F6E"
4745
+ )
4746
+ ])
4747
+ ]
4748
+ )
4749
+ ]
4750
+ )
4615
4751
  ]) : null
4616
4752
  ]);
4617
4753
  }