diff --git a/.vuepress/login-manager.js b/.vuepress/login-manager.js index 544abad..c5a4497 100644 --- a/.vuepress/login-manager.js +++ b/.vuepress/login-manager.js @@ -3,6 +3,11 @@ import Cookies from 'js-cookie' let TOKEN_KEY = 'kb-user-center-token' +let domain = location.hostname +if (domain.indexOf('kuboard.cn') >= 0) { + domain = 'kuboard.cn' +} + window.KbUcloginStatus = { status: Cookies.get(TOKEN_KEY) !== null && Cookies.get(TOKEN_KEY) !== undefined, user: undefined @@ -11,13 +16,13 @@ window.KbUcloginStatus = { Vue.prototype.$login = function (token) { // axios.defaults.headers.common['Authorization'] = token; // localStorage.setItem(TOKEN_KEY, token) - Cookies.set(TOKEN_KEY, token, { path: '/' }) + Cookies.set(TOKEN_KEY, token, { domain: domain, expires: 7, path: '/' }) window.KbUcloginStatus.status = true } Vue.prototype.$logout = function () { window.KbUcloginStatus.status = false // localStorage.removeItem(TOKEN_KEY) - Cookies.remove(TOKEN_KEY, { path: '/' }) + Cookies.remove(TOKEN_KEY, { domain: domain, expires: 7, path: '/' }) // delete (axios.defaults.headers.common['Authorization']) }