272 lines
9.4 KiB
JavaScript
272 lines
9.4 KiB
JavaScript
import { x as ElFormItem, y as ElInput, i as ElIcon, l as ElTooltip, h as ElButton, w as ElForm, r as ElText, t as ElLink } from "./element-plus.CkEW9frc.js";
|
|
import { J as defineComponent, e9 as useI18n, ev as useModel, aO as resolveComponent, S as openBlock, _ as createElementBlock, a1 as createBaseVNode, aa as toDisplayString, o as unref, $ as createVNode, a0 as withCtx, a_ as withKeys, a9 as createTextVNode, r as ref, j as computed } from "./.pnpm.BW3P1y8f.js";
|
|
import { U as UserAPI } from "./index.CMd5bD1r.js";
|
|
import "./codemirror.CvJAcn2d.js";
|
|
const _hoisted_1 = {
|
|
"text-center": "",
|
|
"m-0": "",
|
|
"mb-20px": ""
|
|
};
|
|
const _hoisted_2 = {
|
|
"flex-center": "",
|
|
"gap-10px": ""
|
|
};
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "ResetPwd",
|
|
props: {
|
|
"modelValue": {},
|
|
"modelModifiers": {},
|
|
"presetUsername": {},
|
|
"presetUsernameModifiers": {},
|
|
"presetPassword": {},
|
|
"presetPasswordModifiers": {}
|
|
},
|
|
emits: ["update:modelValue", "update:presetUsername", "update:presetPassword"],
|
|
setup(__props) {
|
|
const loading = ref(false);
|
|
const isCapsLock = ref(false);
|
|
const { t } = useI18n();
|
|
const modelValue = useModel(__props, "modelValue");
|
|
const presetUsername = useModel(__props, "presetUsername");
|
|
const presetPassword = useModel(__props, "presetPassword");
|
|
const toLogin = () => {
|
|
modelValue.value = "login";
|
|
};
|
|
const model = ref({
|
|
username: "",
|
|
new_password: "",
|
|
confirmPassword: ""
|
|
});
|
|
const rules = computed(() => {
|
|
return {
|
|
username: [
|
|
{
|
|
required: true,
|
|
trigger: "blur",
|
|
message: t("login.message.username.required")
|
|
}
|
|
],
|
|
new_password: [
|
|
{
|
|
required: true,
|
|
trigger: "blur",
|
|
message: t("login.message.password.required")
|
|
},
|
|
{
|
|
min: 6,
|
|
message: t("login.message.password.min"),
|
|
trigger: "blur"
|
|
}
|
|
],
|
|
confirmPassword: [
|
|
{
|
|
required: true,
|
|
trigger: "blur",
|
|
message: t("login.message.password.required")
|
|
},
|
|
{
|
|
min: 6,
|
|
message: t("login.message.password.min"),
|
|
trigger: "blur"
|
|
},
|
|
{
|
|
validator: (_, value) => {
|
|
return value === model.value.new_password;
|
|
},
|
|
trigger: "blur",
|
|
message: t("login.message.password.inconformity")
|
|
}
|
|
],
|
|
mobile: [
|
|
{
|
|
required: true,
|
|
trigger: "blur",
|
|
message: t("login.message.captchaCode.required")
|
|
}
|
|
]
|
|
};
|
|
});
|
|
const formRef = ref();
|
|
const submit = async () => {
|
|
var _a;
|
|
try {
|
|
const valid = await ((_a = formRef.value) == null ? void 0 : _a.validate());
|
|
if (!valid) return;
|
|
loading.value = true;
|
|
await UserAPI.forgetPassword(model.value);
|
|
presetUsername.value = model.value.username;
|
|
presetPassword.value = model.value.new_password;
|
|
toLogin();
|
|
} catch (error) {
|
|
console.error(error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
function checkCapsLock(event) {
|
|
if (event instanceof KeyboardEvent) {
|
|
isCapsLock.value = event.getModifierState("CapsLock");
|
|
}
|
|
}
|
|
return (_ctx, _cache) => {
|
|
const _component_User = resolveComponent("User");
|
|
const _component_el_icon = ElIcon;
|
|
const _component_el_input = ElInput;
|
|
const _component_el_form_item = ElFormItem;
|
|
const _component_Lock = resolveComponent("Lock");
|
|
const _component_el_tooltip = ElTooltip;
|
|
const _component_el_button = ElButton;
|
|
const _component_el_form = ElForm;
|
|
const _component_el_text = ElText;
|
|
const _component_el_link = ElLink;
|
|
return openBlock(), createElementBlock("div", null, [
|
|
createBaseVNode("h3", _hoisted_1, toDisplayString(unref(t)("login.resetPassword")), 1),
|
|
createVNode(_component_el_form, {
|
|
ref_key: "formRef",
|
|
ref: formRef,
|
|
model: unref(model),
|
|
rules: unref(rules),
|
|
size: "large",
|
|
"label-suffix": ":"
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_form_item, { prop: "username" }, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_input, {
|
|
modelValue: unref(model).username,
|
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(model).username = $event),
|
|
modelModifiers: { trim: true },
|
|
placeholder: unref(t)("login.username"),
|
|
clearable: ""
|
|
}, {
|
|
prefix: withCtx(() => [
|
|
createVNode(_component_el_icon, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_User)
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["modelValue", "placeholder"])
|
|
]),
|
|
_: 1
|
|
}),
|
|
createVNode(_component_el_tooltip, {
|
|
visible: unref(isCapsLock),
|
|
content: unref(t)("login.capsLock"),
|
|
placement: "right"
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_form_item, { prop: "new_password" }, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_input, {
|
|
modelValue: unref(model).new_password,
|
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(model).new_password = $event),
|
|
modelModifiers: { trim: true },
|
|
placeholder: unref(t)("login.password"),
|
|
type: "password",
|
|
"show-password": "",
|
|
clearable: "",
|
|
onKeyup: [
|
|
checkCapsLock,
|
|
withKeys(submit, ["enter"])
|
|
]
|
|
}, {
|
|
prefix: withCtx(() => [
|
|
createVNode(_component_el_icon, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_Lock)
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["modelValue", "placeholder"])
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["visible", "content"]),
|
|
createVNode(_component_el_tooltip, {
|
|
visible: unref(isCapsLock),
|
|
content: unref(t)("login.capsLock"),
|
|
placement: "right"
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_form_item, { prop: "confirmPassword" }, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_input, {
|
|
modelValue: unref(model).confirmPassword,
|
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(model).confirmPassword = $event),
|
|
modelModifiers: { trim: true },
|
|
placeholder: unref(t)("login.message.password.confirm"),
|
|
type: "password",
|
|
"show-password": "",
|
|
clearable: "",
|
|
onKeyup: [
|
|
checkCapsLock,
|
|
withKeys(submit, ["enter"])
|
|
]
|
|
}, {
|
|
prefix: withCtx(() => [
|
|
createVNode(_component_el_icon, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_Lock)
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["modelValue", "placeholder"])
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["visible", "content"]),
|
|
createVNode(_component_el_form_item, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_el_button, {
|
|
type: "warning",
|
|
class: "w-full",
|
|
onClick: submit
|
|
}, {
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(t)("login.resetPassword")), 1)
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["model", "rules"]),
|
|
createBaseVNode("div", _hoisted_2, [
|
|
createVNode(_component_el_text, { size: "default" }, {
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(t)("login.thinkOfPasswd")), 1)
|
|
]),
|
|
_: 1
|
|
}),
|
|
createVNode(_component_el_link, {
|
|
type: "primary",
|
|
underline: "never",
|
|
onClick: toLogin
|
|
}, {
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(t)("login.login")), 1)
|
|
]),
|
|
_: 1
|
|
})
|
|
])
|
|
]);
|
|
};
|
|
}
|
|
});
|
|
export {
|
|
_sfc_main as default
|
|
};
|