diff --git a/src/frontend/.env.production b/src/frontend/.env.production new file mode 100644 index 0000000..03dcf6d --- /dev/null +++ b/src/frontend/.env.production @@ -0,0 +1,2 @@ +# API 地址配置 +VITE_API_BASE_URL=https://app.zpc-xy.com/corps/api/api/admin diff --git a/src/frontend/Dockerfile b/src/frontend/Dockerfile index 1ed6ab3..e88bd99 100644 --- a/src/frontend/Dockerfile +++ b/src/frontend/Dockerfile @@ -2,7 +2,7 @@ FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN rm -f package-lock.json && npm install COPY . . RUN npm run build diff --git a/src/frontend/src/api/client.ts b/src/frontend/src/api/client.ts index 6b1a35d..78dd90e 100644 --- a/src/frontend/src/api/client.ts +++ b/src/frontend/src/api/client.ts @@ -2,7 +2,7 @@ import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'ax import { ElMessage } from 'element-plus' const apiClient: AxiosInstance = axios.create({ - baseURL: '/api/admin', + baseURL: import.meta.env.VITE_API_BASE_URL || '/api/admin', timeout: 30000, headers: { 'Content-Type': 'application/json' diff --git a/src/frontend/src/router/index.ts b/src/frontend/src/router/index.ts index 7eef9f5..73c1379 100644 --- a/src/frontend/src/router/index.ts +++ b/src/frontend/src/router/index.ts @@ -105,7 +105,7 @@ const routes: RouteRecordRaw[] = [ ] const router = createRouter({ - history: createWebHistory(), + history: createWebHistory('/corps/web/'), routes }) diff --git a/src/frontend/src/views/Login.vue b/src/frontend/src/views/Login.vue index 9986b19..ed18425 100644 --- a/src/frontend/src/views/Login.vue +++ b/src/frontend/src/views/Login.vue @@ -85,8 +85,12 @@ async function handleLogin() { if (success) { ElMessage.success('登录成功') - const redirect = route.query.redirect as string || '/dashboard' - router.push(redirect) + const redirect = route.query.redirect as string + if (redirect) { + router.push(redirect) + } else { + router.push({ name: 'Dashboard' }) + } } else { ElMessage.error('用户名或密码错误') } diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index f3b9246..5fa90b0 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -4,6 +4,7 @@ import { resolve } from 'path' import { fileURLToPath, URL } from 'node:url' export default defineConfig({ + base: '/corps/web/', plugins: [vue()], resolve: { alias: {