zhongrj
2022-12-26 de69b4e78bfbd4023cb787ebeec5fbbaccc64733
登出去除token 信息
3 files modified
34 ■■■■■ changed files
src/api/login/login.js 12 ●●●●● patch | view | raw | blame | history
src/store/modules/user.js 15 ●●●●● patch | view | raw | blame | history
src/views/lyout/index.vue 7 ●●●● patch | view | raw | blame | history
src/api/login/login.js
@@ -37,3 +37,15 @@
    },
  });
};
/**
 * 登出
 */
export const logout = () =>{
  return request({
    url: '/api/blade-auth/oauth/logout',
    method: 'get',
    params: {}
  })
}
src/store/modules/user.js
@@ -1,4 +1,4 @@
import { loginByUsername } from "@/api/login/login";
import { loginByUsername,logout } from "@/api/login/login";
import {Message} from 'element-ui'
import md5 from "js-md5";
import * as auth from '@/utils/auth'
@@ -41,6 +41,19 @@
          });
      });
    },
    //登出
    LogOut({commit}) {
      return new Promise((resolve, reject) => {
        logout().then(() => {
          commit('SET_TOKEN', '');
          auth.removeToken();
          auth.removeUserInfo();
          resolve();
        }).catch(error => {
          reject(error)
        })
      })
    },
  },
  mutations:{
    SET_TOKEN: (state, token) => {
src/views/lyout/index.vue
@@ -186,8 +186,9 @@
    methods: {
        //登出
        goTOLogout(){
            //跳转登录页
            this.$store.dispatch("LogOut").then(() => {
            this.$router.push({ path: "/login" });
            });
        },
        /**
         * @description: 路由跳转的事件
@@ -444,6 +445,7 @@
            .userIcon.on {
                color: rgba(252, 189, 86, 1);
            }
            .userDetail {
                width: 180px;
                height: 92px;
@@ -466,6 +468,7 @@
                    border-left-color: transparent;
                    border-right-color: transparent;
                }
                .userName {
                    width: 100%;
                    height: 40px;
@@ -477,6 +480,7 @@
                    position: absolute;
                    top: 0px;
                }
                .userBtn {
                    width: 100%;
                    height: 50px;
@@ -493,6 +497,7 @@
                        border-radius: 4px;
                        cursor: pointer;
                        line-height: 44px;
                        img {
                            width: 76px;
                            height: 20px;