|
|
@@ -60,7 +60,8 @@
|
|
|
</div>
|
|
|
<div>
|
|
|
<label class="flex cursor-pointer items-center">
|
|
|
- <input type="checkbox" class="form-checkbox bg-white dark:bg-black" />
|
|
|
+ <input v-model="inputValue.checked" type="checkbox"
|
|
|
+ class="form-checkbox bg-white dark:bg-black" />
|
|
|
<span class="text-white-dark">记住密码</span>
|
|
|
</label>
|
|
|
</div>
|
|
|
@@ -118,8 +119,13 @@ const inputValue = reactive({
|
|
|
password: '',
|
|
|
uuid: '',
|
|
|
scene: 'LOGIN',
|
|
|
- captcha: ''
|
|
|
+ captcha: '',
|
|
|
+ checked: false
|
|
|
});
|
|
|
+const loginForm = ref({
|
|
|
+ username: '',
|
|
|
+ password: "",
|
|
|
+})
|
|
|
interface LoginResponse {
|
|
|
data: any;
|
|
|
response: {
|
|
|
@@ -128,19 +134,32 @@ interface LoginResponse {
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+const MixinClone = (obj) => {
|
|
|
+ return JSON.parse(JSON.stringify(obj))
|
|
|
+}
|
|
|
const handleSubmit = async () => {
|
|
|
try {
|
|
|
inputValue.uuid = uuid;
|
|
|
- const response = await UserService.login(inputValue) as LoginResponse
|
|
|
+ const params = MixinClone(inputValue)
|
|
|
+ const response = await UserService.login(params) as LoginResponse
|
|
|
store.setUser({
|
|
|
...response.data,
|
|
|
token: response.data.refresh_token
|
|
|
});
|
|
|
+ // 判断是否记住密码
|
|
|
+ if (inputValue.checked) {
|
|
|
+ loginForm.value.username = inputValue.username
|
|
|
+ loginForm.value.password = inputValue.password
|
|
|
+ localStorage.setItem("loginForm", JSON.stringify(loginForm));
|
|
|
+ } else {
|
|
|
+ localStorage.setItem("loginForm", JSON.stringify({}));
|
|
|
+ }
|
|
|
+ // 路由跳转到首页
|
|
|
router.replace({
|
|
|
name: 'home'
|
|
|
});
|
|
|
} catch (error) {
|
|
|
+ changeValidcode()
|
|
|
console.error('Login failed:', error);
|
|
|
}
|
|
|
/* try {
|
|
|
@@ -161,6 +180,20 @@ onMounted(() => {
|
|
|
const _uuid = uuidv4()
|
|
|
uuid = _uuid
|
|
|
changeValidcode()
|
|
|
+ //在setup中,用来加载页面时,查看账户密码是否存在
|
|
|
+ if (localStorage.getItem("loginForm") != null && Object.keys(localStorage.getItem("loginForm") ?? 'null').length > 2) {
|
|
|
+
|
|
|
+ inputValue.checked = true;
|
|
|
+ var userPwdInfo = JSON.parse(localStorage.getItem("loginForm") ?? 'null');
|
|
|
+ console.log(userPwdInfo._value);
|
|
|
+ inputValue.username = userPwdInfo._value.username;
|
|
|
+ inputValue.password = userPwdInfo._value.password;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ inputValue.checked = false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
const router = useRouter();
|
|
|
|