| | |
| | | // 添加窗口大小变化监听器 |
| | | window.addEventListener('resize', this.handleResize) |
| | | }, |
| | | mounted() { |
| | | document.addEventListener("keydown", this.handleKeyDown); |
| | | }, |
| | | destroyed() { |
| | | // 组件销毁时移除监听器 |
| | | window.removeEventListener('resize', this.handleResize) |
| | | document.removeEventListener("keydown", this.handleKeyDown); |
| | | }, |
| | | methods: { |
| | | handleKeyDown(event) { |
| | | if (event.key === 'Enter') { |
| | | this.login() |
| | | } |
| | | }, |
| | | // 添加处理窗口大小变化的方法 |
| | | handleResize() { |
| | | this.viewWidth = window.innerWidth |
| | |
| | | return |
| | | } |
| | | loginReq(this.loginForm).then(res => { |
| | | console.log('111111',res) |
| | | console.log('111111', res) |
| | | sessionStorage.setItem('token', res.token) |
| | | sessionStorage.setItem('userInfo', JSON.stringify(res.userInfo.user)) |
| | | this.$router.push('/system') |