浏览代码

'调整退登逻辑;添加数据定义Data.User'

main
郑州 3 年前
父节点
当前提交
b7e564d692
共有 3 个文件被更改,包括 30 次插入3 次删除
  1. +1
    -1
      src/app.ts
  2. +27
    -0
      src/services/API.d.ts
  3. +2
    -2
      src/services/user.ts

+ 1
- 1
src/app.ts 查看文件

@@ -87,7 +87,7 @@ export const request: RequestConfig = {
};


export async function getInitialState(): Promise<{ isLogin: boolean, fetchUserInfo: () => any, currentUser?: any }> {
export async function getInitialState(): Promise<{ isLogin: boolean, fetchUserInfo: () => Promise<DATA.User>, currentUser?: DATA.User }> {
async function fetchUserInfo() {
const res = await queryCurrent();
handleRequest(res)


+ 27
- 0
src/services/API.d.ts 查看文件

@@ -12,4 +12,31 @@ declare namespace API {
*/
requestIsSuccess: boolean;
}


}

declare namespace DATA {
export interface User {
backgroundPermission: number;
/**
* 姓名
*/
cnName: string;
companyId: string;
deptId: string;
/**
* 部分名称
*/
deptName: string;
email: string;
/**
* 头像
*/
headImgUrl: string;
/**
* 手机号
*/
phone: string;
}
}

+ 2
- 2
src/services/user.ts 查看文件

@@ -9,7 +9,7 @@ export async function queryCurrent() {
if(!accountId) {
return errorReponse('');
}
const res = await fetchApi<API.ResponseData<any>>('user/queryUserByUserId', { id: accountId });
const res = await fetchApi<API.ResponseData<DATA.User>>('user/queryUserByUserId', { id: accountId });

// const data = firstCharToLowerCase(Object.assign({}, propertyOf(res)('Data.UserExt', {}), res.data || {}));
// data.roleName = roleMap[data.permission] || '';
@@ -62,5 +62,5 @@ export async function login(account: string, password: string) {

export function logout() {
storage.clear();
history.replace('/login');
window.location.href = '/login';
}

正在加载...
取消
保存