Commit 372de7a4d5c98f20bfbeadfe53c1421af233fab8

Authored by xingyu
1 parent 2a332a95

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

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