修改token保存方式
This commit is contained in:
+3
-3
@@ -75,14 +75,14 @@ export default class Home extends Vue{
|
||||
this.openMenuNames.push(result[1])
|
||||
}
|
||||
}
|
||||
if(!localStorage.getItem('login_token')) {
|
||||
if(!this.$store.state.loginInfo.token) {
|
||||
this.$router.push('/login')
|
||||
return
|
||||
}
|
||||
const data = await this.$http.post<{token: null | string}, any>('/api/common/verifyToken', {token: localStorage.getItem('login_token')})
|
||||
const data = await this.$http.post<{token: string}, any>('/api/common/verifyToken', {token: this.$store.state.loginInfo.token})
|
||||
if(data.status) {
|
||||
// 如果是已过期的token 服务端会签发新的token
|
||||
this.$store.commit('login', {token: data.newToken || localStorage.getItem('login_token'), userInfo: data.userInfo})
|
||||
this.$store.commit('login', {token: data.newToken || this.$store.state.loginInfo.token, userInfo: data.userInfo})
|
||||
} else {
|
||||
this.$router.push('/login')
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ export default class SystemConfig extends Vue {
|
||||
* @param dateStr 日期时间
|
||||
*/
|
||||
datetimeFormat(dateStr: string) {
|
||||
return moment(dateStr).format('YYYY-MM-DD HH:mm:ss')
|
||||
return dateStr ? moment(dateStr).format('YYYY-MM-DD HH:mm:ss') : null
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user