Skip to content

Commit 7586700

Browse files
perf: System ui
1 parent 0a70b4c commit 7586700

File tree

5 files changed

+100
-21
lines changed

5 files changed

+100
-21
lines changed

frontend/src/components/layout/LayoutDsl.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
import { ref } from 'vue'
2+
import { ref, computed } from 'vue'
33
import Menu from './Menu.vue'
44
import Workspace from './Workspace.vue'
55
import Person from './Person.vue'
@@ -8,27 +8,30 @@ import LOGO_fold from '@/assets/LOGO-fold.svg'
88
import icon_moments_categories_outlined from '@/assets/svg/icon_moments-categories_outlined.svg'
99
import icon_side_fold_outlined from '@/assets/svg/icon_side-fold_outlined.svg'
1010
import icon_side_expand_outlined from '@/assets/svg/icon_side-expand_outlined.svg'
11-
import { useRouter } from 'vue-router'
11+
import { useRoute, useRouter } from 'vue-router'
1212
const router = useRouter()
1313
const collapse = ref(false)
14-
1514
const handleFoldExpand = () => {
1615
collapse.value = !collapse.value
1716
}
1817
const toWorkspace = () => {
1918
router.push('/')
2019
}
20+
const route = useRoute()
21+
const showSysmenu = computed(() => {
22+
return route.path.includes('/system')
23+
})
2124
</script>
2225

2326
<template>
2427
<div class="system-layout">
2528
<div class="left-side" :class="collapse && 'left-side-collapse'">
2629
<LOGO_fold v-if="collapse" style="margin: 0 0 6px 5px"></LOGO_fold>
2730
<LOGO v-else style="margin-bottom: 6px"></LOGO>
28-
<Workspace :collapse="collapse"></Workspace>
31+
<Workspace v-if="!showSysmenu" :collapse="collapse"></Workspace>
2932
<Menu :collapse="collapse"></Menu>
3033
<div class="bottom">
31-
<div class="back-to_workspace" @click="toWorkspace">
34+
<div v-if="showSysmenu" class="back-to_workspace" @click="toWorkspace">
3235
<el-icon size="16">
3336
<icon_moments_categories_outlined></icon_moments_categories_outlined>
3437
</el-icon>

