Commit 8791ea214c787b41e0ddc49318e0da1c1d9b4720

Authored by 芋道源码
Committed by Gitee
2 parents 2a332a95 d207b95b

!381 vue3 优化第一次进入加载速度

Merge pull request !381 from xingyu/dev
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/components/XTable/src/XTable.vue
@@ -255,16 +255,17 @@ const getToolBarConfig = (options: XTableProps) => { @@ -255,16 +255,17 @@ const getToolBarConfig = (options: XTableProps) => {
255 if (toolbarConfig) return 255 if (toolbarConfig) return
256 if (toolBar) { 256 if (toolBar) {
257 if (!isBoolean(toolBar)) { 257 if (!isBoolean(toolBar)) {
  258 + console.info(2)
258 options.toolbarConfig = toolBar 259 options.toolbarConfig = toolBar
259 return 260 return
260 } 261 }
261 - } else if (!topActionSlots) { 262 + } else if (topActionSlots != false) {
262 options.toolbarConfig = { 263 options.toolbarConfig = {
263 - enabled: true 264 + slots: { buttons: 'toolbar_buttons' }
264 } 265 }
265 } else { 266 } else {
266 options.toolbarConfig = { 267 options.toolbarConfig = {
267 - slots: { buttons: 'toolbar_buttons' } 268 + enabled: true
268 } 269 }
269 } 270 }
270 } 271 }
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']
@@ -48,10 +51,14 @@ declare module '@vue/runtime-core' { @@ -48,10 +51,14 @@ declare module '@vue/runtime-core' {
48 ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] 51 ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
49 ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] 52 ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
50 ElRow: typeof import('element-plus/es')['ElRow'] 53 ElRow: typeof import('element-plus/es')['ElRow']
  54 + ElScroll: typeof import('element-plus/es')['ElScroll']
51 ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] 55 ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
52 ElSelect: typeof import('element-plus/es')['ElSelect'] 56 ElSelect: typeof import('element-plus/es')['ElSelect']
53 ElSkeleton: typeof import('element-plus/es')['ElSkeleton'] 57 ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
  58 + ElSpace: typeof import('element-plus/es')['ElSpace']
54 ElSwitch: typeof import('element-plus/es')['ElSwitch'] 59 ElSwitch: typeof import('element-plus/es')['ElSwitch']
  60 + ElTable: typeof import('element-plus/es')['ElTable']
  61 + ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
55 ElTabPane: typeof import('element-plus/es')['ElTabPane'] 62 ElTabPane: typeof import('element-plus/es')['ElTabPane']
56 ElTabs: typeof import('element-plus/es')['ElTabs'] 63 ElTabs: typeof import('element-plus/es')['ElTabs']
57 ElTag: typeof import('element-plus/es')['ElTag'] 64 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/src/views/system/user/index.vue
@@ -8,17 +8,19 @@ @@ -8,17 +8,19 @@
8 </div> 8 </div>
9 </template> 9 </template>
10 <el-input v-model="filterText" placeholder="搜索部门" /> 10 <el-input v-model="filterText" placeholder="搜索部门" />
11 - <el-tree  
12 - ref="treeRef"  
13 - node-key="id"  
14 - default-expand-all  
15 - :data="deptOptions"  
16 - :props="defaultProps"  
17 - :highlight-current="true"  
18 - :filter-node-method="filterNode"  
19 - :expand-on-click-node="false"  
20 - @node-click="handleDeptNodeClick"  
21 - /> 11 + <el-scrollbar height="650">
  12 + <el-tree
  13 + ref="treeRef"
  14 + node-key="id"
  15 + default-expand-all
  16 + :data="deptOptions"
  17 + :props="defaultProps"
  18 + :highlight-current="true"
  19 + :filter-node-method="filterNode"
  20 + :expand-on-click-node="false"
  21 + @node-click="handleDeptNodeClick"
  22 + />
  23 + </el-scrollbar>
22 </el-card> 24 </el-card>
23 <el-card class="w-4/5 user" style="margin-left: 10px" :gutter="12" shadow="hover"> 25 <el-card class="w-4/5 user" style="margin-left: 10px" :gutter="12" shadow="hover">
24 <template #header> 26 <template #header>
@@ -534,8 +536,8 @@ onMounted(async () =&gt; { @@ -534,8 +536,8 @@ onMounted(async () =&gt; {
534 536
535 <style scoped> 537 <style scoped>
536 .user { 538 .user {
537 - height: 900px;  
538 - max-height: 960px; 539 + height: 780px;
  540 + max-height: 800px;
539 } 541 }
540 .card-header { 542 .card-header {
541 display: flex; 543 display: flex;
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