Skip to content

系统配置

开发环境配置

环境变量配置

项目提供了两种环境的配置文件:

  • 开发环境.env.development

  • 生产环境.env.production

主要配置项说明:

变量名描述开发环境值生产环境值
VITE_APP_BASE_URLAPI 请求基础地址http://127.0.0.1:8080/adminapi//adminapi/
VITE_IMG_DOMAIN图片服务器域名http://127.0.0.1:8080/空(使用相对路径)
VITE_REQUEST_HEADER_TOKEN_KEY请求头中Token的参数名tokentoken
VITE_REQUEST_HEADER_SITEID_KEY请求头中站点ID的参数名site-idsite-id

构建配置

项目使用 Vite 作为构建工具,主要配置位于 vite.config.ts 文件中:

typescript
import { fileURLToPath, URL } from "node:url"
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  base: '',
  server: {
    host: '0.0.0.0'
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      'assets': fileURLToPath(new URL('./src/assets', import.meta.url))
    }
  }
})

基于 MIT 协议发布