diff --git a/src/utils/auth.js b/src/utils/auth.js index 5376250..d62419c 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -50,3 +50,11 @@ export function getMusicU(string) { export function setMusicU(key, value) { return Cookies.set(key, value); } + +export function setCookies(string) { + const cookies = string.split(";;"); + cookies.map((cookie) => { + document.cookie = cookie; + console.log(cookie); + }); +} diff --git a/src/utils/request.js b/src/utils/request.js index 76dba79..9d5d377 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,4 +1,5 @@ import axios from "axios"; +import Cookies from "js-cookie"; let baseURL = ""; // Web 和 Electron 跑在不同端口避免同时启动时冲突 @@ -18,6 +19,11 @@ const service = axios.create({ timeout: 15000, }); +service.interceptors.request.use(function (config) { + config.params.cookie = `MUSIC_U=${Cookies.get("MUSIC_U")};`; + return config; +}); + service.interceptors.response.use( (response) => { const res = response.data; diff --git a/src/views/loginAccount.vue b/src/views/loginAccount.vue index 72d1b7b..1df4691 100644 --- a/src/views/loginAccount.vue +++ b/src/views/loginAccount.vue @@ -93,6 +93,7 @@