更新
This commit is contained in:
Generated
+1
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/mini-program/temp-uni" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# 测试环境配置
|
|
||||||
VITE_APP_TITLE=情绪博物馆
|
|
||||||
VITE_API_BASE_URL=http://test-api.example.com/api
|
|
||||||
VITE_WS_URL=ws://test-api.example.com/ws
|
|
||||||
+19
-12
@@ -1,13 +1,20 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<script>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||||
<title>mini-program</title>
|
CSS.supports('top: constant(a)'))
|
||||||
</head>
|
document.write(
|
||||||
<body>
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||||
<div id="app"></div>
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||||
<script type="module" src="/src/main.ts"></script>
|
</script>
|
||||||
</body>
|
<title></title>
|
||||||
|
<!--preload-links-->
|
||||||
|
<!--app-context-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"><!--app-html--></div>
|
||||||
|
<script type="module" src="/src/main.js"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* 环境配置工具
|
||||||
|
* 用于统一管理不同环境的配置
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 环境标识
|
||||||
|
export const ENV = import.meta.env.MODE
|
||||||
|
|
||||||
|
// API 基础地址
|
||||||
|
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL
|
||||||
|
|
||||||
|
// WebSocket 地址
|
||||||
|
export const WS_URL = import.meta.env.VITE_WS_URL
|
||||||
|
|
||||||
|
// 是否开启调试模式
|
||||||
|
export const DEBUG = import.meta.env.VITE_DEBUG === 'true'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取完整的 API 请求地址
|
||||||
|
* @param path 接口路径,例如 '/user/login'
|
||||||
|
* @returns 完整的请求地址
|
||||||
|
*/
|
||||||
|
export function getApiUrl(path: string): string {
|
||||||
|
// 确保 path 以 / 开头
|
||||||
|
const normalizedPath = path.startsWith('/') ? path : `/${path}`
|
||||||
|
return `${API_BASE_URL}${normalizedPath}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为开发环境
|
||||||
|
*/
|
||||||
|
export function isDev(): boolean {
|
||||||
|
return ENV === 'development'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为生产环境
|
||||||
|
*/
|
||||||
|
export function isProd(): boolean {
|
||||||
|
return ENV === 'production'
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
ENV,
|
||||||
|
API_BASE_URL,
|
||||||
|
WS_URL,
|
||||||
|
DEBUG,
|
||||||
|
getApiUrl,
|
||||||
|
isDev,
|
||||||
|
isProd
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user