Skip to content

Commit

Permalink
🐞 fix: 修复海外地区播放问题 #238
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Aug 23, 2024
1 parent b0a08ce commit 8a842aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/stores/siteSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, // 代理端口
Expand Down
6 changes: 5 additions & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkPlatform } from "@/utils/helper";
import { getCookie, isLogin } from "@/utils/auth";
import { siteSettings } from "@/stores";
import axios from "axios";

// 全局地址
Expand All @@ -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)) {
Expand All @@ -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") {
Expand Down
26 changes: 25 additions & 1 deletion src/views/Setting/other.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
<template>
<div class="set-type">
<n-h3 prefix="bar"> 其他 </n-h3>
<n-card class="set-item">
<div class="name">
使用真实 IP 地址
<n-text class="tip">在海外或部分地区可能会受到限制,可开启此处尝试解决</n-text>
</div>
<n-switch v-model:value="useRealIP" :round="false" />
</n-card>
<n-card class="set-item">
<div class="name">
真实 IP 地址
<n-text class="tip">可在此处输入国内 IP</n-text>
</div>
<n-input
v-model:value="realIP"
:disabled="!useRealIP"
class="set"
type="text"
placeholder="请填写真实 IP 地址"
>
<template #prefix>
<n-text depth="3">IP</n-text>
</template>
</n-input>
</n-card>
<div v-if="checkPlatform.electron()" class="all-porxy" style="margin-bottom: 12px">
<n-card class="set-item">
<div class="name">
Expand Down Expand Up @@ -111,7 +135,7 @@ import { checkPlatform } from "@/utils/helper";
import debounce from "@/utils/debounce";
const settings = siteSettings();
const { themeAuto, loadSize, showGithub, proxyProtocol, proxyServe, proxyPort } =
const { themeAuto, loadSize, showGithub, proxyProtocol, proxyServe, proxyPort, useRealIP, realIP } =
storeToRefs(settings);
// 程序重置
Expand Down

0 comments on commit 8a842aa

Please sign in to comment.