fix router
This commit is contained in:
1 parent
8088538589
commit
c6a962a089
8 files changed
+46
-45
No files matched your search
+34
-5
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<el-container class="h-screen">
|
||||
<el-container :class="showFullHeight ? 'h-screen' : ''">
|
||||
<el-header>
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-container>
|
||||
<el-aside width="250px">
|
||||
<el-aside width="250px" v-if="showSidebar">
|
||||
<sidebar />
|
||||
</el-aside>
|
||||
<el-main>
|
||||
@@ -17,13 +17,42 @@
|
||||
<script lang="ts">
|
||||
import Sidebar from '@/components/content/Sidebar.vue';
|
||||
import { TopHeader } from '@/components/common/index';
|
||||
export default {
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
routes: {
|
||||
detail: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
TopHeader,
|
||||
Sidebar
|
||||
},
|
||||
name: 'LayoutContent'
|
||||
};
|
||||
data(): IData {
|
||||
return {
|
||||
routes: {
|
||||
detail: ['article-detail']
|
||||
}
|
||||
};
|
||||
},
|
||||
name: 'LayoutContent',
|
||||
computed: {
|
||||
showSidebar(): boolean {
|
||||
console.log('router', this.$route.name);
|
||||
return !this.isDetailRoute();
|
||||
},
|
||||
showFullHeight(): boolean {
|
||||
return !this.isDetailRoute();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isDetailRoute(): boolean {
|
||||
return this.routes.detail.includes(this.$route.name?.toString() || '');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -55,7 +55,7 @@ export default defineComponent({
|
||||
methods: {
|
||||
onEdit(row: IArticle) {
|
||||
this.$router.push({
|
||||
name: 'article-edit',
|
||||
name: 'article-detail',
|
||||
params: {
|
||||
id: row.id
|
||||
}
|
||||
|
||||
@@ -8,14 +8,6 @@ export default {
|
||||
},
|
||||
component: () => import('@/layouts/Content.vue'),
|
||||
children: [
|
||||
{
|
||||
path: 'editor',
|
||||
name: 'editor',
|
||||
meta: {
|
||||
title: t('common.nav.editor')
|
||||
},
|
||||
component: () => import('@/pages/content/Editor.vue')
|
||||
},
|
||||
{
|
||||
path: 'article',
|
||||
name: 'article-index',
|
||||
@@ -24,6 +16,14 @@ export default {
|
||||
},
|
||||
component: () => import('@/pages/content/article/Index.vue')
|
||||
},
|
||||
{
|
||||
path: 'article/:id',
|
||||
name: 'article-detail',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/editor/article/Detail.vue')
|
||||
},
|
||||
{
|
||||
path: 'platform',
|
||||
name: 'platform-index',
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { t } from '../i18n';
|
||||
|
||||
export default {
|
||||
path: '/editor',
|
||||
name: 'editor',
|
||||
meta: {
|
||||
title: t('common.nav.editor')
|
||||
},
|
||||
component: () => import('@/layouts/Editor.vue'),
|
||||
children: [
|
||||
{
|
||||
path: 'article/:id',
|
||||
name: 'article-edit',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/editor/article/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+1
-3
@@ -1,6 +1,5 @@
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||
import content from './content';
|
||||
import editor from './editor';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -8,8 +7,7 @@ const routes = [
|
||||
name: 'home',
|
||||
component: () => import('@/pages/Home.vue')
|
||||
},
|
||||
content,
|
||||
editor
|
||||
content
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
|
||||
Reference in new issue
Block a user