refactor(env): 重构环境变量配置并简化项目设置

-移除了大部分冗余环境变量,简化了配置结构
- 更新了 API 地址配置方式,使用 VITE_API_URL 替代原有变量
- 删除了未使用的代码文件,包括 apiCodes.ts、axiosHandler.ts 和 types.d.ts
- 调整了 vite 配置,使用环境变量中的 API地址
- 更新了 gitignore 文件,添加了 dist 目录的忽略项
This commit is contained in:
rd
2025-09-19 11:44:09 +08:00
parent e2771d29cb
commit 529b9f28d9
13 changed files with 25 additions and 178 deletions

View File

@ -9,12 +9,11 @@ import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import analyzer from 'rollup-plugin-visualizer';
import { pluginsConfig, setServerConfig, resolve } from './config';
import { pluginsConfig, resolve } from './config';
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const envDir = resolve('env');
const env = loadEnv(mode, envDir, '');
const setServer = setServerConfig({ env });
return {
define: {
@ -43,11 +42,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
'/api': {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
target: 'https://lingjiapi.lvfunai.com/api',
target: env.VITE_API_URL,
},
},
},
preview: setServer(),
};
});
@ -57,7 +55,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
* @returns
*/
function setAnalyzer(env = 'development') {
console.log('env: ', env);
// console.log('env: ', env);
if (env === 'development') {
return analyzer({
filename: 'analyzer.html',