From 8a842aa6d657a1b7c46e5a227ab0bb48c710b741 Mon Sep 17 00:00:00 2001 From: imsyy Date: Fri, 23 Aug 2024 11:32:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B5=B7=E5=A4=96=E5=9C=B0=E5=8C=BA=E6=92=AD=E6=94=BE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20#238?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/siteSettings.js | 2 ++ src/utils/request.js | 6 +++++- src/views/Setting/other.vue | 26 +++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) 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 @@