File tree Expand file tree Collapse file tree 6 files changed +37
-37
lines changed Expand file tree Collapse file tree 6 files changed +37
-37
lines changed Original file line number Diff line number Diff line change 1
- VITE_USE_PRODUCTION_API = true
1
+ # 后端接口地址
2
+ VITE_API = https://prts.maa.plus
3
+
4
+ # 地图站地址
2
5
VITE_THERESA_SERVER = https://theresa.wiki
Original file line number Diff line number Diff line change
1
+ # 本地开发端口
2
+ PORT = 3000
3
+
4
+ # 如果需要使用生产环境的API,请把下面一行注释掉,或者在.env.development.local中覆盖
5
+ VITE_API = https://maa-docker.kkdy.tech
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ MAA 作业站前端!
4
4
5
5
## 开发流程
6
6
7
+ 后端接口文档:https://maa-docker.kkdy.tech/swagger-ui/index.html
8
+
7
9
该仓库的主分支为 ` dev ` ,线上分支为 ` main ` ,代码合并到 ` main ` 后将会自动部署到线上
8
10
9
11
在自己的 fork 上开发完成后请提交 PR 到 ` dev ` 分支,由管理员合并
@@ -12,15 +14,9 @@ MAA 作业站前端!
12
14
13
15
## 环境变量
14
16
15
- 环境变量在 ` .env ` 文件内定义,你也可以创建 ` .env.local ` 来覆盖 ` .env ` 的配置
16
-
17
- ``` ini
18
- # 使用线上的后端 API,否则使用本地开发服务器
19
- VITE_USE_PRODUCTION_API =true
17
+ 环境变量定义在 ` .env ` ` .dev.development ` 文件内
20
18
21
- # 地图服务器,如果正在对地图进行本地开发请改为例如 http://localhost:3001
22
- VITE_THERESA_SERVER =https://theresa.wiki
23
- ```
19
+ 你可以创建 ` .env.development.local ` 文件来覆盖环境变量,优先级为 ` .env.development.local ` > ` .env.development ` > ` .env `
24
20
25
21
## 命令
26
22
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ import unfetch from 'unfetch'
4
4
5
5
import { Response } from 'models/network'
6
6
7
- import { envUseProductionApi } from './envvar'
8
-
9
7
const fetch = window . fetch || unfetch
10
8
11
9
export class NetworkError extends Error { }
12
10
13
- const baseURL = envUseProductionApi
14
- ? 'https://prts.maa.plus'
15
- : 'http://localhost:5259'
11
+ if ( ! import . meta. env . VITE_API ) {
12
+ throw new Error ( 'env var VITE_API is not set' )
13
+ }
14
+
15
+ const baseURL = import . meta. env . VITE_API as string
16
16
17
17
export const FETCHER_CONFIG : {
18
18
apiToken ?: ( ) => Promise < string | undefined >
Original file line number Diff line number Diff line change 1
1
import react from '@vitejs/plugin-react'
2
2
3
- import { defineConfig } from 'vite'
3
+ import { defineConfig , loadEnv } from 'vite'
4
4
import viteTsconfigPath from 'vite-tsconfig-paths'
5
5
6
6
// https://vitejs.dev/config/
7
- export default defineConfig ( {
8
- plugins : [ react ( ) , viteTsconfigPath ( ) ] ,
9
- server : {
10
- port : 3000 ,
11
- } ,
12
- resolve : {
13
- alias : {
14
- src : require ( 'path' ) . resolve ( __dirname , 'src' ) ,
7
+ export default defineConfig ( ( { command, mode } ) => {
8
+ // Load env file based on `mode` in the current working directory.
9
+ // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
10
+ const env = loadEnv ( mode , process . cwd ( ) , '' )
11
+
12
+ return {
13
+ plugins : [ react ( ) , viteTsconfigPath ( ) ] ,
14
+ server : {
15
+ port : + env . PORT || undefined ,
16
+ } ,
17
+ resolve : {
18
+ alias : {
19
+ src : require ( 'path' ) . resolve ( __dirname , 'src' ) ,
20
+ } ,
21
+ } ,
22
+ build : {
23
+ sourcemap : true ,
15
24
} ,
16
- } ,
17
- build : {
18
- sourcemap : true ,
19
- } ,
25
+ }
20
26
} )
You can’t perform that action at this time.
0 commit comments