guhongwei 4 лет назад
Родитель
Сommit
1b433cc656
4 измененных файлов с 87 добавлено и 84 удалено
  1. 2 12
      src/App.vue
  2. 8 7
      src/layout/layout-part/heads.vue
  3. 23 13
      src/layout/main-layout.vue
  4. 54 52
      src/router/index.js

+ 2 - 12
src/App.vue

@@ -1,11 +1,6 @@
 <template>
   <div id="app">
-    <el-row v-if="toLogin()">
-      <router-view />
-    </el-row>
-    <el-row v-else>
-      <main-layout></main-layout>
-    </el-row>
+    <main-layout></main-layout>
   </div>
 </template>
 <script>
@@ -17,12 +12,7 @@ export default {
   },
   data: () => ({}),
   created() {},
-  methods: {
-    toLogin() {
-      let route = window.location.pathname;
-      return route.includes('login');
-    },
-  },
+  methods: {},
 };
 </script>
 

+ 8 - 7
src/layout/layout-part/heads.vue

@@ -15,7 +15,7 @@
               {{ user.name }}
             </span>
             <span v-else>
-              <el-link href="/login" :underline="false" target="_blank">登录</el-link>
+              <el-link href="/login" :underline="false">登录</el-link>
             </span>
           </span>
           <span @click="logoutBtn()"><i class="iconfont iconiconfront-"></i>退出登录</span>
@@ -65,6 +65,10 @@ export default {
     bindBtn() {
       this.bindDia = true;
     },
+    // 绑定微信关闭
+    bindDown() {
+      this.bindDia = false;
+    },
     // 修改密码
     passwdBtn() {
       this.passwdDia = true;
@@ -79,18 +83,15 @@ export default {
           message: '修改密码成功',
           type: 'success',
         });
-        this.logoutBtn();
+        this.$router.push({ path: '/login' });
       }
     },
     // 退出登录
     logoutBtn() {
       this.logout();
-      location.reload();
-    },
-    // 绑定微信关闭
-    bindDown() {
-      this.bindDia = false;
+      this.$router.push({ path: '/login' });
     },
+
     handleClose(done) {
       done();
     },

+ 23 - 13
src/layout/main-layout.vue

@@ -1,19 +1,24 @@
 <template>
   <div id="main-layout">
     <el-row>
-      <el-container class="index">
-        <el-header height="4rem" class="heads">
-          <heads></heads>
-        </el-header>
-        <el-container>
-          <el-aside width="13rem" class="menus">
-            <menus></menus>
-          </el-aside>
-          <el-main class="main">
-            <router-view />
-          </el-main>
+      <div v-if="!toLogin()">
+        <el-container class="index">
+          <el-header height="4rem" class="heads">
+            <heads></heads>
+          </el-header>
+          <el-container>
+            <el-aside width="13rem" class="menus">
+              <menus></menus>
+            </el-aside>
+            <el-main class="main">
+              <router-view />
+            </el-main>
+          </el-container>
         </el-container>
-      </el-container>
+      </div>
+      <div v-else>
+        <router-view />
+      </div>
     </el-row>
   </div>
 </template>
@@ -36,7 +41,12 @@ export default {
   computed: {
     ...mapState(['user']),
   },
-  methods: {},
+  methods: {
+    toLogin() {
+      let route = window.location.pathname;
+      return route.includes('login');
+    },
+  },
   mounted() {},
 };
 </script>

+ 54 - 52
src/router/index.js

@@ -4,64 +4,66 @@ import checkLogin from './before';
 
 Vue.use(VueRouter);
 
-const routes = [
+const index = [
   {
     path: '/',
     meta: { title: '首页' },
     component: () => import('../views/index.vue'),
-  },
-  {
-    path: '/anchor/index',
-    meta: { title: '主播管理' },
-    component: () => import('../views/anchor/index.vue'),
-  },
+    children: [
+      {
+        path: '/anchor/index',
+        meta: { title: '主播管理' },
+        component: () => import('../views/anchor/index.vue'),
+      },
 
-  {
-    path: '/anchor/detail',
-    meta: { title: '主播详情' },
-    component: () => import('../views/anchor/detail.vue'),
-  },
-  {
-    path: '/role/index',
-    meta: { title: '菜单管理' },
-    component: () => import('../views/role/index.vue'),
-  },
+      {
+        path: '/anchor/detail',
+        meta: { title: '主播详情' },
+        component: () => import('../views/anchor/detail.vue'),
+      },
+      {
+        path: '/role/index',
+        meta: { title: '菜单管理' },
+        component: () => import('../views/role/index.vue'),
+      },
 
-  {
-    path: '/role/detail',
-    meta: { title: '菜单详情' },
-    component: () => import('../views/role/detail.vue'),
-  },
-  {
-    path: '/live/index',
-    meta: { title: '直播管理' },
-    component: () => import('../views/live/index.vue'),
-  },
-  {
-    path: '/room/index',
-    meta: { title: '房间管理' },
-    component: () => import('../views/room/index.vue'),
-  },
+      {
+        path: '/role/detail',
+        meta: { title: '菜单详情' },
+        component: () => import('../views/role/detail.vue'),
+      },
+      {
+        path: '/live/index',
+        meta: { title: '直播管理' },
+        component: () => import('../views/live/index.vue'),
+      },
+      {
+        path: '/room/index',
+        meta: { title: '房间管理' },
+        component: () => import('../views/room/index.vue'),
+      },
 
-  {
-    path: '/room/detail',
-    meta: { title: '房间详情' },
-    component: () => import('../views/room/detail.vue'),
-  },
-  {
-    path: '/stat/index',
-    meta: { title: '统计管理' },
-    component: () => import('../views/stat/index.vue'),
-  },
-  {
-    path: '/test/index',
-    meta: { title: '测试管理' },
-    component: () => import('../views/test/index.vue'),
-  },
-  {
-    path: '/test/detail',
-    meta: { title: '添加' },
-    component: () => import('../views/test/detail.vue'),
+      {
+        path: '/room/detail',
+        meta: { title: '房间详情' },
+        component: () => import('../views/room/detail.vue'),
+      },
+      {
+        path: '/stat/index',
+        meta: { title: '统计管理' },
+        component: () => import('../views/stat/index.vue'),
+      },
+      {
+        path: '/test/index',
+        meta: { title: '测试管理' },
+        component: () => import('../views/test/index.vue'),
+      },
+      {
+        path: '/test/detail',
+        meta: { title: '添加' },
+        component: () => import('../views/test/detail.vue'),
+      },
+    ],
   },
   {
     path: '/login',
@@ -69,7 +71,7 @@ const routes = [
     component: () => import('../views/login.vue'),
   },
 ];
-
+const routes = [...index];
 const router = new VueRouter({
   mode: 'history',
   base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,