fix(player): dev Vite proxy reads API PORT; wallet list rows blend with page background
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
import { resolveApiDevTarget } from '../../scripts/dev-api-target.mjs';
|
||||||
import { visualizer } from 'rollup-plugin-visualizer';
|
import { visualizer } from 'rollup-plugin-visualizer';
|
||||||
import AutoImport from 'unplugin-auto-import/vite';
|
import AutoImport from 'unplugin-auto-import/vite';
|
||||||
import Components from 'unplugin-vue-components/vite';
|
import Components from 'unplugin-vue-components/vite';
|
||||||
@@ -8,6 +9,7 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
|||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const analyze = process.env.ANALYZE === '1' || mode === 'analyze';
|
const analyze = process.env.ANALYZE === '1' || mode === 'analyze';
|
||||||
|
const apiTarget = resolveApiDevTarget();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -75,8 +77,8 @@ export default defineConfig(({ mode }) => {
|
|||||||
server: {
|
server: {
|
||||||
port: 5174,
|
port: 5174,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': { target: 'http://localhost:3000', changeOrigin: true },
|
'/api': { target: apiTarget, changeOrigin: true },
|
||||||
'/uploads': { target: 'http://localhost:3000', changeOrigin: true },
|
'/uploads': { target: apiTarget, changeOrigin: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ const pullIndicatorStyle = () => ({
|
|||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
background: var(--bg-card);
|
background: transparent;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ const pullIndicatorStyle = () => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tx-row:active {
|
.tx-row:active {
|
||||||
background: var(--bg-hover);
|
background: rgba(255, 255, 255, 0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tx-main {
|
.tx-main {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ const pullIndicatorStyle = () => ({
|
|||||||
padding: 6px 10px;
|
padding: 6px 10px;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
background: var(--bg-card);
|
background: transparent;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ const pullIndicatorStyle = () => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tx-row:active {
|
.tx-row:active {
|
||||||
background: var(--bg-hover);
|
background: rgba(255, 255, 255, 0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tx-main {
|
.tx-main {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
|
import { resolveApiDevTarget } from '../../scripts/dev-api-target.mjs';
|
||||||
|
|
||||||
|
const apiTarget = resolveApiDevTarget();
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
@@ -37,8 +40,8 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': { target: 'http://localhost:3000', changeOrigin: true },
|
'/api': { target: apiTarget, changeOrigin: true },
|
||||||
'/uploads': { target: 'http://localhost:3000', changeOrigin: true },
|
'/uploads': { target: apiTarget, changeOrigin: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
19
scripts/dev-api-target.mjs
Normal file
19
scripts/dev-api-target.mjs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { existsSync, readFileSync } from 'node:fs';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
|
|
||||||
|
/** 本地 dev:与 apps/api/.env 的 PORT 对齐,供 player/admin Vite 代理使用 */
|
||||||
|
export function resolveApiDevTarget() {
|
||||||
|
if (process.env.VITE_DEV_API_TARGET) return process.env.VITE_DEV_API_TARGET;
|
||||||
|
if (process.env.API_DEV_TARGET) return process.env.API_DEV_TARGET;
|
||||||
|
|
||||||
|
let port = '3000';
|
||||||
|
const envPath = resolve(repoRoot, 'apps/api/.env');
|
||||||
|
if (existsSync(envPath)) {
|
||||||
|
const match = readFileSync(envPath, 'utf8').match(/^PORT=(\d+)\s*$/m);
|
||||||
|
if (match) port = match[1];
|
||||||
|
}
|
||||||
|
return `http://localhost:${port}`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user