From 17608bbe12fe9ee04e0dc167aabf9433f7f365b8 Mon Sep 17 00:00:00 2001 From: kangod Date: Mon, 5 Feb 2024 18:33:46 +0800 Subject: [PATCH] =?UTF-8?q?modify:=20=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=20api=20=E4=BB=8E=20mock=20=E5=88=B0=20nest=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=89=80=E6=9C=89=20username=20=E4=B8=BA=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_mock/_user.js | 6 +++--- src/_mock/assets.js | 8 ++++---- src/api/services/userService.ts | 2 +- src/layouts/_common/account-dropdown.tsx | 4 ++-- src/locales/lang/en_US/sys.json | 4 ++-- src/locales/lang/zh_CN/sys.json | 2 +- src/pages/dashboard/workbench/banner-card.tsx | 4 ++-- src/pages/management/system/user/index.tsx | 2 +- .../management/user/account/general-tab.tsx | 6 +++--- src/pages/management/user/profile/index.tsx | 4 ++-- .../management/user/profile/profile-tab.tsx | 6 +++--- src/pages/sys/login/LoginForm.tsx | 18 +++++++++--------- src/pages/sys/login/RegisterForm.tsx | 4 ++-- src/pages/sys/others/kanban/task-detail.tsx | 6 +++--- src/pages/sys/others/kanban/task-utils.ts | 2 +- src/pages/sys/others/kanban/types.ts | 2 +- src/store/userStore.ts | 2 +- types/entity.ts | 2 +- 18 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/_mock/_user.js b/src/_mock/_user.js index c5aaa44..57a2c18 100644 --- a/src/_mock/_user.js +++ b/src/_mock/_user.js @@ -6,15 +6,15 @@ import { UserApi } from '@/api/services/userService'; import { USER_LIST } from './assets'; const signIn = rest.post(`/api${UserApi.SignIn}`, async (req, res, ctx) => { - const { username, password } = await req.json(); + const { account, password } = await req.json(); - const user = USER_LIST.find((item) => item.username === username); + const user = USER_LIST.find((item) => item.account === account); if (!user || user.password !== password) { return res( ctx.json({ status: 10001, - message: 'Incorrect username or password.', + message: 'Incorrect account or password.', }), ); } diff --git a/src/_mock/assets.js b/src/_mock/assets.js index e740b4c..63a0d65 100644 --- a/src/_mock/assets.js +++ b/src/_mock/assets.js @@ -499,19 +499,19 @@ export const ROLE_LIST = [ADMIN_ROLE, TEST_ROLE]; */ export const DEFAULT_USER = { id: faker.string.uuid(), - username: 'admin@gmail.com', + account: 'lamp', email: faker.internet.email(), avatar: faker.image.avatarLegacy(), createdAt: faker.date.anytime(), updatedAt: faker.date.recent(), - password: 'demo1234', + password: '123456', role: ADMIN_ROLE, permissions: ADMIN_ROLE.permission, }; export const TEST_USER = { id: faker.string.uuid(), - username: 'test@gmail.com', - password: 'demo1234', + account: 'lamp_pt', + password: '123456', email: faker.internet.email(), avatar: faker.image.avatarLegacy(), createdAt: faker.date.anytime(), diff --git a/src/api/services/userService.ts b/src/api/services/userService.ts index 59a037b..8586dc1 100644 --- a/src/api/services/userService.ts +++ b/src/api/services/userService.ts @@ -3,7 +3,7 @@ import apiClient from '../apiClient'; import { UserInfo, UserToken } from '#/entity'; export interface SignInReq { - username: string; + account: string; password: string; } diff --git a/src/layouts/_common/account-dropdown.tsx b/src/layouts/_common/account-dropdown.tsx index e88dccb..c0fd086 100644 --- a/src/layouts/_common/account-dropdown.tsx +++ b/src/layouts/_common/account-dropdown.tsx @@ -17,7 +17,7 @@ const { VITE_APP_HOMEPAGE: HOMEPAGE } = import.meta.env; */ export default function AccountDropdown() { const { replace } = useRouter(); - const { username, email, avatar } = useUserInfo(); + const { account, email, avatar } = useUserInfo(); const { clearUserInfoAndToken } = useUserActions(); const { backToLogin } = useLoginStateContext(); const { t } = useTranslation(); @@ -48,7 +48,7 @@ export default function AccountDropdown() { const dropdownRender: DropdownProps['dropdownRender'] = (menu) => (
-
{username}
+
{account}
{email}
diff --git a/src/locales/lang/en_US/sys.json b/src/locales/lang/en_US/sys.json index acd126f..1db08c3 100644 --- a/src/locales/lang/en_US/sys.json +++ b/src/locales/lang/en_US/sys.json @@ -52,7 +52,7 @@ "loginSuccessTitle": "Login successful", "loginSuccessDesc": "Welcome back", - "accountPlaceholder": "Please input username", + "accountPlaceholder": "Please input account", "passwordPlaceholder": "Please input password", "confirmPasswordPlaceholder": "Please input confirm password", "emaildPlaceholder": "Please input email", @@ -61,7 +61,7 @@ "policyPlaceholder": "Register after checking", "diffPwd": "The two passwords are inconsistent", - "userName": "Username", + "account": "Account", "password": "Password", "confirmPassword": "Confirm Password", "email": "Email", diff --git a/src/locales/lang/zh_CN/sys.json b/src/locales/lang/zh_CN/sys.json index 63ba35b..0f53630 100644 --- a/src/locales/lang/zh_CN/sys.json +++ b/src/locales/lang/zh_CN/sys.json @@ -60,7 +60,7 @@ "policyPlaceholder": "勾选后才能注册", "diffPwd": "两次输入密码不一致", - "userName": "账号", + "account": "账号", "password": "密码", "confirmPassword": "确认密码", "email": "邮箱", diff --git a/src/pages/dashboard/workbench/banner-card.tsx b/src/pages/dashboard/workbench/banner-card.tsx index c2804dd..cbcb8af 100644 --- a/src/pages/dashboard/workbench/banner-card.tsx +++ b/src/pages/dashboard/workbench/banner-card.tsx @@ -6,7 +6,7 @@ import { useUserInfo } from '@/store/userStore'; import { useThemeToken } from '@/theme/hooks'; export default function BannerCard() { - const { username } = useUserInfo(); + const { account } = useUserInfo(); const themeToken = useThemeToken(); const bg = `linear-gradient(135deg, ${Color(themeToken.colorPrimaryHover).alpha(0.2)}, ${Color( @@ -26,7 +26,7 @@ export default function BannerCard() { style={{ color: themeToken.colorPrimaryActive }} >

Welcome back 👋

-

{username}

+

{account}

- {record.username} + {record.account} {record.email} diff --git a/src/pages/management/user/account/general-tab.tsx b/src/pages/management/user/account/general-tab.tsx index 110d824..30bcbc7 100644 --- a/src/pages/management/user/account/general-tab.tsx +++ b/src/pages/management/user/account/general-tab.tsx @@ -16,9 +16,9 @@ type FieldType = { }; export default function GeneralTab() { const { notification } = App.useApp(); - const { avatar, username, email } = useUserInfo(); + const { avatar, account, email } = useUserInfo(); const initFormValues = { - name: username, + name: account, email, phone: faker.phone.number(), address: faker.location.county(), @@ -58,7 +58,7 @@ export default function GeneralTab() { > - label="Username" name="name"> + label="Account" name="name"> diff --git a/src/pages/management/user/profile/index.tsx b/src/pages/management/user/profile/index.tsx index 5059df8..85be742 100644 --- a/src/pages/management/user/profile/index.tsx +++ b/src/pages/management/user/profile/index.tsx @@ -12,7 +12,7 @@ import ProjectsTab from './projects-tab'; import TeamsTab from './teams-tab'; function UserProfile() { - const { avatar, username } = useUserInfo(); + const { avatar, account } = useUserInfo(); const { colorTextBase } = useThemeToken(); const [currentTabIndex, setcurrentTabIndex] = useState(0); @@ -55,7 +55,7 @@ function UserProfile() { className="ml-6 mt-6 flex flex-col justify-center md:mt-0" style={{ color: '#fff' }} > - {username} + {account} TS FullStack
diff --git a/src/pages/management/user/profile/profile-tab.tsx b/src/pages/management/user/profile/profile-tab.tsx index a682f0a..faceda9 100644 --- a/src/pages/management/user/profile/profile-tab.tsx +++ b/src/pages/management/user/profile/profile-tab.tsx @@ -21,15 +21,15 @@ interface DataType { } export default function ProfileTab() { - const { username } = useUserInfo(); + const { account } = useUserInfo(); const theme = useThemeToken(); const AboutItems = [ - { icon: , label: 'Full Name', val: username }, + { icon: , label: 'Full Name', val: account }, { icon: , label: 'Role', val: 'Developer' }, { icon: , label: 'Country', val: 'USA' }, { icon: , label: 'Language', val: 'English' }, { icon: , label: 'Contact', val: '(123)456-7890' }, - { icon: , label: 'Email', val: username }, + { icon: , label: 'Email', val: account }, ]; const ConnectionsItems = [ diff --git a/src/pages/sys/login/LoginForm.tsx b/src/pages/sys/login/LoginForm.tsx index 914f9e4..6b3a85f 100644 --- a/src/pages/sys/login/LoginForm.tsx +++ b/src/pages/sys/login/LoginForm.tsx @@ -21,10 +21,10 @@ function LoginForm() { if (loginState !== LoginStateEnum.LOGIN) return null; - const handleFinish = async ({ username, password }: SignInReq) => { + const handleFinish = async ({ account, password }: SignInReq) => { setLoading(true); try { - await signIn({ username, password }); + await signIn({ account, password }); } finally { setLoading(false); } @@ -37,7 +37,7 @@ function LoginForm() { size="large" initialValues={{ remember: true, - username: DEFAULT_USER.username, + account: DEFAULT_USER.account, password: DEFAULT_USER.password, }} onFinish={handleFinish} @@ -48,16 +48,16 @@ function LoginForm() { description={
- Admin {t('sys.login.userName')}: + Admin {t('sys.login.account')}: - {DEFAULT_USER.username} + {DEFAULT_USER.account}
- Test {t('sys.login.userName')}: + Test {t('sys.login.account')}: - {TEST_USER.username} + {TEST_USER.account}
@@ -74,10 +74,10 @@ function LoginForm() {
- + {t('sys.login.signUpFormTitle')}
- + - {comments?.map(({ avatar, username, content, time }) => ( -
+ {comments?.map(({ avatar, account, content, time }) => ( +
- {username} + {account} {dayjs(time).format('DD/MM/YYYY HH:mm')}

{content}

diff --git a/src/pages/sys/others/kanban/task-utils.ts b/src/pages/sys/others/kanban/task-utils.ts index 266ce20..dc954d2 100644 --- a/src/pages/sys/others/kanban/task-utils.ts +++ b/src/pages/sys/others/kanban/task-utils.ts @@ -6,7 +6,7 @@ const fakeComment = (count: number): TaskComment[] => { const result = []; for (let index = 0; index < count; index += 1) { result.push({ - username: faker.person.fullName(), + account: faker.person.fullName(), avatar: faker.image.avatarLegacy(), content: faker.lorem.lines({ min: 1, max: 3 }), time: faker.date.past(), diff --git a/src/pages/sys/others/kanban/types.ts b/src/pages/sys/others/kanban/types.ts index 3419ab9..bb91399 100644 --- a/src/pages/sys/others/kanban/types.ts +++ b/src/pages/sys/others/kanban/types.ts @@ -17,7 +17,7 @@ export enum TaskTag { } export type TaskComment = { - username: string; + account: string; avatar: string; content: string; time: Date; diff --git a/src/store/userStore.ts b/src/store/userStore.ts index a7704a9..f6986ba 100644 --- a/src/store/userStore.ts +++ b/src/store/userStore.ts @@ -67,7 +67,7 @@ export const useSignIn = () => { notification.success({ message: t('sys.login.loginSuccessTitle'), - description: `${t('sys.login.loginSuccessDesc')}: ${data.username}`, + description: `${t('sys.login.loginSuccessDesc')}: ${data.account}`, duration: 3, }); } catch (err) { diff --git a/types/entity.ts b/types/entity.ts index 4681b1f..bc6aa34 100644 --- a/types/entity.ts +++ b/types/entity.ts @@ -8,7 +8,7 @@ export interface UserToken { export interface UserInfo { id: string; email: string; - username: string; + account: string; password?: string; avatar?: string; role?: Role;