zhizhijie
4 小时以前 799ec6799ad9e994f7d369f059ca7682962f648f
traffic-audit-web/src/views/Login.vue
@@ -44,7 +44,7 @@
    }
  },
  created() {
    axios.get('/api/auth/captcha-config')
    axios.get('/api/auth/captcha-config', { timeout: 10000 })
      .then(res => {
        const d = res.data
        if (d && d.code === 200) this.captchaRequired = d.data.required !== false
@@ -75,14 +75,14 @@
          password: this.form.password,
          captchaId: this.captchaId,
          captchaClickIds: this.clickIds
        }).then(res => {
        }, { timeout: 15000 }).then(res => {
          this.loggingIn = false
          const d = res.data
          if (d.code === 200) {
            localStorage.setItem('token', d.data.token)
            localStorage.setItem('username', d.data.username)
            localStorage.setItem('realName', d.data.realName || '')
            localStorage.setItem('modules', d.data.modules || '')
            sessionStorage.setItem('token', d.data.token)
            sessionStorage.setItem('username', d.data.username)
            sessionStorage.setItem('realName', d.data.realName || '')
            sessionStorage.setItem('modules', d.data.modules || '')
            this.$message.success('登录成功')
            this.$router.push('/dashboard')
          } else if (d.code === 401) {
@@ -95,8 +95,9 @@
            this.$message.error(d.message || '登录失败,请重试')
            if (this.$refs.captcha) this.$refs.captcha.load()
          }
        }).catch(() => {
        }).catch(e => {
          this.loggingIn = false
          if (e && e.code === 'ECONNABORTED') { this.$message.error('登录请求超时,请重试'); return }
          this.$message.error('网络错误,登录失败')
        })
      })