From 2b0c11525b60dcd38d88f8cbb077067946d3d0d7 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 22 May 2025 09:21:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=20giturl=20?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/utils/index.ts | 6 +++--- react-ui/tests/date.test.ts | 2 +- react-ui/tests/getGitUrl.test.ts | 35 ++++++++++++++++++++++++++++++++ react-ui/tests/getGitUrl.tesx.ts | 19 ----------------- 4 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 react-ui/tests/getGitUrl.test.ts delete mode 100644 react-ui/tests/getGitUrl.tesx.ts diff --git a/react-ui/src/utils/index.ts b/react-ui/src/utils/index.ts index a62e6e88..2db6af2a 100644 --- a/react-ui/src/utils/index.ts +++ b/react-ui/src/utils/index.ts @@ -267,14 +267,14 @@ export const hasNoValue = (value?: any | null): boolean => { /** * 获取 git 仓库的 url * - * @param {string} url - the url of the git repository - * @param {string} branch - the branch of the repository + * @param {string} [url] - the url of the git repository + * @param {string} [branch] - the branch of the repository * @return {string} the url of the repository * * If `branch` is given, the url will be in the format of 'http://gitlab.com/user/repo/tree/branch'. * Otherwise, the url will be in the format of 'http://gitlab.com/user/repo'. */ -export const getGitUrl = (url: string, branch: string): string => { +export const getGitUrl = (url?: string, branch?: string): string => { if (!url) { return ''; } diff --git a/react-ui/tests/date.test.ts b/react-ui/tests/date.test.ts index 6dbb028f..af91d8ab 100644 --- a/react-ui/tests/date.test.ts +++ b/react-ui/tests/date.test.ts @@ -1,6 +1,6 @@ import { canBeConvertToDate } from '../src/utils/date'; -describe('canBeConvertToDate()', () => { +describe('test canBeConvertToDate()', () => { test('null', () => { expect(canBeConvertToDate(null)).toBe(false); }); diff --git a/react-ui/tests/getGitUrl.test.ts b/react-ui/tests/getGitUrl.test.ts new file mode 100644 index 00000000..19be4061 --- /dev/null +++ b/react-ui/tests/getGitUrl.test.ts @@ -0,0 +1,35 @@ +import { getGitUrl } from '../src/utils'; + +describe('test getGitUrl', () => { + test('undefined', () => { + expect(getGitUrl(undefined)).toBe(''); + }); + + test('empty url', () => { + expect(getGitUrl('')).toBe(''); + }); + + test('url domain with branch', () => { + expect( + getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', 'master'), + ).toBe('https://gitlink.org.cn/somunslotus/material-atom-predict/tree/master'); + }); + + test('url domain without branch', () => { + expect(getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git')).toBe( + 'https://gitlink.org.cn/somunslotus/material-atom-predict', + ); + }); + + test('30202 port with branch', () => { + expect(getGitUrl('http://172.20.32.235:30202/fanshuai/active_learn_demo.git', 'master')).toBe( + 'http://172.20.32.235:30203/fanshuai/active_learn_demo/tree/master', + ); + }); + + test('30202 port without branch', () => { + expect(getGitUrl('http://172.20.32.235:30202/fanshuai/active_learn_demo.git')).toBe( + 'http://172.20.32.235:30203/fanshuai/active_learn_demo', + ); + }); +}); diff --git a/react-ui/tests/getGitUrl.tesx.ts b/react-ui/tests/getGitUrl.tesx.ts deleted file mode 100644 index b33a592e..00000000 --- a/react-ui/tests/getGitUrl.tesx.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getGitUrl } from '../src/utils'; - -describe('canBeConvertToDate()', () => { - test('empty string', () => { - expect(getGitUrl('', '')).toBe(''); - }); - - test('url domain with branch', () => { - expect( - getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', 'master'), - ).toBe('https://gitlink.org.cn/somunslotus/material-atom-predict/tree/master'); - }); - - test('url domain without branch', () => { - expect(getGitUrl('https://gitlink.org.cn/somunslotus/material-atom-predict.git', '')).toBe( - 'https://gitlink.org.cn/somunslotus/material-atom-predict.git', - ); - }); -}); From b8049721df232559fe583765d19313653dbb9f9f Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 22 May 2025 10:53:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=B8=A4=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/components/RightContent/AvatarDropdown.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/react-ui/src/components/RightContent/AvatarDropdown.tsx b/react-ui/src/components/RightContent/AvatarDropdown.tsx index ce90efb5..d3fa9e97 100644 --- a/react-ui/src/components/RightContent/AvatarDropdown.tsx +++ b/react-ui/src/components/RightContent/AvatarDropdown.tsx @@ -4,7 +4,7 @@ import { logout } from '@/services/system/auth'; import { ClientInfo } from '@/types'; import { sleep } from '@/utils/promise'; import SessionStorage from '@/utils/sessionStorage'; -import { gotoLoginPage, oauthLogout } from '@/utils/ui'; +import { oauthLogout } from '@/utils/ui'; import { LogoutOutlined, UserOutlined } from '@ant-design/icons'; import { setAlpha } from '@ant-design/pro-components'; import { useEmotionCss } from '@ant-design/use-emotion-css'; @@ -68,12 +68,15 @@ const AvatarDropdown: React.FC = ({ menu }) => { await Promise.all([logout(), sleep(1000)]); clearSessionToken(); setRemoteMenu(null); - gotoLoginPage(); + // 退出 oauth2 const clientInfo: ClientInfo = SessionStorage.getItem(SessionStorage.clientInfoKey, true); if (clientInfo) { const { logoutUri } = clientInfo; location.replace(logoutUri); } + // setTimeout(() => { + // gotoLoginPage(); + // }, 1000); }; const actionClassName = useEmotionCss(({ token }) => { return { From 16d4b476f20f617fd252fd37950ee72e8e49a1fb Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 22 May 2025 10:54:50 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E5=88=86=E9=85=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/pages/System/Role/authUser.tsx | 2 +- react-ui/src/pages/System/Role/components/UserSelectorModal.tsx | 2 +- react-ui/src/pages/System/Role/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-ui/src/pages/System/Role/authUser.tsx b/react-ui/src/pages/System/Role/authUser.tsx index 44678525..a22b3f59 100644 --- a/react-ui/src/pages/System/Role/authUser.tsx +++ b/react-ui/src/pages/System/Role/authUser.tsx @@ -113,7 +113,7 @@ const AuthUserTableList: React.FC = () => { dataIndex: 'createTime', valueType: 'dateRange', render: (_, record) => { - return {record.createTime.toString()} ; + return {record.createTime?.toString()} ; }, hideInSearch: true, }, diff --git a/react-ui/src/pages/System/Role/components/UserSelectorModal.tsx b/react-ui/src/pages/System/Role/components/UserSelectorModal.tsx index fa95872f..0128a6e6 100644 --- a/react-ui/src/pages/System/Role/components/UserSelectorModal.tsx +++ b/react-ui/src/pages/System/Role/components/UserSelectorModal.tsx @@ -84,7 +84,7 @@ const UserSelectorModal: React.FC = (props) => { valueType: 'dateRange', hideInSearch: true, render: (_, record) => { - return {record.createTime.toString()} ; + return {record.createTime?.toString()} ; }, }, ]; diff --git a/react-ui/src/pages/System/Role/index.tsx b/react-ui/src/pages/System/Role/index.tsx index b616c133..9488c100 100644 --- a/react-ui/src/pages/System/Role/index.tsx +++ b/react-ui/src/pages/System/Role/index.tsx @@ -240,7 +240,7 @@ const RoleTableList: React.FC = () => { dataIndex: 'createTime', valueType: 'dateRange', render: (_, record) => { - return {record.createTime.toString()} ; + return {record.createTime?.toString()} ; }, search: { transform: (value) => {