mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
fix: CORS
This commit is contained in:
parent
94ef0934a5
commit
e169ee19e2
3 changed files with 16 additions and 0 deletions
|
|
@ -50,3 +50,11 @@ export function getMusicU(string) {
|
||||||
export function setMusicU(key, value) {
|
export function setMusicU(key, value) {
|
||||||
return Cookies.set(key, value);
|
return Cookies.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setCookies(string) {
|
||||||
|
const cookies = string.split(";;");
|
||||||
|
cookies.map((cookie) => {
|
||||||
|
document.cookie = cookie;
|
||||||
|
console.log(cookie);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
let baseURL = "";
|
let baseURL = "";
|
||||||
// Web 和 Electron 跑在不同端口避免同时启动时冲突
|
// Web 和 Electron 跑在不同端口避免同时启动时冲突
|
||||||
|
|
@ -18,6 +19,11 @@ const service = axios.create({
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
service.interceptors.request.use(function (config) {
|
||||||
|
config.params.cookie = `MUSIC_U=${Cookies.get("MUSIC_U")};`;
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
const res = response.data;
|
const res = response.data;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@
|
||||||
<script>
|
<script>
|
||||||
import NProgress from "nprogress";
|
import NProgress from "nprogress";
|
||||||
import { loginWithPhone, loginWithEmail } from "@/api/auth";
|
import { loginWithPhone, loginWithEmail } from "@/api/auth";
|
||||||
|
import { setCookies } from "@/utils/auth";
|
||||||
import md5 from "crypto-js/md5";
|
import md5 from "crypto-js/md5";
|
||||||
import { mapMutations } from "vuex";
|
import { mapMutations } from "vuex";
|
||||||
|
|
||||||
|
|
@ -183,6 +184,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.code === 200) {
|
if (data.code === 200) {
|
||||||
|
setCookies(data.cookie);
|
||||||
this.updateData({ key: "user", value: data.profile });
|
this.updateData({ key: "user", value: data.profile });
|
||||||
this.updateData({ key: "loginMode", value: "account" });
|
this.updateData({ key: "loginMode", value: "account" });
|
||||||
this.$router.push({ path: "/library" });
|
this.$router.push({ path: "/library" });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue