Add tools menu and submenu. Add Add multiple environments. #28

Merged
FatttSnake merged 4 commits from FatttSnake into dev 2023-10-10 01:35:59 +08:00
6 changed files with 19 additions and 2 deletions
Showing only changes of commit f0782cdfa2 - Show all commits

2
.env.development Normal file
View File

@@ -0,0 +1,2 @@
VITE_API_URL=http://localhost:8080
VITE_API_TOKEN_URL=${VITE_API_URL}/token

2
.env.production Normal file
View File

@@ -0,0 +1,2 @@
VITE_API_URL=http://api.fatweb.top
VITE_API_TOKEN_URL=${VITE_API_URL}/token

3
.env.testing Normal file
View File

@@ -0,0 +1,3 @@
NODE_ENV=development
VITE_API_URL=http://api-test.fatweb.top
VITE_API_TOKEN_URL=${VITE_API_URL}/token

View File

@@ -7,6 +7,7 @@
"dev": "vite", "dev": "vite",
"dev-host": "vite --host 0.0.0.0", "dev-host": "vite --host 0.0.0.0",
"build": "vite build", "build": "vite build",
"build-test": "vite build --mode testing",
"clean": "rimraf dist .eslintrc-auto-import.json auto-imports.d.ts", "clean": "rimraf dist .eslintrc-auto-import.json auto-imports.d.ts",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write src/", "format": "prettier --write src/",

View File

@@ -14,7 +14,7 @@ import {
import { message } from 'antd' import { message } from 'antd'
const service: AxiosInstance = axios.create({ const service: AxiosInstance = axios.create({
baseURL: 'http://localhost:8181', baseURL: import.meta.env.VITE_API_URL,
timeout: 10000, timeout: 10000,
withCredentials: false withCredentials: false
}) })
@@ -44,7 +44,7 @@ service.interceptors.request.use(
jwt.exp * 1000 - new Date().getTime() > 0 jwt.exp * 1000 - new Date().getTime() > 0
) { ) {
await axios await axios
.get('http://localhost:8181/token', { .get(import.meta.env.VITE_API_TOKEN_URL, {
headers: { token } headers: { token }
}) })
.then((value: AxiosResponse<_Response<Token>>) => { .then((value: AxiosResponse<_Response<Token>>) => {

9
src/vite-env.d.ts vendored
View File

@@ -1,5 +1,14 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_URL: string
readonly VITE_API_TOKEN_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
type RouteHandle = { type RouteHandle = {
name?: string name?: string
menu?: boolean menu?: boolean