-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(projects): refactor page: user-management [重构用户管理页面]
- Loading branch information
1 parent
88e535f
commit 468b4bb
Showing
26 changed files
with
342 additions
and
353 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** 用户性别 */ | ||
export const genderLabels: Record<UserManagement.GenderKey, string> = { | ||
0: '女', | ||
1: '男' | ||
}; | ||
|
||
export const genderOptions: { value: UserManagement.GenderKey; label: string }[] = [ | ||
{ value: '0', label: genderLabels['0'] }, | ||
{ value: '1', label: genderLabels['1'] } | ||
]; | ||
|
||
/** 用户状态 */ | ||
export const userStatusLabels: Record<UserManagement.UserStatusKey, string> = { | ||
1: '启用', | ||
2: '禁用', | ||
3: '冻结', | ||
4: '软删除' | ||
}; | ||
|
||
export const userStatusOptions: { value: UserManagement.UserStatusKey; label: string }[] = [ | ||
{ value: '1', label: userStatusLabels['1'] }, | ||
{ value: '2', label: userStatusLabels['2'] }, | ||
{ value: '3', label: userStatusLabels['3'] }, | ||
{ value: '4', label: userStatusLabels['4'] } | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './business'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function useTable() {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './auth'; | ||
export * from './demo'; | ||
export * from './management'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,13 @@ | ||
import { EnumGender } from '@/enum'; | ||
import { isUndefined } from '@/utils'; | ||
export function adapterOfFetchUserList(data: ApiUserManagement.User[] | null): UserManagement.User[] { | ||
if (!data) return []; | ||
|
||
export function adapterOfFetchUserManagementList( | ||
requestData: ApiUserManagement.UserTable[] | ||
): UserManagement.UserTable[] { | ||
const genderMap: Record< | ||
NonNullable<ApiUserManagement.UserTable['gender']>, | ||
NonNullable<UserManagement.UserTable['userGender']> | ||
> = { | ||
'0': 'female', | ||
'1': 'male' | ||
}; | ||
|
||
// 1. 有可能依赖于多个接口的结果,再转换成页面的数据 | ||
// 2. 接口定义的字段有可能为null, 例如 预期是数组却返回了null,导致调用数组方法报错 | ||
// 3. 字段可能丢失 | ||
|
||
return requestData.map((item, index) => { | ||
const { id, name: userName, age, gender, phone: userPhone, email: userEmail, role: userRole, disabled } = item; | ||
|
||
const userAge = isUndefined(age) ? '无' : String(age); | ||
|
||
const userGender = gender !== null ? genderMap[gender] : 'null'; | ||
|
||
const result: UserManagement.UserTable = { | ||
return data.map((item, index) => { | ||
const user: UserManagement.User = { | ||
index: index + 1, | ||
key: id, | ||
id, | ||
userName, | ||
userAge, | ||
userGender, | ||
userGenderLabel: EnumGender[userGender], | ||
userPhone, | ||
userEmail, | ||
userRole, | ||
disabled | ||
key: item.id, | ||
...item | ||
}; | ||
|
||
return result; | ||
return user; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
import { adapter } from '@/utils'; | ||
import { mockRequest } from '../request'; | ||
import { adapterOfFetchUserManagementList } from './management.adapter'; | ||
import { adapterOfFetchUserList } from './management.adapter'; | ||
|
||
/** | ||
* 获取用户管理列表 | ||
*/ | ||
export async function fetchUserManagementList() { | ||
const data = await mockRequest.post<ApiUserManagement.UserTable[]>('/getUserManagementList'); | ||
|
||
return adapter(adapterOfFetchUserManagementList, data); | ||
} | ||
/** 获取用户列表 */ | ||
export const fetchUserList = async () => { | ||
const data = await mockRequest.post<ApiUserManagement.User[] | null>('/getAllUserList'); | ||
return adapter(adapterOfFetchUserList, data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare namespace NaiveUI { | ||
type ThemeColor = 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
468b4bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
soybean-admin – ./
soybean-admin-git-main-honghuangdc.vercel.app
soybean-admin.vercel.app
soybean-admin-honghuangdc.vercel.app
soybean.pro
www.soybean.pro