From 42048764d51314116b2e3f16e510f4045c6d69cb Mon Sep 17 00:00:00 2001 From: alger Date: Sat, 7 Dec 2024 11:38:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=83=20docs:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 15 ++++++++++++--- .env.production | 3 --- .gitignore | 2 ++ README.md | 41 +++++++++++++++++++++++++++++++++-------- src/utils/index.ts | 4 +--- vite.config.ts | 17 +++++++++++------ 6 files changed, 59 insertions(+), 23 deletions(-) delete mode 100644 .env.production diff --git a/.env.development b/.env.development index 7fb820e..76730e5 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,12 @@ -VITE_API = /api -VITE_API_MUSIC = /music -VITE_API_PROXY = http://110.42.251.190:9856 \ No newline at end of file +# 你的接口地址 (必填) +VITE_API = *** +# 音乐破解接口地址 +VITE_API_MUSIC = *** +# 代理地址 +VITE_API_PROXY = *** + + +# 本地运行代理地址 +VITE_API_PROXY = /api +VITE_API_MUSIC_PROXY = /music +VITE_API_PROXY_MUSIC = /music_proxy diff --git a/.env.production b/.env.production deleted file mode 100644 index e5c86f3..0000000 --- a/.env.production +++ /dev/null @@ -1,3 +0,0 @@ -VITE_API = http://110.42.251.190:9898 -VITE_API_MUSIC = http://110.42.251.190:4100 -VITE_API_PROXY = http://110.42.251.190:9856 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 08bebeb..7794f9d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ dist.zip .vscode bun.lockb + +.env.*.local \ No newline at end of file diff --git a/README.md b/README.md index 105b173..9f46480 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ ## 预览地址 [http://mc.alger.fun/](http://mc.alger.fun/) +## 软件截图 +![首页](./docs/img/image-7.png) +![歌词](./docs/img/image-6.png) +![歌单](./docs/img/image-1.png) +![搜索](./docs/img/image-8.png) +![mv](./docs/img/image-3.png) +![历史](./docs/img/image-4.png) +![我的](./docs/img/image-5.png) + ## 项目运行 ```bash # 安装依赖 @@ -29,17 +38,33 @@ npm run win ... # 具体看 package.json ``` +#### 注意 +- 本地运行需要配置 .env.development 文件 +- 打包需要配置 .env.production 文件 + +```bash + # .env.development + # 你的接口地址 (必填) + VITE_API = *** + # 音乐破解接口地址 + VITE_API_MUSIC = *** + # 代理地址 + VITE_API_PROXY = *** + # 本地运行代理地址 + VITE_API_PROXY = /api + VITE_API_MUSIC_PROXY = /music + VITE_API_PROXY_MUSIC = /music_proxy -## 软件截图 -![首页](./docs/img/image-7.png) -![歌词](./docs/img/image-6.png) -![歌单](./docs/img/image-1.png) -![搜索](./docs/img/image-8.png) -![mv](./docs/img/image-3.png) -![历史](./docs/img/image-4.png) -![我的](./docs/img/image-5.png) + # .env.production + # 你的接口地址 (必填) + VITE_API = *** + # 音乐破解接口地址 + VITE_API_MUSIC = *** + # 代理地址 + VITE_API_PROXY = *** +``` ## 欢迎提Issues diff --git a/src/utils/index.ts b/src/utils/index.ts index fdb76b9..568c975 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -54,11 +54,9 @@ export const getIsMc = () => { if (windowData.electron.ipcRenderer.getStoreValue('set').isProxy) { return true; } - if (window.location.origin.includes('localhost')) { - } return false; }; -const ProxyUrl = import.meta.env.VITE_API_PROXY || 'http://110.42.251.190:9856'; +const ProxyUrl = import.meta.env.VITE_API_PROXY; export const getMusicProxyUrl = (url: string) => { if (!getIsMc()) { diff --git a/vite.config.ts b/vite.config.ts index 688efb2..352d4e3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -36,15 +36,20 @@ export default defineConfig({ port: 4488, proxy: { // with options - '/api': { - target: 'http://110.42.251.190:9898', + [process.env.VITE_API_PROXY as string]: { + target: process.env.VITE_API, changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ''), + rewrite: (path) => path.replace(new RegExp(`^${process.env.VITE_API_PROXY}`), ''), }, - '/music': { - target: 'http://110.42.251.190:4100', + [process.env.VITE_API_MUSIC_PROXY as string]: { + target: process.env.VITE_API_MUSIC, changeOrigin: true, - rewrite: (path) => path.replace(/^\/music/, ''), + rewrite: (path) => path.replace(new RegExp(`^${process.env.VITE_API_MUSIC_PROXY}`), ''), + }, + [process.env.VITE_API_PROXY_MUSIC as string]: { + target: process.env.VITE_API_PROXY, + changeOrigin: true, + rewrite: (path) => path.replace(new RegExp(`^${process.env.VITE_API_PROXY_MUSIC}`), ''), }, }, },