-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refresh token on site created (#76)
close #51
- Loading branch information
Showing
2 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import request from '@/utils/request' | ||
import { message } from 'ant-design-vue' | ||
import store from '@/store' | ||
|
||
/** | ||
* LG0103 刷新 token | ||
* @returns {Promise<void>} | ||
*/ | ||
export async function refreshToken () { | ||
await request.put('/login', {}).then(res => { | ||
localStorage.setItem('token', res.token) | ||
store.dispatch('userLogin', res.id) | ||
}).catch(() => { | ||
message.error('登录已过期,请重新登录') | ||
store.commit('userLogout') | ||
}) | ||
} |