Skip to content

Commit 4f3e458

Browse files
rysinalsendya
authored andcommitted
修复storejs的token存储过期时间不生效bug
1 parent 1f9e69c commit 4f3e458

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/store/modules/user.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import storage from 'store'
2+
import expirePlugin from 'store/plugins/expire'
23
import { login, getInfo, logout } from '@/api/login'
34
import { ACCESS_TOKEN } from '@/store/mutation-types'
45
import { welcome } from '@/utils/util'
56

7+
storage.addPlugin(expirePlugin)
68
const user = {
79
state: {
810
token: '',
@@ -38,7 +40,7 @@ const user = {
3840
return new Promise((resolve, reject) => {
3941
login(userInfo).then(response => {
4042
const result = response.result
41-
storage.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
43+
storage.set(ACCESS_TOKEN, result.token, new Date().getTime() + 7 * 24 * 60 * 60 * 1000)
4244
commit('SET_TOKEN', result.token)
4345
resolve()
4446
}).catch(error => {

0 commit comments

Comments
 (0)