From 300aaf32da47f3b0544d2cecdf813064604ee2eb Mon Sep 17 00:00:00 2001 From: walker Date: Fri, 2 Jun 2023 18:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/api/UserApi.ts | 9 ++++++++- src/boot/axios.ts | 4 ++-- src/configs/UrlManage.ts | 2 +- src/pages/UserLogin.vue | 24 +++++++++++++++++++++--- yarn.lock | 5 +++++ 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 446d582..3ca4442 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-vue": "^9.0.0", "prettier": "^2.5.1", + "ts-md5": "^1.3.1", "typescript": "^4.5.4" }, "engines": { diff --git a/src/api/UserApi.ts b/src/api/UserApi.ts index 6e98f3e..d2e129d 100644 --- a/src/api/UserApi.ts +++ b/src/api/UserApi.ts @@ -1,5 +1,6 @@ import { api } from 'src/boot/axios'; import { PageDto, PageQueryDto } from './ApiCommon'; +import { Md5 } from 'ts-md5'; const UserUriBase = '/api/user'; @@ -32,7 +33,7 @@ interface LoginInfo { password: string; } -const PasswordSult = ''; +const PasswordSult = 'sdfs'; /** * 用户登录 @@ -40,6 +41,12 @@ const PasswordSult = ''; * @returns */ export async function login(loginInfo: LoginInfo): Promise { + const md5 = new Md5(); + const encryptedPassword = md5 + .appendStr(`${loginInfo.password}${PasswordSult}`) + .end(); + const info = { ...loginInfo, password: encryptedPassword }; + console.log(info); const response = await api.post(`${UserUriBase}/login`, loginInfo); return response.data; } diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 5e7b59c..3fe93a6 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -15,7 +15,7 @@ interface ErrorData { status: number; title: string; detail: string; - properties: { [key: string]: unknown }; + code: number; } export class ApiError { @@ -37,7 +37,7 @@ export class ApiError { const response = origin.response; if (response) { const err = response.data as ErrorData; - this.code = err.properties.code as number; + this.code = err.code; this.title = err.title; this.detail = err.detail; } else { diff --git a/src/configs/UrlManage.ts b/src/configs/UrlManage.ts index 93c0159..42ab080 100644 --- a/src/configs/UrlManage.ts +++ b/src/configs/UrlManage.ts @@ -1,5 +1,5 @@ function getHost(): string { - return '192.168.3.212:9081'; + return '192.168.3.7:9081'; } export function getHttpBase() { diff --git a/src/pages/UserLogin.vue b/src/pages/UserLogin.vue index 57f30d7..558f1e6 100644 --- a/src/pages/UserLogin.vue +++ b/src/pages/UserLogin.vue @@ -21,7 +21,7 @@ @@ -29,7 +29,7 @@ type="password" filled v-model="loginInfo.password" - label="Password" + label="密码" lazy-rules /> @@ -49,15 +49,33 @@ diff --git a/yarn.lock b/yarn.lock index ad711b8..810ea2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3137,6 +3137,11 @@ toidentifier@1.0.1: resolved "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +ts-md5@^1.3.1: + version "1.3.1" + resolved "https://registry.npmmirror.com/ts-md5/-/ts-md5-1.3.1.tgz#f5b860c0d5241dd9bb4e909dd73991166403f511" + integrity sha512-DiwiXfwvcTeZ5wCE0z+2A9EseZsztaiZtGrtSaY5JOD7ekPnR/GoIVD5gXZAlK9Na9Kvpo9Waz5rW64WKAWApg== + tslib@^1.8.1: version "1.14.1" resolved "https://registry.npmmirror.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"