Commit 372de7a4d5c98f20bfbeadfe53c1421af233fab8

Authored by xingyu
1 parent 2a332a95

perf: 优化第一次进入加载速度

yudao-ui-admin-vue3/.env.base
1 1 # 本地开发环境
2 2 NODE_ENV=development
3 3  
  4 +VITE_DEV=true
  5 +
4 6 # 请求路径
5 7 VITE_BASE_URL='http://localhost:48080'
6 8  
... ...
yudao-ui-admin-vue3/.env.dev
1 1 # 开发环境
2 2 NODE_ENV=production
3 3  
  4 +VITE_DEV=false
  5 +
4 6 # 请求路径
5 7 VITE_BASE_URL='http://localhost:48080'
6 8  
... ...
yudao-ui-admin-vue3/.env.pro
1 1 # 生产环境
2 2 NODE_ENV=production
3 3  
  4 +VITE_DEV=false
  5 +
4 6 # 请求路径
5 7 VITE_BASE_URL='http://localhost:48080'
6 8  
... ...
yudao-ui-admin-vue3/.env.test
1 1 # 测试环境
2 2 NODE_ENV=production
3 3  
  4 +VITE_DEV=false
  5 +
4 6 # 请求路径
5 7 VITE_BASE_URL='http://localhost:48080'
6 8  
... ...
yudao-ui-admin-vue3/src/main.ts
... ... @@ -37,6 +37,13 @@ import App from './App.vue'
37 37  
38 38 import './permission'
39 39  
  40 +import { isDevMode } from '@/utils/env'
  41 +
  42 +if (isDevMode()) {
  43 + console.info(isDevMode())
  44 + import('element-plus/dist/index.css')
  45 +}
  46 +
40 47 // 创建实例
41 48 const setupAll = async () => {
42 49 const app = createApp(App)
... ...
yudao-ui-admin-vue3/src/types/auto-components.d.ts
... ... @@ -21,6 +21,7 @@ declare module '@vue/runtime-core' {
21 21 DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
22 22 Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
23 23 Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
  24 + ElAvatar: typeof import('element-plus/es')['ElAvatar']
24 25 ElBadge: typeof import('element-plus/es')['ElBadge']
25 26 ElButton: typeof import('element-plus/es')['ElButton']
26 27 ElCard: typeof import('element-plus/es')['ElCard']
... ... @@ -30,6 +31,7 @@ declare module '@vue/runtime-core' {
30 31 ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
31 32 ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
32 33 ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
  34 + ElDialog: typeof import('element-plus/es')['ElDialog']
33 35 ElDivider: typeof import('element-plus/es')['ElDivider']
34 36 ElDrawer: typeof import('element-plus/es')['ElDrawer']
35 37 ElDropdown: typeof import('element-plus/es')['ElDropdown']
... ... @@ -38,6 +40,7 @@ declare module '@vue/runtime-core' {
38 40 ElForm: typeof import('element-plus/es')['ElForm']
39 41 ElFormItem: typeof import('element-plus/es')['ElFormItem']
40 42 ElIcon: typeof import('element-plus/es')['ElIcon']
  43 + ElImage: typeof import('element-plus/es')['ElImage']
41 44 ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
42 45 ElInput: typeof import('element-plus/es')['ElInput']
43 46 ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
... ... @@ -51,7 +54,10 @@ declare module '@vue/runtime-core' {
51 54 ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
52 55 ElSelect: typeof import('element-plus/es')['ElSelect']
53 56 ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
  57 + ElSpace: typeof import('element-plus/es')['ElSpace']
54 58 ElSwitch: typeof import('element-plus/es')['ElSwitch']
  59 + ElTable: typeof import('element-plus/es')['ElTable']
  60 + ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
55 61 ElTabPane: typeof import('element-plus/es')['ElTabPane']
56 62 ElTabs: typeof import('element-plus/es')['ElTabs']
57 63 ElTag: typeof import('element-plus/es')['ElTag']
... ...
yudao-ui-admin-vue3/src/utils/env.ts 0 → 100644
  1 +export const isDevMode = () => {
  2 + const dev = import.meta.env.VITE_DEV
  3 + if (dev && dev === true) {
  4 + return true
  5 + } else {
  6 + return false
  7 + }
  8 +}
... ...
yudao-ui-admin-vue3/src/views/infra/swagger/index.vue
... ... @@ -5,5 +5,6 @@
5 5 </template>
6 6 <script setup lang="ts" name="Swagger">
7 7 const BASE_URL = import.meta.env.VITE_BASE_URL
8   -const src = ref(BASE_URL + '/doc.html')
  8 +// const src = ref(BASE_URL + '/doc.html')
  9 +const src = ref(BASE_URL + '/swagger-ui')
9 10 </script>
... ...
yudao-ui-admin-vue3/types/env.d.ts
... ... @@ -11,6 +11,7 @@ interface ImportMetaEnv {
11 11 readonly VITE_APP_TITLE: string
12 12 readonly VITE_PORT: number
13 13 readonly VITE_OPEN: string
  14 + readonly VITE_DEV: boolean
14 15 readonly VITE_ROUTE_ALWAYSSHOW_ENABLE: string
15 16 readonly VITE_APP_CAPTCHA_ENABLE: string
16 17 readonly VITE_APP_TENANT_ENABLE: string
... ...