diff --git a/src/api/auth/index.ts b/src/api/auth/index.ts index 61de631a..d75d67b1 100644 --- a/src/api/auth/index.ts +++ b/src/api/auth/index.ts @@ -1,6 +1,6 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { LoginData, LoginResult } from './types'; +import { CaptchaResult, LoginData, LoginResult } from './types'; /** * 登录API @@ -25,3 +25,15 @@ export function logoutApi() { method: 'delete' }); } + + + +/** + * 获取验证码 + */ +export function getCaptchaApi(): AxiosPromise { + return request({ + url: '/api/v1/auth/captcha', + method: 'get' + }); +} diff --git a/src/api/auth/types.ts b/src/api/auth/types.ts index cd8bd3a3..dcc47d09 100644 --- a/src/api/auth/types.ts +++ b/src/api/auth/types.ts @@ -5,11 +5,21 @@ export interface LoginData { /** * 用户名 */ - username: string; + username?: string; /** * 密码 */ - password: string; + password?: string; + + /** + * 验证码缓存key + */ + verifyCodeKey?: string; + + /** + * 验证码 + */ + verifyCode?: string; } /** @@ -33,3 +43,18 @@ export interface LoginResult { */ tokenType?: string; } + +/** + * 验证码响应 + */ +export interface CaptchaResult { + /** + * 验证码缓存key + */ + verifyCodeKey: string; + /** + * 验证码图片Base64字符串 + */ + verifyCodeBase64: string; +} + diff --git a/src/assets/icons/verify_code.svg b/src/assets/icons/verify_code.svg new file mode 100644 index 00000000..39bf4783 --- /dev/null +++ b/src/assets/icons/verify_code.svg @@ -0,0 +1,9 @@ + + + + diff --git a/src/lang/en.ts b/src/lang/en.ts index 64318e70..6213eb2e 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -10,10 +10,7 @@ export default { username: 'Username', password: 'Password', login: 'Login', - code: 'Verification Code', - copyright: '', - icp: '', - thirdPartyLogin: 'third-party login' + verifyCode: 'Verify Code', }, // 导航栏国际化 navbar: { diff --git a/src/lang/zh-cn.ts b/src/lang/zh-cn.ts index 1c915266..06cd85b1 100644 --- a/src/lang/zh-cn.ts +++ b/src/lang/zh-cn.ts @@ -10,10 +10,7 @@ export default { username: '用户名', password: '密码', login: '登 录', - code: '请输入验证码', - copyright: '', - icp: '', - thirdPartyLogin: '第三方登录' + verifyCode: '验证码' }, navbar: { dashboard: '首页', diff --git a/src/views/login/index.vue b/src/views/login/index.vue index f2799cde..9243f640 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -1,11 +1,6 @@