16. 个人信息的功能接入

master
YunaiV 3 years ago
parent 7db5b436b4
commit cbddf13cd0
  1. 13
      src/api/path/system.api.ts
  2. 5
      src/api/path/system.d.ts
  3. 11
      src/i18n/en/index.ts
  4. 11
      src/i18n/zh/index.ts
  5. 16
      src/views/login/index.vue

@ -1,7 +1,7 @@
import { http } from '@/api/http'
import { httpErrorHandle } from '@/utils'
import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
import { AuthLoginRespVO } from './system'
import {AuthLoginRespVO, ProfileVO} from './system'
// * 登录
export const loginApi = async (data: object) => {
@ -24,6 +24,17 @@ export const logoutApi = async () => {
}
}
// 查询用户个人信息
export const getUserProfileApi = async () => {
try {
const res = await http(RequestHttpEnum.GET)<ProfileVO>(`${ModuleTypeEnum.SYSTEM}/user/profile/get`)
return res
} catch (err) {
httpErrorHandle()
}
}
// 获取验证图片 以及token
export const getCodeApi = async (data: any) => {
try {

@ -16,3 +16,8 @@ export interface AuthLoginRespVO {
*/
expiresTime: number
}
export interface ProfileVO {
id: number
nickname: string
}

@ -34,9 +34,18 @@ const http = {
token_overdue_message: 'Login expired, please log in again!'
}
const captcha = {
verification: 'Please complete security verification',
slide: 'Swipe right to complete verification',
point: 'Please click',
success: 'Verification succeeded',
fail: 'verification failed'
}
export default {
global,
http,
login,
project
project,
captcha
}

@ -39,9 +39,18 @@ const http = {
token_overdue_message: '登录过期,请重新登录!'
}
const captcha = {
verification: '请完成安全验证',
slide: '向右滑动完成验证',
point: '请依次点击',
success: '验证成功',
fail: '验证失败',
}
export default {
global,
http,
login,
project
project,
captcha
}

@ -147,7 +147,7 @@ import { PageEnum } from '@/enums/pageEnum'
import { StorageEnum } from '@/enums/storageEnum'
import { icon } from '@/plugins'
import { routerTurnByName } from '@/utils'
import {getTenantIdByNameApi, loginApi} from '@/api/path'
import {getTenantIdByNameApi, getUserProfileApi, loginApi} from '@/api/path'
import { Verify } from '@/components/Verifition'
interface FormState {
@ -269,14 +269,19 @@ const handleSubmit = async (params: any) => {
captchaVerification: params.captchaVerification
})
if(loginRes && loginRes.data) {
// Token
// Token
const tokenValue = loginRes.data.accessToken
const tokenName = 'Authorization'
systemStore.setItem(SystemStoreEnum.USER_INFO, {
[SystemStoreUserInfoEnum.USER_TOKEN]: tokenValue,
[SystemStoreUserInfoEnum.TOKEN_NAME]: tokenName
})
//
const profileRes = await getUserProfileApi()
const id = loginRes.data.userId
const username = '芋道源码'
const nickname = '芋道源码'
const username = profileRes?.data?.nickname
const nickname = profileRes?.data?.nickname
// pinia
systemStore.setItem(SystemStoreEnum.USER_INFO, {
[SystemStoreUserInfoEnum.USER_TOKEN]: tokenValue,
@ -284,7 +289,6 @@ const handleSubmit = async (params: any) => {
[SystemStoreUserInfoEnum.USER_ID]: id,
[SystemStoreUserInfoEnum.USER_NAME]: username,
[SystemStoreUserInfoEnum.NICK_NAME]: nickname,
t
})
window['$message'].success(t('login.login_success'))

Loading…
Cancel
Save