lijinlong
杜函宇 1 year ago
parent 81b8397e47
commit d5b926ca80

@ -9,7 +9,11 @@ import { isRelogin } from "@/utils/request";
NProgress.configure({ showSpinner: false }); NProgress.configure({ showSpinner: false });
const whiteList = [ const whiteList = [
'/toLogin' '/toLogin',
'/home',
'/planManage',
"/enforcing",
"/focusEnter"
]; ];
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {

@ -130,8 +130,8 @@ export default {
}, },
}, },
created() { created() {
this.getCode(); // this.getCode();
this.getCookie(); // this.getCookie();
}, },
methods: { methods: {
getCode() { getCode() {
@ -158,31 +158,33 @@ export default {
handleLogin() { handleLogin() {
this.$refs.loginForm.validate((valid) => { this.$refs.loginForm.validate((valid) => {
if (valid) { if (valid) {
this.loading = true; // this.loading = true;
if (this.loginForm.rememberMe) { this.$router.push({ path: "/home" }).catch(() => {});
Cookies.set("username", this.loginForm.username, { expires: 30 });
Cookies.set("password", encrypt(this.loginForm.password), { // if (this.loginForm.rememberMe) {
expires: 30, // Cookies.set("username", this.loginForm.username, { expires: 30 });
}); // Cookies.set("password", encrypt(this.loginForm.password), {
Cookies.set("rememberMe", this.loginForm.rememberMe, { // expires: 30,
expires: 30, // });
}); // Cookies.set("rememberMe", this.loginForm.rememberMe, {
} else { // expires: 30,
Cookies.remove("username"); // });
Cookies.remove("password"); // } else {
Cookies.remove("rememberMe"); // Cookies.remove("username");
} // Cookies.remove("password");
this.$store // Cookies.remove("rememberMe");
.dispatch("Login", this.loginForm) // }
.then(() => { // this.$store
this.$router.push({ path: this.redirect || "/" }).catch(() => {}); // .dispatch("Login", this.loginForm)
}) // .then(() => {
.catch(() => { // this.$router.push({ path: this.redirect || "/" }).catch(() => {});
this.loading = false; // })
if (this.captchaEnabled) { // .catch(() => {
this.getCode(); // this.loading = false;
} // if (this.captchaEnabled) {
}); // this.getCode();
// }
// });
} }
}); });
}, },

Loading…
Cancel
Save