mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 21:58:03 +00:00
feat: using vuex to make login status reactively (#51)
This commit is contained in:
parent
5ce9c3689a
commit
780b429fa9
13 changed files with 110 additions and 71 deletions
|
|
@ -112,9 +112,9 @@ export default {
|
|||
NProgress.done();
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["updateUser", "updateUserInfo"]),
|
||||
...mapMutations(["updateUser", "updateUserInfo", "updateAccountLogin"]),
|
||||
afterLogin() {
|
||||
// Cookies.set("MUSIC_U", true, { expires: 3650 });
|
||||
this.updateAccountLogin(true);
|
||||
Cookies.set("loginMode", "account", { expires: 3650 });
|
||||
userPlaylist({
|
||||
uid: this.$store.state.settings.user.userId,
|
||||
|
|
@ -127,18 +127,34 @@ export default {
|
|||
this.$router.push({ path: "/library" });
|
||||
});
|
||||
},
|
||||
validatePhone() {
|
||||
if (
|
||||
this.countryCode === "" ||
|
||||
this.phone === "" ||
|
||||
this.password === ""
|
||||
) {
|
||||
alert("国家区号、手机或密码不正确");
|
||||
this.processing = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
validateEmail() {
|
||||
const emailReg = /^[A-Za-z0-9]+([_][A-Za-z0-9]+)*@([A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/;
|
||||
if (
|
||||
this.email === "" ||
|
||||
this.password === "" ||
|
||||
!emailReg.test(this.email)
|
||||
) {
|
||||
alert("邮箱或密码不正确");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
login() {
|
||||
this.processing = true;
|
||||
if (this.mode === "phone") {
|
||||
if (
|
||||
this.countryCode === "" ||
|
||||
this.phone === "" ||
|
||||
this.password === ""
|
||||
) {
|
||||
alert("国家区号、手机或密码不正确");
|
||||
this.processing = false;
|
||||
return;
|
||||
}
|
||||
this.processing = this.validatePhone();
|
||||
loginWithPhone({
|
||||
countrycode: this.countryCode.replace("+", "").replace(/\s/g, ""),
|
||||
phone: this.phoneNumber.replace(/\s/g, ""),
|
||||
|
|
@ -156,16 +172,7 @@ export default {
|
|||
alert(error);
|
||||
});
|
||||
} else {
|
||||
let emailReg = /^[A-Za-z0-9]+([_][A-Za-z0-9]+)*@([A-Za-z0-9]+\.)+[A-Za-z]{2,6}$/;
|
||||
if (
|
||||
this.email === "" ||
|
||||
this.password === "" ||
|
||||
!emailReg.test(this.email)
|
||||
) {
|
||||
alert("邮箱或密码不正确");
|
||||
this.processing = false;
|
||||
return;
|
||||
}
|
||||
this.processing = this.validateEmail();
|
||||
loginWithEmail({
|
||||
email: this.email.replace(/\s/g, ""),
|
||||
password: "fakePassword",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue