修复密码输入可访问性并统一新手机号为中国大陆区号
This commit is contained in:
1 parent
990b802553
commit
f6ab3c9087
15 files changed
+592
-362
No files matched your search
@@ -49,7 +49,8 @@ import CaptchaField from "~/components/CaptchaField.vue";
|
||||
import select from "primevue/select";
|
||||
import ClientLevelDialog from "~/components/ClientLevelDialog.vue";
|
||||
import { t as interval_t } from "~/lib/interval.js";
|
||||
import password from "primevue/password";
|
||||
import password from "~/components/PasswordField.vue";
|
||||
import PhoneCodeField from "~/components/PhoneCodeField.vue";
|
||||
import skeleton from "primevue/skeleton";
|
||||
import toggleswitch from "primevue/toggleswitch";
|
||||
import { t as useCaptcha_t } from "~/lib/useCaptcha.js";
|
||||
@@ -204,8 +205,7 @@ var Ce = {
|
||||
_t = {
|
||||
class: `field`,
|
||||
},
|
||||
vt = [`id`, `for`],
|
||||
yt = [`id`],
|
||||
vt = [`for`],
|
||||
bt = {
|
||||
class: `inline`,
|
||||
},
|
||||
@@ -729,7 +729,6 @@ var Ce = {
|
||||
}
|
||||
}
|
||||
let q = reactive({
|
||||
phone_code: 86,
|
||||
newPhone: ``,
|
||||
code: ``,
|
||||
}),
|
||||
@@ -799,7 +798,7 @@ var Ce = {
|
||||
try {
|
||||
if (!q.newPhone.trim()) throw Error(`请输入新手机号`);
|
||||
(await jn(`phone`, `update`, {
|
||||
phone_code: q.phone_code,
|
||||
phone_code: 86,
|
||||
phone: q.newPhone.trim(),
|
||||
}),
|
||||
(O.value = `验证码已发送`));
|
||||
@@ -815,7 +814,7 @@ var Ce = {
|
||||
(M(), (Y.value = !0));
|
||||
try {
|
||||
(await b.put(`/account/phone`, {
|
||||
phone_code: q.phone_code,
|
||||
phone_code: 86,
|
||||
phone: q.newPhone,
|
||||
code: q.code,
|
||||
}),
|
||||
@@ -1406,6 +1405,7 @@ var Ce = {
|
||||
toggleMask: ``,
|
||||
fluid: ``,
|
||||
placeholder: `输入当前密码`,
|
||||
autocomplete: `current-password`,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
@@ -1617,6 +1617,7 @@ var Ce = {
|
||||
toggleMask: ``,
|
||||
fluid: ``,
|
||||
placeholder: `输入新密码`,
|
||||
autocomplete: `new-password`,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
@@ -1647,6 +1648,7 @@ var Ce = {
|
||||
toggleMask: ``,
|
||||
fluid: ``,
|
||||
placeholder: `再次输入新密码`,
|
||||
autocomplete: `new-password`,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
@@ -2068,88 +2070,18 @@ var Ce = {
|
||||
createElementVNode(
|
||||
`label`,
|
||||
{
|
||||
id: `${unref(x)}-phone-label`,
|
||||
for: `${unref(x)}-new-phone`,
|
||||
},
|
||||
`新手机号`,
|
||||
8,
|
||||
vt,
|
||||
),
|
||||
createElementVNode(
|
||||
`span`,
|
||||
{
|
||||
id: `${unref(x)}-phone-code-label`,
|
||||
class: `sr-only`,
|
||||
},
|
||||
`国际区号`,
|
||||
8,
|
||||
yt,
|
||||
),
|
||||
createElementVNode(
|
||||
`div`,
|
||||
bt,
|
||||
[
|
||||
createVNode(
|
||||
g,
|
||||
{
|
||||
modelValue:
|
||||
unref(q)
|
||||
.phone_code,
|
||||
"onUpdate:modelValue":
|
||||
(r[19] ||= (
|
||||
e,
|
||||
) =>
|
||||
(unref(
|
||||
q,
|
||||
).phone_code =
|
||||
e)),
|
||||
"aria-labelledby": `${unref(x)}-phone-label ${unref(x)}-phone-code-label`,
|
||||
options:
|
||||
unref(Zt),
|
||||
optionLabel: `phone_code`,
|
||||
optionValue: `phone_code`,
|
||||
filter: ``,
|
||||
class: `code-select`,
|
||||
},
|
||||
{
|
||||
option: withCtx(
|
||||
({
|
||||
option: t,
|
||||
}) => [
|
||||
createTextVNode(
|
||||
`+` +
|
||||
toDisplayString(
|
||||
t.phone_code,
|
||||
) +
|
||||
` ` +
|
||||
toDisplayString(
|
||||
t.name,
|
||||
),
|
||||
1,
|
||||
),
|
||||
],
|
||||
),
|
||||
value: withCtx(
|
||||
({
|
||||
value: t,
|
||||
}) => [
|
||||
createTextVNode(
|
||||
`+` +
|
||||
toDisplayString(
|
||||
t,
|
||||
),
|
||||
1,
|
||||
),
|
||||
],
|
||||
),
|
||||
_: 1,
|
||||
},
|
||||
8,
|
||||
[
|
||||
`modelValue`,
|
||||
`aria-labelledby`,
|
||||
`options`,
|
||||
],
|
||||
PhoneCodeField,
|
||||
),
|
||||
createVNode(
|
||||
l,
|
||||
|
||||
@@ -36,7 +36,7 @@ import { n as auth_redirect_n } from "~/lib/auth-redirect.js";
|
||||
import { t as auth_redirect_t } from "~/lib/auth-redirect.js";
|
||||
import inputtext from "primevue/inputtext";
|
||||
import CaptchaField from "~/components/CaptchaField.vue";
|
||||
import password from "primevue/password";
|
||||
import password from "~/components/PasswordField.vue";
|
||||
import PhoneCodeField from "~/components/PhoneCodeField.vue";
|
||||
import { t as useCaptcha_t } from "~/lib/useCaptcha.js";
|
||||
import { t as composables_t } from "~/lib/composables-2.js";
|
||||
@@ -94,7 +94,6 @@ var D = {
|
||||
code: ``,
|
||||
password: ``,
|
||||
re_password: ``,
|
||||
phone_code: `86`,
|
||||
}),
|
||||
W = ref(``),
|
||||
G = ref(!1),
|
||||
@@ -120,7 +119,6 @@ var D = {
|
||||
action: `password_reset`,
|
||||
captcha: K,
|
||||
error: W,
|
||||
phoneCode: () => U.phone_code,
|
||||
});
|
||||
// 复用 password_reset 场景的验证码发送与倒计时,不在页面另写一套短信请求。
|
||||
function fe() {
|
||||
@@ -140,8 +138,6 @@ var D = {
|
||||
if (!e)
|
||||
return (W.value =
|
||||
H.value === `email` ? `请输入邮箱` : `请输入手机号`);
|
||||
if (H.value === `phone` && !/^[1-9]\d{0,3}$/.test(U.phone_code))
|
||||
return (W.value = `请输入有效的国际电话区号`);
|
||||
if (!U.code.trim()) return (W.value = `请输入验证码`);
|
||||
if (!U.password) return (W.value = `请输入新密码`);
|
||||
if (U.password !== U.re_password)
|
||||
@@ -151,7 +147,7 @@ var D = {
|
||||
(await z.post(`/account/password_reset`, {
|
||||
type: H.value,
|
||||
account: e,
|
||||
phone_code: U.phone_code,
|
||||
phone_code: `86`,
|
||||
code: U.code.trim(),
|
||||
password: U.password,
|
||||
re_password: U.re_password,
|
||||
@@ -205,20 +201,7 @@ var D = {
|
||||
},
|
||||
[
|
||||
unref(H) === `phone`
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
f,
|
||||
{
|
||||
key: 0,
|
||||
modelValue: unref(U).phone_code,
|
||||
"onUpdate:modelValue": (o[0] ||= (e) =>
|
||||
(unref(U).phone_code = e)),
|
||||
disabled: unref(G) || unref(Q),
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`modelValue`, `disabled`],
|
||||
))
|
||||
? (openBlock(), createBlock(f, { key: 0 }))
|
||||
: createCommentVNode(``, !0),
|
||||
createElementVNode(`div`, O, [
|
||||
(o[8] ||= createElementVNode(
|
||||
|
||||
+4
-8
@@ -15,7 +15,7 @@ import { NuxtLink } from "#components";
|
||||
import Button from "primevue/button";
|
||||
import InputText from "primevue/inputtext";
|
||||
import Message from "primevue/message";
|
||||
import Password from "primevue/password";
|
||||
import Password from "~/components/PasswordField.vue";
|
||||
import AuthProviders from "~/components/AuthProviders.vue";
|
||||
import CaptchaField from "~/components/CaptchaField.vue";
|
||||
import GenericOAuthProviders from "~/components/GenericOAuthProviders.vue";
|
||||
@@ -42,7 +42,8 @@ const site = useSiteConfig();
|
||||
const { config, error: configError } = site;
|
||||
const form = reactive({ account: "", password: "", code: "" });
|
||||
const loginMode = ref("password");
|
||||
const phoneCode = ref("86");
|
||||
// 新输入的手机号统一为中国大陆,不从用户输入或地区选择器派生区号。
|
||||
const phoneCode = "86";
|
||||
const errorMessage = ref("");
|
||||
const submitting = ref(false);
|
||||
const authProviders = ref(null);
|
||||
@@ -115,7 +116,6 @@ const {
|
||||
action: "login",
|
||||
captcha,
|
||||
error: errorMessage,
|
||||
phoneCode: () => phoneCode.value,
|
||||
});
|
||||
const fieldsDisabled = computed(() => formLocked.value || sendingCode.value);
|
||||
const captchaBusy = computed(
|
||||
@@ -304,10 +304,6 @@ async function submitLogin() {
|
||||
errorMessage.value = "当前登录方式未开放,请选择其他方式";
|
||||
return;
|
||||
}
|
||||
if (isPhoneAccount.value && !/^[1-9]\d{0,3}$/.test(phoneCode.value)) {
|
||||
errorMessage.value = "请输入有效的国际电话区号";
|
||||
return;
|
||||
}
|
||||
if (loginMode.value === "code" && form.account.includes("@")) {
|
||||
errorMessage.value = "请输入手机号";
|
||||
return;
|
||||
@@ -334,7 +330,7 @@ async function submitLogin() {
|
||||
token: captchaToken.value,
|
||||
type: loginMode.value,
|
||||
code: form.code.trim(),
|
||||
phoneCode: isPhoneAccount.value ? phoneCode.value : "",
|
||||
phoneCode: isPhoneAccount.value ? phoneCode : "",
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -112,7 +112,6 @@ var ve = {
|
||||
F = auth_redirect_r(M.query.redirect),
|
||||
I = ref(`phone`),
|
||||
L = ref(``),
|
||||
R = ref(`86`),
|
||||
z = ref(``),
|
||||
B = ref(!1),
|
||||
V = ref(!1),
|
||||
@@ -182,7 +181,6 @@ var ve = {
|
||||
action: `oauth`,
|
||||
captcha: q,
|
||||
error: H,
|
||||
phoneCode: () => R.value,
|
||||
}),
|
||||
{
|
||||
needed: Ae,
|
||||
@@ -223,10 +221,6 @@ var ve = {
|
||||
H.value = `请先阅读并同意服务协议和隐私协议`;
|
||||
return;
|
||||
}
|
||||
if (I.value === `phone` && !/^[1-9]\d{0,3}$/.test(R.value)) {
|
||||
H.value = `请输入有效的国际电话区号`;
|
||||
return;
|
||||
}
|
||||
V.value = !0;
|
||||
try {
|
||||
let e = q.validationError?.();
|
||||
@@ -238,7 +232,7 @@ var ve = {
|
||||
{
|
||||
type: I.value,
|
||||
account: L.value.trim(),
|
||||
phone_code: R.value,
|
||||
phone_code: `86`,
|
||||
code: z.value.trim(),
|
||||
...(N && P
|
||||
? {
|
||||
@@ -404,20 +398,7 @@ var ve = {
|
||||
),
|
||||
createElementVNode(`div`, T, [
|
||||
unref(I) === `phone`
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
u,
|
||||
{
|
||||
key: 0,
|
||||
modelValue: unref(R),
|
||||
"onUpdate:modelValue": (n[2] ||= (e) =>
|
||||
isRef(R) ? (R.value = e) : null),
|
||||
disabled: unref(V) || unref(J),
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`modelValue`, `disabled`],
|
||||
))
|
||||
? (openBlock(), createBlock(u, { key: 0 }))
|
||||
: createCommentVNode(``, !0),
|
||||
createVNode(
|
||||
g,
|
||||
|
||||
+3
-20
@@ -43,7 +43,7 @@ import inputtext from "primevue/inputtext";
|
||||
import CaptchaField from "~/components/CaptchaField.vue";
|
||||
import select from "primevue/select";
|
||||
import checkbox from "primevue/checkbox";
|
||||
import password from "primevue/password";
|
||||
import password from "~/components/PasswordField.vue";
|
||||
import textarea from "primevue/textarea";
|
||||
import PhoneCodeField from "~/components/PhoneCodeField.vue";
|
||||
import { i as product_fields_i } from "~/lib/product-fields.js";
|
||||
@@ -209,7 +209,6 @@ var ve = {
|
||||
username: ``,
|
||||
password: ``,
|
||||
re_password: ``,
|
||||
phone_code: `86`,
|
||||
customfield: {},
|
||||
}),
|
||||
I = ref(``),
|
||||
@@ -264,7 +263,6 @@ var ve = {
|
||||
action: `register`,
|
||||
captcha: R,
|
||||
error: I,
|
||||
phoneCode: () => F.phone_code,
|
||||
});
|
||||
// 仅对已开放且需要验证码的注册方式发送验证码,倒计时与验证码挑战由公共发送器管理。
|
||||
function ze() {
|
||||
@@ -291,8 +289,6 @@ var ve = {
|
||||
if (!e)
|
||||
return (I.value =
|
||||
P.value === `email` ? `请输入邮箱` : `请输入手机号`);
|
||||
if (P.value === `phone` && !/^[1-9]\d{0,3}$/.test(F.phone_code))
|
||||
return (I.value = `请输入有效的国际电话区号`);
|
||||
if (K.value && !F.code.trim()) return (I.value = `请输入验证码`);
|
||||
if (!F.password) return (I.value = `请输入密码`);
|
||||
if (F.password !== F.re_password)
|
||||
@@ -308,7 +304,7 @@ var ve = {
|
||||
(await w.post(`/register`, {
|
||||
type: P.value,
|
||||
account: e,
|
||||
phone_code: F.phone_code,
|
||||
phone_code: `86`,
|
||||
code: K.value ? F.code.trim() : ``,
|
||||
username: F.username.trim(),
|
||||
password: F.password,
|
||||
@@ -455,20 +451,7 @@ var ve = {
|
||||
),
|
||||
]),
|
||||
unref(P) === `phone`
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
m,
|
||||
{
|
||||
key: 3,
|
||||
modelValue: unref(F).phone_code,
|
||||
"onUpdate:modelValue": (a[2] ||= (e) =>
|
||||
(unref(F).phone_code = e)),
|
||||
disabled: unref(L) || unref(Z),
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`modelValue`, `disabled`],
|
||||
))
|
||||
? (openBlock(), createBlock(m, { key: 3 }))
|
||||
: createCommentVNode(``, !0),
|
||||
createElementVNode(`div`, D, [
|
||||
createElementVNode(
|
||||
|
||||
Reference in new issue
Block a user