研发图纸文件管理系统-前端项目
iczer
2020-07-15 687a3adc37ffcfbd65942c8ca55655deec04ca08
chore: optimize the code; :star2:
3个文件已修改
31 ■■■■ 已修改文件
src/pages/login/Login.vue 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/services/user.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/login/Login.vue
@@ -100,22 +100,21 @@
          this.logging = true
          const name = this.form.getFieldValue('name')
          const password = this.form.getFieldValue('password')
          // 登录
          login(name, password)
          .then((res) => {
            this.logging = false
            const result = res.data
            if (result.code >= 0) {
              const user = result.data.user
              this.$router.push('/dashboard/workplace')
              this.$store.commit('account/setUser', user)
              this.$message.success(result.message, 3)
            } else {
              this.error = result.message
            }
          })
          login(name, password).then(this.afterLogin)
        }
      })
    },
    afterLogin(res) {
      this.logging = false
      const result = res.data
      if (result.code >= 0) {
        const user = result.data.user
        this.$router.push('/dashboard/workplace')
        this.$store.commit('account/setUser', user)
        this.$message.success(result.message, 3)
      } else {
        this.error = result.message
      }
    }
  }
}
src/services/user.js
@@ -7,7 +7,7 @@
 * @param password 账户密码
 * @returns {Promise<AxiosResponse<T>>}
 */
function login(name, password) {
async function login(name, password) {
  return request(LOGIN, METHOD.POST, {
    name: name,
    password: password
src/utils/request.js
@@ -6,7 +6,7 @@
}
/**
 * axios请求函数
 * axios请求
 * @param url 请求地址
 * @param method {METHOD} http method
 * @param params 请求参数