perf: 优化页面结构

This commit is contained in:
wangdan-fit2cloud 2024-07-10 11:27:52 +08:00
parent fd6aa4fb39
commit 0a6f6f0114
10 changed files with 67 additions and 14 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts"></script> <script setup lang="ts"></script>
<template> <template>
<RouterView /> <router-view />
</template> </template>
<style scoped></style> <style scoped></style>

View File

@ -2,7 +2,7 @@
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<transition appear name="fade-transform" mode="out-in"> <transition appear name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews"> <keep-alive :include="cachedViews">
<component :is="Component" :key="route.fullPath" /> <component :is="Component" :key="route.path" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
@ -17,8 +17,7 @@ const route = useRoute()
const cachedViews: any = ref([]) const cachedViews: any = ref([])
onBeforeUpdate(() => { onBeforeUpdate(() => {
const { name, meta } = route const { name, meta } = route
let isCached = meta?.cache if (name && !cachedViews.value.includes(name)) {
if (isCached && name && !cachedViews.value.includes(name)) {
cachedViews.value.push(name) cachedViews.value.push(name)
} }
}) })

View File

@ -12,7 +12,7 @@ import { TopBar, AppMain } from '../components'
</div> </div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss">
.app-layout { .app-layout {
background-color: var(--app-layout-bg-color); background-color: var(--app-layout-bg-color);
height: 100%; height: 100%;

View File

@ -10,7 +10,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Sidebar, AppMain } from '../components' import { TopBar, Sidebar, AppMain } from '../components'
</script> </script>
<style lang="scss"> <style lang="scss">
.sidebar-container { .sidebar-container {

View File

@ -0,0 +1,53 @@
<template>
<div class="app-layout">
<div class="app-header">
<TopBar />
</div>
<div class="app-main">
<div class="main-layout h-full flex">
<div class="sidebar-container">
<Sidebar />
</div>
<div class="view-container">
<AppMain />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { TopBar, Sidebar, AppMain } from '../components'
</script>
<style lang="scss">
.app-layout {
background-color: var(--app-layout-bg-color);
height: 100%;
}
.app-main {
position: relative;
height: 100%;
padding: var(--app-header-height) 0 0 !important;
box-sizing: border-box;
overflow: auto;
}
.app-header {
background: var(--app-header-bg-color);
position: fixed;
width: 100%;
left: 0;
top: 0;
z-index: 100;
}
.sidebar-container {
box-sizing: border-box;
transition: width 0.28s;
width: var(--sidebar-width);
min-width: var(--sidebar-width);
background-color: var(--sidebar-bg-color);
}
.view-container {
width: calc(100% - var(--sidebar-width));
}
</style>

View File

@ -1,9 +1,10 @@
import Layout from '@/layout/main-layout/index.vue' import Layout from '@/layout/layout-template/DetailLayout.vue'
const applicationRouter = { const applicationRouter = {
path: '/application', path: '/application',
name: 'application', name: 'application',
meta: { title: '应用', permission: 'APPLICATION:READ' }, meta: { title: '应用', permission: 'APPLICATION:READ' },
redirect: '/application', redirect: '/application',
component: () => import('@/layout/layout-template/AppLayout.vue'),
children: [ children: [
{ {
path: '/application', path: '/application',

View File

@ -1,8 +1,9 @@
import Layout from '@/layout/main-layout/index.vue' import Layout from '@/layout/layout-template/DetailLayout.vue'
const datasetRouter = { const datasetRouter = {
path: '/dataset', path: '/dataset',
name: 'dataset', name: 'dataset',
meta: { title: '知识库', permission: 'DATASET:READ' }, meta: { title: '知识库', permission: 'DATASET:READ' },
component: () => import('@/layout/layout-template/AppLayout.vue'),
redirect: '/dataset', redirect: '/dataset',
children: [ children: [
{ {

View File

@ -1,5 +1,5 @@
import { hasPermission } from '@/utils/permission/index' import { hasPermission } from '@/utils/permission/index'
import Layout from '@/layout/main-layout/index.vue' import Layout from '@/layout/layout-template/SystemLayout.vue'
import { Role } from '@/utils/permission/type' import { Role } from '@/utils/permission/type'
const settingRouter = { const settingRouter = {
path: '/setting', path: '/setting',

View File

@ -8,7 +8,6 @@ export const routes: Array<RouteRecordRaw> = [
{ {
path: '/', path: '/',
name: 'home', name: 'home',
component: () => import('@/layout/app-layout/index.vue'),
redirect: '/application', redirect: '/application',
children: [...rolesRoutes] children: [...rolesRoutes]
}, },

View File

@ -5,11 +5,11 @@
<template v-for="(item, index) in tabList" :key="index"> <template v-for="(item, index) in tabList" :key="index">
<el-tab-pane :label="item.label" :name="item.name"> <el-tab-pane :label="item.label" :name="item.name">
<div class="authentication-setting__main main-calc-height"> <div class="authentication-setting__main main-calc-height">
<div class="form-container"> <el-scrollbar>
<el-scrollbar> <div class="form-container">
<component :is="item.component" /> <component :is="item.component" />
</el-scrollbar> </div>
</div> </el-scrollbar>
</div> </div>
</el-tab-pane> </el-tab-pane>
</template> </template>