|
@@ -65,8 +65,8 @@ export default {
|
|
|
},
|
|
|
}),
|
|
|
created() {
|
|
|
- this.checkUrl();
|
|
|
this.setUser();
|
|
|
+ this.check();
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
@@ -74,19 +74,8 @@ export default {
|
|
|
methods: {
|
|
|
...mapMutations(['setUser']),
|
|
|
...mapActions(['userOperation']),
|
|
|
- checkUrl() {
|
|
|
- if (location.search.length > 0) {
|
|
|
- let params = location.search.replace('?', '').split('=');
|
|
|
- let key = params[0];
|
|
|
- if (key.includes(`token`)) {
|
|
|
- let token = params[1];
|
|
|
- sessionStorage.setItem('token', token);
|
|
|
- let info = jwt.decode(token);
|
|
|
- this.setUser(info);
|
|
|
- let turnTo = window.location.href.replace(window.location.search, '');
|
|
|
- window.location.href = turnTo;
|
|
|
- }
|
|
|
- }
|
|
|
+ check() {
|
|
|
+ if (!this.user.id) this.$router.push({ path: '/login' });
|
|
|
},
|
|
|
toClose() {
|
|
|
this.$refs.form.resetFields();
|