feat: 优化B站视频代理URL获取逻辑

This commit is contained in:
algerkong
2025-04-04 21:16:09 +08:00
parent 7f7d41f883
commit a24f901d1d
3 changed files with 19 additions and 14 deletions
+11
View File
@@ -101,3 +101,14 @@ export const isElectron = (window as any).electron !== undefined;
export const isLyricWindow = computed(() => {
return window.location.hash.includes('lyric');
});
export const getSetData = (): any => {
let setData = null;
if (window.electron) {
setData = window.electron.ipcRenderer.sendSync('get-store-value', 'set');
} else {
const settingsStore = useSettingsStore();
setData = settingsStore.setData;
}
return setData;
};
+2 -12
View File
@@ -1,20 +1,10 @@
import axios, { InternalAxiosRequestConfig } from 'axios';
import { useSettingsStore } from '@/store/modules/settings';
import { useUserStore } from '@/store/modules/user';
import { isElectron } from '.';
import { getSetData, isElectron } from '.';
let setData: any = null;
const getSetData = () => {
if (window.electron) {
setData = window.electron.ipcRenderer.sendSync('get-store-value', 'set');
} else {
const settingsStore = useSettingsStore();
setData = settingsStore.setData;
}
return setData;
};
// 扩展请求配置接口
interface CustomAxiosRequestConfig extends InternalAxiosRequestConfig {
@@ -39,7 +29,7 @@ const RETRY_DELAY = 500;
// 请求拦截器
request.interceptors.request.use(
(config: CustomAxiosRequestConfig) => {
getSetData();
setData = getSetData();
config.baseURL = window.electron
? `http://127.0.0.1:${setData?.musicApiPort}`
: import.meta.env.VITE_API;