fix: bugs

This commit is contained in:
qier222 2021-04-26 15:38:39 +08:00
parent 603e39f362
commit 2c8ba10e20
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
7 changed files with 59 additions and 80 deletions

View file

@ -1,10 +1,10 @@
import axios from "axios";
import Cookies from "js-cookie";
import axios from 'axios';
import Cookies from 'js-cookie';
let baseURL = "";
let baseURL = '';
// Web 和 Electron 跑在不同端口避免同时启动时冲突
if (process.env.IS_ELECTRON) {
if (process.env.NODE_ENV === "production") {
if (process.env.NODE_ENV === 'production') {
baseURL = process.env.VUE_APP_ELECTRON_API_URL;
} else {
baseURL = process.env.VUE_APP_ELECTRON_API_URL_DEV;
@ -21,18 +21,18 @@ const service = axios.create({
service.interceptors.request.use(function (config) {
if (!config.params) config.params = {};
if (baseURL[0] !== "/") {
config.params.cookie = `MUSIC_U=${Cookies.get("MUSIC_U")};`;
if (baseURL[0] !== '/' && !process.env.IS_ELECTRON) {
config.params.cookie = `MUSIC_U=${Cookies.get('MUSIC_U')};`;
}
return config;
});
service.interceptors.response.use(
(response) => {
response => {
const res = response.data;
return res;
},
(error) => {
error => {
return Promise.reject(error);
}
);