Blame view

Antis.Erp.Plat/douyin/frontend/README.md 2.45 KB
f946e9dd   hexiaodong   hhh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  # frontend
  
  This template should help get you started developing with Vue 3 in Vite.
  
  ## Recommended IDE Setup
  
  [VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
  
  ## Recommended Browser Setup
  
  - Chromium-based browsers (Chrome, Edge, Brave, etc.):
    - [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) 
    - [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
  - Firefox:
    - [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
    - [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
  
  ## Type Support for `.vue` Imports in TS
  
  TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
  
  ## Customize configuration
  
  See [Vite Configuration Reference](https://vite.dev/config/).
  
  ## Project Setup
  
  ```sh
  npm install
  ```
  
  ### Compile and Hot-Reload for Development
  
  ```sh
  npm run dev
  ```
  
  ### Type-Check, Compile and Minify for Production
  
  ```sh
  npm run build
  ```
  
  ## 环境变量配置
  
  项目支持通过环境变量配置后端地址,用于开发和生产环境。
  
  ### 配置方式
  
  1. **开发环境**:创建 `.env` 文件
  2. **生产环境**:创建 `.env.production` 文件
  
  ### 环境变量说明
  
  - `VITE_API_BASE_URL`: 后端 API 基础地址(包含 `/api` 路径)
    - 开发环境默认: `http://localhost:5070/api`
    - 生产环境默认: `/api` (同站点部署)
  
  - `VITE_BACKEND_BASE_URL`: 后端服务器地址(不含 `/api` 路径,用于预览等功能)
    - 开发环境默认: `http://localhost:5070`
    - 生产环境默认: 当前域名 (`window.location.origin`)
  
  ### 配置示例
  
  **开发环境 (.env)**
  ```env
  VITE_API_BASE_URL=http://localhost:5070/api
  VITE_BACKEND_BASE_URL=http://localhost:5070
  ```
  
  **生产环境 (.env.production)**
  ```env
  VITE_API_BASE_URL=https://api.yourdomain.com/api
  VITE_BACKEND_BASE_URL=https://api.yourdomain.com
  ```
  
  或者如果 API 和前端在同一域名:
  ```env
  VITE_API_BASE_URL=/api
  VITE_BACKEND_BASE_URL=https://yourdomain.com
  ```
  
  > 💡 **提示**:修改环境变量后需要重新构建前端项目 (`npm run build`)