Browse Source

退出登录 清除浏览器缓存

yusheng 2 years ago
parent
commit
d7d94930d0
3 changed files with 31 additions and 31 deletions
  1. 1 1
      src/layout/components/setting-drawer.vue
  2. 28 30
      src/layout/index.vue
  3. 2 0
      src/utils/page-tab-util.js

+ 1 - 1
src/layout/components/setting-drawer.vue

@@ -339,7 +339,7 @@ export default {
   },
   created() {
     this.initColorValue();
-    this.getLogo()
+    // this.getLogo()
   },
   methods: {
 

+ 28 - 30
src/layout/index.vue

@@ -51,12 +51,10 @@
     <!-- 路由出口 -->
     <router-layout />
     <!-- logo 图标 -->
-    <template v-slot:logo  >
-       <el-image v-if="logoImg"   fit="contain" :src="logoImg" alt="logo" />
+    <template v-slot:logo>
+      <el-image v-if="logoImg" fit="contain" :src="logoImg" alt="logo" />
     </template>
 
-
-   
     <!-- 顶栏右侧区域 -->
     <template v-slot:right>
       <header-tools :fullscreen="fullscreen" @fullscreen="onFullscreen" />
@@ -93,9 +91,9 @@
   import RouterLayout from '@/components/RouterLayout/index.vue';
   import HeaderTools from './components/header-tools.vue';
   // import PageFooter from './components/page-footer.vue';
+  import { getToken } from '@/utils/token-util';
 
-  
-import {  logoByCode } from '@/api/login/index'
+  import { logoByCode } from '@/api/login/index';
   import {
     PROJECT_NAME,
     HIDE_SIDEBARS,
@@ -126,7 +124,7 @@ import {  logoByCode } from '@/api/login/index'
       HeaderTools
       // PageFooter
     },
-    data () {
+    data() {
       return {
         // PROJECT_NAME,
         HIDE_SIDEBARS,
@@ -139,60 +137,60 @@ import {  logoByCode } from '@/api/login/index'
         // 是否全屏
         fullscreen: false,
 
-        logoImg:  null,
-        projectName: null,
+        logoImg: null,
+        projectName: null
       };
     },
     computed: {
       // 当前语言
-      locale () {
+      locale() {
         return this.$i18n.locale;
       },
       // 菜单数据
-      menus () {
+      menus() {
         return this.$store.state.user.menus;
       },
       // 主题状态
       ...mapGetters(['theme'])
     },
     created() {
-      this.getLogo()
+      if(getToken()){
+        this.getLogo();
+
+      }
     },
     methods: {
-
       getLogo() {
-      logoByCode('logoCode').then(res => {
-        this.logoImg = res.logoUrl
-          this.projectName = res.logoName
-      
-
-      })
-    },
+        logoByCode('logoCode').then((res) => {
+          this.logoImg = res.logoUrl;
+          this.projectName = res.logoName;
+        });
+      },
 
       /* 侧栏折叠切换 */
-      updateCollapse (value) {
+      updateCollapse(value) {
         // console.log('value:', this.$store.state.user.menus);
         this.$store.dispatch('theme/setCollapse', value);
       },
       /* 双侧栏一级折叠切换 */
-      updateSideNavCollapse (value) {
+      updateSideNavCollapse(value) {
         this.$store.dispatch('theme/setSideNavCollapse', value);
       },
       /* 内容区域全屏切换 */
-      updateBodyFullscreen (value) {
+      updateBodyFullscreen(value) {
         this.$store.dispatch('theme/setBodyFullscreen', value);
       },
       /* logo 点击事件 */
-      onLogoClick (isHome) {
+      onLogoClick(isHome) {
         isHome || this.$router.push(LAYOUT_PATH);
       },
       /* 监听屏幕尺寸改变 */
-      screenSizeChange () {
+      screenSizeChange() {
         this.$store.dispatch('theme/updateScreenSize');
         this.fullscreen = isFullscreen();
       },
       /* 全屏切换 */
-      onFullscreen () {
+      onFullscreen() {
         try {
           this.fullscreen = toggleFullscreen();
         } catch (e) {
@@ -200,7 +198,7 @@ import {  logoByCode } from '@/api/login/index'
         }
       },
       /* 页签右键菜单点击事件 */
-      onTabContextMenu ({ key, tabKey, item, active }) {
+      onTabContextMenu({ key, tabKey, item, active }) {
         switch (key) {
           case 'reload': // 刷新
             reloadPageTab({
@@ -235,7 +233,7 @@ import {  logoByCode } from '@/api/login/index'
         }
       },
       /* 菜单标题国际化 */
-      i18n (_path, key) {
+      i18n(_path, key) {
         if (!I18N_ENABLE || !key) {
           return;
         }
@@ -359,10 +357,10 @@ import {  logoByCode } from '@/api/login/index'
     }
   }
 
-  .ele-admin-layout .ele-admin-logo img  {
+  .ele-admin-layout .ele-admin-logo img {
     height: auto !important;
     width: 80px !important;
     margin-right: 5px;
-    max-height: 35px
+    max-height: 35px;
   }
 </style>

+ 2 - 0
src/utils/page-tab-util.js

@@ -239,6 +239,8 @@ export function goHomeRoute(from) {
  */
 export function logout(route, from) {
   removeToken();
+  localStorage.clear();
+  sessionStorage.clear();
   if (route) {
     router.push({
       path: '/login',