mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-05 23:50:52 +08:00
Compare commits
1 Commits
feat/windo
...
v4.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f33861fd25 |
@@ -1,4 +1,5 @@
|
||||
import type { IBilibiliPlayUrl, IBilibiliVideoDetail } from '@/types/bilibili';
|
||||
import { getSetData, isElectron } from '@/utils';
|
||||
import request from '@/utils/request';
|
||||
|
||||
interface ISearchParams {
|
||||
@@ -121,10 +122,13 @@ export const getBilibiliPlayUrl = (
|
||||
});
|
||||
};
|
||||
|
||||
// `http://127.0.0.1:30666/bilibili/stream-proxy?url=${encodeURIComponent(`https:${item.pic}`)}`,
|
||||
export const getBilibiliProxyUrl = (url: string) => {
|
||||
const setData = getSetData();
|
||||
const baseURL = isElectron
|
||||
? `http://127.0.0.1:${setData?.musicApiPort}`
|
||||
: import.meta.env.VITE_API;
|
||||
const AUrl = url.startsWith('http') ? url : `https:${url}`;
|
||||
return `${import.meta.env.VITE_API}/bilibili/stream-proxy?url=${encodeURIComponent(AUrl)}`;
|
||||
return `${baseURL}/bilibili/stream-proxy?url=${encodeURIComponent(AUrl)}`;
|
||||
};
|
||||
|
||||
export const getBilibiliAudioUrl = async (bvid: string, cid: number): Promise<string> => {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user