window
This commit is contained in:
@ -6,25 +6,29 @@ let TOKEN_KEY = 'kb-user-center-token'
|
|||||||
let domain = ''
|
let domain = ''
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
domain = window.location.hostname
|
domain = window.location.hostname
|
||||||
|
window.KbUcloginStatus = {
|
||||||
|
status: Cookies.get(TOKEN_KEY) !== null && Cookies.get(TOKEN_KEY) !== undefined,
|
||||||
|
user: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (domain.indexOf('kuboard.cn') >= 0) {
|
if (domain.indexOf('kuboard.cn') >= 0) {
|
||||||
domain = 'kuboard.cn'
|
domain = 'kuboard.cn'
|
||||||
}
|
}
|
||||||
|
|
||||||
window.KbUcloginStatus = {
|
|
||||||
status: Cookies.get(TOKEN_KEY) !== null && Cookies.get(TOKEN_KEY) !== undefined,
|
|
||||||
user: undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$login = function (token) {
|
Vue.prototype.$login = function (token) {
|
||||||
// axios.defaults.headers.common['Authorization'] = token;
|
// axios.defaults.headers.common['Authorization'] = token;
|
||||||
// localStorage.setItem(TOKEN_KEY, token)
|
// localStorage.setItem(TOKEN_KEY, token)
|
||||||
Cookies.set(TOKEN_KEY, token, { domain: domain, expires: 7, path: '/' })
|
Cookies.set(TOKEN_KEY, token, { domain: domain, expires: 7, path: '/' })
|
||||||
window.KbUcloginStatus.status = true
|
if (typeof window !== 'undefined') {
|
||||||
|
window.KbUcloginStatus.status = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$logout = function () {
|
Vue.prototype.$logout = function () {
|
||||||
window.KbUcloginStatus.status = false
|
if (typeof window !== 'undefined') {
|
||||||
|
window.KbUcloginStatus.status = false
|
||||||
|
}
|
||||||
// localStorage.removeItem(TOKEN_KEY)
|
// localStorage.removeItem(TOKEN_KEY)
|
||||||
Cookies.remove(TOKEN_KEY, { domain: domain, expires: 7, path: '/' })
|
Cookies.remove(TOKEN_KEY, { domain: domain, expires: 7, path: '/' })
|
||||||
// delete (axios.defaults.headers.common['Authorization'])
|
// delete (axios.defaults.headers.common['Authorization'])
|
||||||
|
|||||||
Reference in New Issue
Block a user