session
Showing
2 changed files
with
8 additions
and
34 deletions
... | @@ -21,25 +21,25 @@ | ... | @@ -21,25 +21,25 @@ |
21 | import { mapGetters } from 'vuex' | 21 | import { mapGetters } from 'vuex' |
22 | import Breadcrumb from '@/components/Breadcrumb' | 22 | import Breadcrumb from '@/components/Breadcrumb' |
23 | import Hamburger from '@/components/Hamburger' | 23 | import Hamburger from '@/components/Hamburger' |
24 | import { getSession } from '@/utils/session' | 24 | // import { getSession } from '@/utils/session' |
25 | export default { | 25 | export default { |
26 | components: { | 26 | components: { |
27 | Breadcrumb, | 27 | Breadcrumb, |
28 | Hamburger | 28 | Hamburger |
29 | }, | 29 | }, |
30 | created () { | 30 | created () { |
31 | this.init(); | 31 | // this.init(); |
32 | }, | 32 | }, |
33 | computed: { | 33 | computed: { |
34 | ...mapGetters(['sidebar', 'avatar', 'name']) | 34 | ...mapGetters(['sidebar', 'avatar', 'name']) |
35 | }, | 35 | }, |
36 | methods: { | 36 | methods: { |
37 | init () { | 37 | // init () { |
38 | let userInfo = getSession('userInfo'); | 38 | // let userInfo = getSession('userInfo'); |
39 | if (userInfo && userInfo.userValid === 0) { | 39 | // if (userInfo && userInfo.userValid === 0) { |
40 | this.userValid = 0; | 40 | // this.userValid = 0; |
41 | } | 41 | // } |
42 | }, | 42 | // }, |
43 | toggleSideBar () { | 43 | toggleSideBar () { |
44 | this.$store.dispatch('app/toggleSideBar') | 44 | this.$store.dispatch('app/toggleSideBar') |
45 | }, | 45 | }, | ... | ... |
src/utils/session.js
deleted
100644 → 0
1 | // setSession | ||
2 | export function setSession (key, value, time) { | ||
3 | time = time ? Date.parse(new Date()) + time * 1000 * 60 : null | ||
4 | let params = { | ||
5 | value: value, | ||
6 | time: time ? time : null | ||
7 | } | ||
8 | window.sessionStorage.setItem(key, JSON.stringify(params)) | ||
9 | } | ||
10 | // getSession | ||
11 | export function getSession (key) { | ||
12 | let params = window.sessionStorage.getItem(key) | ||
13 | if (!params) return null | ||
14 | params = JSON.parse(params) | ||
15 | if (params.time) { | ||
16 | if (params.time > Date.parse(new Date)) { | ||
17 | return params.value | ||
18 | } | ||
19 | window.sessionStorage.removeItem(key) | ||
20 | return null | ||
21 | } | ||
22 | return params.value | ||
23 | } | ||
24 | export function removeSession (key) { | ||
25 | return sessionStorage.removeItem(key) | ||
26 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment