From 31e5a3013d255bc15374b9f268582b45115b6efe Mon Sep 17 00:00:00 2001 From: iizmg Date: Thu, 30 Apr 2020 15:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/App.vue | 6 ++++-- admin/src/assets/js/glob.js | 11 +---------- 2 files changed, 5 insertions(+), 12 deletions(-) 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() {