-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathindex.vue
More file actions
74 lines (65 loc) · 1.92 KB
/
index.vue
File metadata and controls
74 lines (65 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<div>
<template v-if="setting.layout.value === 'side'">
<t-layout key="side" :class="mainLayoutCls">
<t-aside><layout-side-nav /></t-aside>
<t-layout>
<t-header><layout-header /></t-header>
<t-content><layout-content /></t-content>
</t-layout>
</t-layout>
</template>
<template v-else>
<t-layout key="no-side">
<t-header><layout-header /> </t-header>
<t-layout :class="mainLayoutCls">
<layout-side-nav />
<layout-content />
</t-layout>
</t-layout>
</template>
<setting-com />
</div>
</template>
<script setup lang="ts">
import '@/style/layout.less';
import { storeToRefs } from 'pinia';
import { computed, onMounted, watch } from 'vue';
import { useRoute } from 'vue-router';
import { prefix } from '@/config/global';
import { useSettingStore, useTabsRouterStore } from '@/store';
import LayoutContent from './components/LayoutContent.vue';
import LayoutHeader from './components/LayoutHeader.vue';
import LayoutSideNav from './components/LayoutSideNav.vue';
import SettingCom from './setting.vue';
const route = useRoute();
const settingStore = useSettingStore();
const tabsRouterStore = useTabsRouterStore();
const setting = storeToRefs(settingStore);
const mainLayoutCls = computed(() => [
{
't-layout--with-sider': settingStore.showSidebar,
},
]);
const appendNewRoute = () => {
const {
path,
query,
meta: { title },
name,
} = route;
const titleObj = typeof title === 'string' ? { zh_CN: title, en_US: title } : title;
tabsRouterStore.appendTabRouterList({ path, query, title: titleObj, name, isAlive: true, meta: route.meta });
};
onMounted(() => {
appendNewRoute();
});
watch(
() => route.path,
() => {
appendNewRoute();
document.querySelector(`.${prefix}-layout`).scrollTo({ top: 0, behavior: 'smooth' });
},
);
</script>
<style lang="less" scoped></style>