x
This commit is contained in:
+72
-3
@@ -1,5 +1,74 @@
|
||||
# Vue 3 + TypeScript + Vite
|
||||
# geMoldInsight Frontend
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
这是 geMoldInsight 的独立前端工程,基于:
|
||||
|
||||
Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
|
||||
- Vue 3
|
||||
- Vite
|
||||
- TypeScript
|
||||
- Pinia
|
||||
- Vue Router
|
||||
|
||||
当前推荐部署方式为:
|
||||
|
||||
> **独立前端部署 + 同域反代 + unified backend**
|
||||
|
||||
即:
|
||||
- 前端由 Nginx 静态站点独立提供
|
||||
- `/api`、`/health`、`/html` 通过同域反代统一转发到一个 unified backend
|
||||
- 前端继续使用相对路径调用后端接口
|
||||
|
||||
---
|
||||
|
||||
## 本地开发
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
开发服务器默认:
|
||||
- 端口:`5173`
|
||||
- 已代理:`/api`、`/health`、`/html`
|
||||
|
||||
---
|
||||
|
||||
## 生产构建
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
构建产物输出到:
|
||||
- `frontend/dist/`
|
||||
|
||||
该目录由前端 Nginx 镜像或外部静态站点托管,不再输出到仓库根目录 `static/`。
|
||||
|
||||
---
|
||||
|
||||
## 部署
|
||||
|
||||
当前仓库已提供:
|
||||
- [deploy/Dockerfile.frontend](../deploy/Dockerfile.frontend)
|
||||
- [deploy/nginx/frontend.conf](../deploy/nginx/frontend.conf)
|
||||
|
||||
以及根目录 Compose 中的 `frontend` 服务:
|
||||
|
||||
```bash
|
||||
docker compose --profile frontend up -d
|
||||
```
|
||||
|
||||
完整系统:
|
||||
|
||||
```bash
|
||||
docker compose --profile full up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 说明
|
||||
|
||||
前端历史上曾通过后端 `static/` 目录托管;当前已切换为独立部署模式。后端默认不再负责提供 SPA 页面,但仍提供:
|
||||
|
||||
- `/api/*`
|
||||
- `/health`
|
||||
- `/html/*`(gemold 分析产物)
|
||||
|
||||
@@ -244,7 +244,7 @@ export const inventoryApi = {
|
||||
|
||||
updatePurchaseOrderStatus(id: number, status: string) {
|
||||
return apiRequest<Schema<'PurchaseOrderResponse'>>(`/api/purchase-orders/${id}/status`, {
|
||||
method: 'PUT',
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ status }),
|
||||
})
|
||||
},
|
||||
@@ -405,6 +405,6 @@ export const moldinsightApi = {
|
||||
},
|
||||
|
||||
getAluminumPrice() {
|
||||
return apiRequest<{ price: number; unit: string; updated_at: string }>('/api/aluminum-price/')
|
||||
return apiRequest<{ price: number; unit: string; updated_at: string }>('/api/aluminum-price/current')
|
||||
},
|
||||
}
|
||||
|
||||
+10
-2
@@ -9,9 +9,9 @@ export default defineConfig(({ mode }) => ({
|
||||
'@': resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
base: mode === 'development' ? '/' : '/static/',
|
||||
base: '/',
|
||||
build: {
|
||||
outDir: '../static',
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
@@ -21,6 +21,14 @@ export default defineConfig(({ mode }) => ({
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/health': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/html': {
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user