frontend/src/components/layout/Menu.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
11
<script lang="ts" setup>
22
import { computed } from 'vue'
33
import { ElMenu } from 'element-plus-secondary'
4-
import { useRoute } from 'vue-router'
4+
import { useRoute, useRouter } from 'vue-router'
55
import MenuItem from './MenuItem.vue'
66
7+
const router = useRouter()
78
defineProps({
89
collapse: Boolean,
910
})
1011
1112
const route = useRoute()
12-
const menuList = computed(() => route.matched[0]?.children || [])
13-
14-
const activeIndex = computed(() => {
13+
// const menuList = computed(() => route.matched[0]?.children || [])
14+
const activeMenu = computed(() => route.path)
15+
/* const activeIndex = computed(() => {
1516
const arr = route.path.split('/')
1617
return arr[arr.length - 1]
18+
}) */
19+
20+
const showSysmenu = computed(() => {
21+
return route.path.includes('/system')
22+
})
23+
24+
const routerList = computed(() => {
25+
if (showSysmenu.value) {
26+
return router.getRoutes().filter((route) => route.path.includes('/system') && !route.redirect)
27+
}
28+
return router.getRoutes().filter((route) => {
29+
return (
30+
!route.path.includes('canvas') &&
31+
!route.path.includes('preview') &&
32+
route.path !== '/login' &&
33+
!route.path.includes('/system') &&
34+
!route.redirect &&
35+
route.path !== '/:pathMatch(.*)*' &&
36+
!route.path.includes('dsTable')
37+
)
38+
})
1739
})
1840
</script>
1941

2042
<template>
21-
<el-menu :default-active="activeIndex" class="ed-menu-vertical" :collapse="collapse">
22-
<MenuItem v-for="menu in menuList" :key="menu.path" :menu="menu"></MenuItem>
43+
<el-menu :default-active="activeMenu" class="el-menu-demo ed-menu-vertical" :collapse="collapse">
44+
<MenuItem v-for="menu in routerList" :key="menu.path" :menu="menu"></MenuItem>
2345
</el-menu>
2446
</template>
2547

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<script lang="ts">
2-
import { h } from 'vue'
2+
import { h, defineComponent } from 'vue'
33
import { ElMenuItem, ElSubMenu, ElIcon } from 'element-plus-secondary'
44
55
import model from '@/assets/svg/icon_dataset_filled.svg'
66
import ds from '@/assets/svg/ds.svg'
7-
7+
import dashboard from '@/assets/svg/dashboard.svg'
8+
import chat from '@/assets/svg/chat.svg'
9+
import icon_user from '@/assets/svg/icon_user.svg'
10+
import { useRouter } from 'vue-router'
811
const iconMap = {
912
icon_ai: model,
1013
ds,
14+
dashboard,
15+
chat,
16+
icon_user: icon_user,
1117
} as { [key: string]: any }
1218
1319
const titleWithIcon = (props: any) => {
@@ -17,16 +23,64 @@ const titleWithIcon = (props: any) => {
1723
h('span', null, { default: () => title }),
1824
]
1925
}
26+
const MenuItem = defineComponent({
27+
name: 'MenuItem',
28+
props: {
29+
menu: {
30+
type: Object,
31+
required: true,
32+
},
33+
},
34+
setup(props) {
35+
const router = useRouter()
36+
37+
const handleMenuClick = (e: any) => {
38+
router.push(e.index)
39+
}
40+
41+
return () => {
42+
const { children, hidden, path } = props.menu
43+
if (hidden) {
44+
return null
45+
}
2046
21-
const MenuItem = (props: any) => {
47+
if (children?.length) {
48+
return h(
49+
ElSubMenu,
50+
{ index: path, onClick: (e: any) => handleMenuClick(e) },
51+
{
52+
title: () => titleWithIcon(props),
53+
default: () => children.map((ele: any) => h(MenuItem, { menu: ele })),
54+
}
55+
)
56+
}
57+
58+
const { title, icon } = props.menu?.meta || {}
59+
const iconCom: any = iconMap[icon] ? ElIcon : null
60+
return h(
61+
ElMenuItem,
62+
{ index: path, onClick: (e: any) => handleMenuClick(e) },
63+
{
64+
default: () => [
65+
h(iconCom, null, {
66+
default: () => h(iconMap[icon]),
67+
}),
68+
h('span', null, { default: () => title }),
69+
],
70+
}
71+
)
72+
}
73+
},
74+
})
75+
/* const MenuItem = (props: any) => {
2276
const { children, hidden, path } = props.menu
2377
if (hidden) {
2478
return null
2579
}
2680
if (children?.length) {
2781
return h(
2882
ElSubMenu,
29-
{ index: path },
83+
{ index: path, onClick: (e: any) => handleMenuClick(e) },
3084
{
3185
title: () => titleWithIcon(props),
3286
default: () => children.map((ele: any) => h(MenuItem, { menu: ele })),
@@ -37,14 +91,14 @@ const MenuItem = (props: any) => {
3791
const iconCom: any = iconMap[icon] ? ElIcon : null
3892
return h(
3993
ElMenuItem,
40-
{ index: path },
94+
{ index: path, onClick: (e: any) => handleMenuClick(e) },
4195
{
4296
title: h('span', null, { default: () => title }),
4397
default: h(iconCom, null, {
4498
default: () => h(iconMap[icon]),
4599
}),
46100
}
47101
)
48-
}
102+
} */
49103
export default MenuItem
50104
</script>

frontend/src/components/layout/Person.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const languageList = [
4141
value: 'zh-CN',
4242
}, */,
4343
]
44-
const handlePersonChange = () => {
45-
emit('selectPerson')
44+
const toSystem = () => {
45+
router.push('/system')
4646
}
4747
4848
const changeLanguage = (lang: string) => {
@@ -88,7 +88,7 @@ const logout = () => {
8888
<div class="top">{{ name }}</div>
8989
<div class="bottom">{{ account }}</div>
9090
</div>
91-
<div v-if="isAdmin" class="popover-item" @click="handlePersonChange">
91+
<div v-if="isAdmin" class="popover-item" @click="toSystem">
9292
<el-icon size="16">
9393
<icon_admin_outlined></icon_admin_outlined>
9494
</el-icon>

frontend/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const router = createRouter({
2222
},
2323
{
2424
path: '/chat',
25-
component: Layout,
25+
component: LayoutDsl,
2626
redirect: '/chat/index',
2727
children: [
2828
{

0 commit comments

Comments
 (0)