Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #16 from Jzow/master
Browse files Browse the repository at this point in the history
Fix new ui in login api error
  • Loading branch information
Jzow authored Sep 20, 2023
2 parents a16ca4e + 5b7525a commit c1f5087
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 128 deletions.
Binary file removed public/favicon2.ico
Binary file not shown.
Binary file removed public/resource/img/pwa-192x192.png
Binary file not shown.
Binary file removed public/resource/img/pwa-512x512.png
Binary file not shown.
16 changes: 16 additions & 0 deletions src/api/model/baseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ export interface BasicFetchResult<T> {
items: T[];
total: number;
}

export interface BaseDataResp<T> {
code: string;
msg: string;
data: T;
}

export interface BaseResp {
code?: string;
msg: string;
}

export interface BaseListResp<T> {
data: T[];
total: number;
}
23 changes: 23 additions & 0 deletions src/api/sys/captcha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { BaseDataResp } from '../model/baseModel';
import { ErrorMessageMode } from '/#/axios';
import { defHttp } from '/@/utils/http/axios';

enum Api {
GetCaptcha = '/v2/common/captcha'
}

interface CaptchaResp {
captchaId: string;
imagePath: string;
}

export function getCaptcha(mode: ErrorMessageMode = 'notice') {
return defHttp.get<BaseDataResp<CaptchaResp>>(
{
url: Api.GetCaptcha,
},
{
errorMessageMode: mode,
},
);
}
12 changes: 12 additions & 0 deletions src/api/sys/model/captchaModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface CaptchaResp {
captchaId: string;
imgPath: string;
}

export interface GetEmailCaptchaReq {
email: string;
}

export interface GetSmsCaptchaReq {
phoneNumber: string;
}
4 changes: 2 additions & 2 deletions src/api/sys/model/uploadModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface UploadApiResult {
message: string;
code: number;
msg: string;
code: string;
url: string;
}
21 changes: 17 additions & 4 deletions src/api/sys/model/userModel.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/**
* @description: Login interface parameters
*/
export interface LoginParams {
export interface LoginReq {
username: string;
password: string;
captcha: string;
captchaId: string;
}

export interface RoleInfo {
roleName: string;
value: string;
}

export interface LoginResp {
userId: string | number;
token: string;
expire?: number;
}

/**
* @description: Login interface return value
*/
Expand All @@ -24,15 +32,20 @@ export interface LoginResultModel {
* @description: Get user information return value
*/
export interface GetUserInfoModel {
roles: RoleInfo[];
// 用户id
userId: string | number;
// 用户名
username: string;
// 真实名字
realName: string;
// 昵称
name: string;
// 头像
avatar: string;
// 介绍
desc?: string;
// 用户首页
homePath: string;
// 用户角色
roles?: string[];
// 用户角色名称
roleName: string[];
}
1 change: 0 additions & 1 deletion src/api/sys/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function uploadApi(
return defHttp.uploadFile<UploadApiResult>(
{
url: uploadUrl,
onUploadProgress,
},
params,
);
Expand Down
19 changes: 12 additions & 7 deletions src/api/sys/user.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';
import {GetUserInfoModel, LoginReq, LoginResp} from './model/userModel';

import { ErrorMessageMode } from '/#/axios';
import {BaseDataResp} from "@/api/model/baseModel";

enum Api {
Login = '/login',
Logout = '/logout',
GetUserInfo = '/getUserInfo',
Login = '/user/login',
Logout = '/user/logout',
GetUserInfo = '/user/info',
GetPermCode = '/getPermCode',
TestRetry = '/testRetry',
}

/**
* @description: user login api
*/
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
return defHttp.post<LoginResultModel>(
export function login(params: LoginReq, mode: ErrorMessageMode = 'notice') {
return defHttp.post<BaseDataResp<LoginResp>>(
{
url: Api.Login,
params,
},
{
errorMessageMode: mode,
successMessageMode: mode,
},
);
}
Expand All @@ -30,7 +32,10 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
* @description: getUserInfo
*/
export function getUserInfo() {
return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, { errorMessageMode: 'none' });
return defHttp.get<BaseDataResp<GetUserInfoModel>>(
{ url: Api.GetUserInfo },
{ errorMessageMode: 'none' },
);
}

export function getPermCode() {
Expand Down
2 changes: 2 additions & 0 deletions src/enums/cacheEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const ROLES_KEY = 'ROLES__KEY__';
// project config key
export const PROJ_CFG_KEY = 'PROJ__CFG__KEY__';

export const ROLES_NAME_KEY = 'ROLES__NAME__KEY__';

// lock info
export const LOCK_INFO_KEY = 'LOCK__INFO__KEY__';

Expand Down
6 changes: 3 additions & 3 deletions src/enums/httpEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @description: Request result set
*/
export enum ResultEnum {
SUCCESS = 0,
ERROR = -1,
TIMEOUT = 401,
SUCCESS = '00000',
ERROR = 'A0500',
TIMEOUT = 'A0501',
TYPE = 'success',
}

Expand Down
7 changes: 4 additions & 3 deletions src/locales/lang/en/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,17 @@ export default {
placeholder: 'Please enter the lock screen password or user password',
},
login: {
captcha: 'Verification code',
backSignIn: 'Back sign in',
mobileSignInFormTitle: 'Mobile sign in',
qrSignInFormTitle: 'Qr code sign in',
signInFormTitle: 'Sign in',
signUpFormTitle: 'Sign up',
forgetFormTitle: 'Reset password',

signInTitle: 'Backstage management system',
signInDesc: 'Enter your personal details and get started!',
policy: 'I agree to the xxx Privacy Policy',
signInTitle: 'Provide next-generation intelligent ERP system software for enterprises',
signInDesc: '© 2023-2033 Wan Sen ERP - All Right Reserved',
policy: 'I agree, to the WanSer ERP System Privacy Policy',
scanSign: `scanning the code to complete the login`,

loginButton: 'Sign in',
Expand Down
11 changes: 6 additions & 5 deletions src/locales/lang/zh-CN/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,21 @@ export default {
placeholder: '请输入锁屏密码或者用户密码',
},
login: {
captcha: '验证码',
backSignIn: '返回',
signInFormTitle: '登录',
mobileSignInFormTitle: '手机登录',
qrSignInFormTitle: '二维码登录',
signUpFormTitle: '注册',
signUpFormTitle: '注册租户',
forgetFormTitle: '重置密码',

signInTitle: '开箱即用的中后台管理系统',
signInDesc: '输入您的个人详细信息开始使用!',
policy: '我同意xxx隐私政策',
signInTitle: '为企业提供下一代智能ERP系统软件',
signInDesc: '© 2015-2030 Wan Sen ERP - All Right Reserved 版权所有',
policy: '我同意,《万森ERP系统》隐私政策',
scanSign: `扫码后点击"确认",即可完成登录`,

loginButton: '登录',
registerButton: '注册',
registerButton: '注册租户',
rememberMe: '记住我',
forgetPassword: '忘记密码?',
otherSignIn: '其他登录方式',
Expand Down
Loading

0 comments on commit c1f5087

Please sign in to comment.