diff --git a/admin/src/App.vue b/admin/src/App.vue index 79cf9bc..a016c63 100644 --- a/admin/src/App.vue +++ b/admin/src/App.vue @@ -123,6 +123,10 @@ //初始化 this.init(); }, + mounted() { + //检查登陆 + glob.checkLogin(); + }, methods: { //初始化 init() { @@ -137,8 +141,6 @@ window.addEventListener('resize', this.resizeListener); //主动调用一次resize监听 this.resizeListener(); - //检查登陆 - glob.checkLogin(); }, //重设主题属性 resetTheme() { diff --git a/admin/src/assets/js/glob.js b/admin/src/assets/js/glob.js index 483a0fb..c5b87fc 100644 --- a/admin/src/assets/js/glob.js +++ b/admin/src/assets/js/glob.js @@ -9,21 +9,12 @@ const glob = { //初始化Axios this.intiAxios(); }, - //读取cookies - getCookie(name) { - var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); - if (arr === document.cookie.match(reg)) { - return unescape(arr[2]); - } else { - return null; - } - }, //返回token getToken() { //token名称 const TOKEN_NAME = 'token'; //返回TOKEN - return this.getCookie(this.TOKEN_NAME); + return $cookies.get(this.TOKEN_NAME); }, //检查是否登陆 checkLogin() {