fix router

This commit is contained in:
AceDataCloud
2021-09-04 16:31:44 +08:00
parent 8088538589
commit c6a962a089
8 changed files with 46 additions and 45 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
<title>知数云</title>
</head>
<body>
<div id="app" class="h-screen"></div>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+1
View File
@@ -9,6 +9,7 @@
"dependencies": {
"@element-plus/icons": "^0.0.11",
"axios": "^0.21.1",
"diff-match-patch": "^1.0.5",
"element-plus": "^1.1.0-beta.7",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
+34 -5
View File
@@ -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>
+1 -1
View File
@@ -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 -8
View File
@@ -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',
-20
View File
@@ -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
View File
@@ -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({
-7
View File
@@ -2247,13 +2247,6 @@ v8-compile-cache@^2.0.3:
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
vditor@^3.8.6:
version "3.8.6"
resolved "https://registry.yarnpkg.com/vditor/-/vditor-3.8.6.tgz#95a89c4865efa740bf55f2a7e3f968b395987a60"
integrity sha512-KZSmg593dTx/BmX9HdXcZCLi5stkJvW3AHVq4gOVvA00JnZngT7sjlX8WlfWbLe0A80UzelNSVXff3yoyljRAA==
dependencies:
diff-match-patch "^1.0.5"
vite@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.5.1.tgz#953c71a034c07b3ae0448d57664ec9c6862f23a8"