File tree Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 4
4
get ,
5
5
put ,
6
6
} from '@/lin/plugins/axios'
7
- import { saveTokens , saveAccessToken } from '../utils/cookie '
7
+ import { saveTokens , saveAccessToken } from '../utils/token '
8
8
9
9
const SUPER_VALUE = 2
10
10
const ACTIVE_VALUE = 1
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Vue from 'vue'
3
3
import axios from 'axios'
4
4
import Config from '@/config'
5
5
import store from '@/store'
6
- import { getToken } from '@/lin/utils/cookie '
6
+ import { getToken } from '@/lin/utils/token '
7
7
import User from '@/lin/models/user'
8
8
9
9
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 存储tokens
3
+ * @param {string } accessToken
4
+ * @param {string } refreshToken
5
+ */
6
+ export function saveTokens ( accessToken , refreshToken ) {
7
+ localStorage . setItem ( 'access_token' , `Bearer ${ accessToken } ` )
8
+ localStorage . setItem ( 'refresh_token' , `Bearer ${ refreshToken } ` )
9
+ }
10
+
11
+ /**
12
+ * 存储access_token
13
+ * @param {string } accessToken
14
+ */
15
+ export function saveAccessToken ( accessToken ) {
16
+ localStorage . setItem ( 'access_token' , `Bearer ${ accessToken } ` )
17
+ }
18
+
19
+ /**
20
+ * 获得某个token
21
+ * @param {string } tokenKey
22
+ */
23
+ export function getToken ( tokenKey ) {
24
+ return localStorage . getItem ( tokenKey )
25
+ }
26
+
27
+ /**
28
+ * 移除token
29
+ */
30
+ export function removeToken ( ) {
31
+ localStorage . removeItem ( 'access_token' )
32
+ localStorage . removeItem ( 'refresh_token' )
33
+ }
Original file line number Diff line number Diff line change 1
1
import * as types from './mutation-types'
2
- import { removeToken } from '@/lin/utils/cookie '
2
+ import { removeToken } from '@/lin/utils/token '
3
3
4
4
5
5
export default {
You can’t perform that action at this time.
0 commit comments