diff --git a/src/stores/siteSettings.js b/src/stores/siteSettings.js index b13456d5..2a14bf8f 100644 --- a/src/stores/siteSettings.js +++ b/src/stores/siteSettings.js @@ -57,6 +57,8 @@ const useSiteSettingsStore = defineStore("siteSettings", { downloadCover: true, // 同时下载封面 downloadLyrics: true, // 同时下载歌词 // 网络部分 + useRealIP: true, // 是否使用真实IP地址 + realIP: "116.25.146.177", // 真实IP地址 proxyProtocol: "off", // 代理协议 proxyServe: "127.0.0.1", // 代理地址 proxyPort: 80, // 代理端口 diff --git a/src/utils/request.js b/src/utils/request.js index 7f826c8f..c591806e 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,5 +1,6 @@ import { checkPlatform } from "@/utils/helper"; import { getCookie, isLogin } from "@/utils/auth"; +import { siteSettings } from "@/stores"; import axios from "axios"; // 全局地址 @@ -16,6 +17,7 @@ axios.defaults.withCredentials = true; // 请求拦截 axios.interceptors.request.use( (request) => { + const settings = siteSettings(); if (!request.params) request.params = {}; // 附加 cookie if (!request.noCookie && (isLogin() || getCookie("MUSIC_U") !== null)) { @@ -26,7 +28,9 @@ axios.interceptors.request.use( request.params.noCookie = true; } // 附加 realIP - if (!checkPlatform.electron()) request.params.realIP = "116.25.146.177"; + if (settings.useRealIP) { + request.params.realIP = settings.realIP || "116.25.146.177"; + } // 附加代理 const proxy = JSON.parse(localStorage.getItem("siteSettings")).proxyProtocol; if (proxy !== "off") { diff --git a/src/views/Setting/other.vue b/src/views/Setting/other.vue index ecb6ede6..5890df7c 100644 --- a/src/views/Setting/other.vue +++ b/src/views/Setting/other.vue @@ -1,6 +1,30 @@