| @@ -4,7 +4,7 @@ import { logout } from '@/services/system/auth'; | |||||
| import { ClientInfo } from '@/types'; | import { ClientInfo } from '@/types'; | ||||
| import { sleep } from '@/utils/promise'; | import { sleep } from '@/utils/promise'; | ||||
| import SessionStorage from '@/utils/sessionStorage'; | import SessionStorage from '@/utils/sessionStorage'; | ||||
| import { gotoLoginPage, oauthLogout } from '@/utils/ui'; | |||||
| import { oauthLogout } from '@/utils/ui'; | |||||
| import { LogoutOutlined, UserOutlined } from '@ant-design/icons'; | import { LogoutOutlined, UserOutlined } from '@ant-design/icons'; | ||||
| import { setAlpha } from '@ant-design/pro-components'; | import { setAlpha } from '@ant-design/pro-components'; | ||||
| import { useEmotionCss } from '@ant-design/use-emotion-css'; | import { useEmotionCss } from '@ant-design/use-emotion-css'; | ||||
| @@ -68,12 +68,15 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => { | |||||
| await Promise.all([logout(), sleep(1000)]); | await Promise.all([logout(), sleep(1000)]); | ||||
| clearSessionToken(); | clearSessionToken(); | ||||
| setRemoteMenu(null); | setRemoteMenu(null); | ||||
| gotoLoginPage(); | |||||
| // 退出 oauth2 | |||||
| const clientInfo: ClientInfo = SessionStorage.getItem(SessionStorage.clientInfoKey, true); | const clientInfo: ClientInfo = SessionStorage.getItem(SessionStorage.clientInfoKey, true); | ||||
| if (clientInfo) { | if (clientInfo) { | ||||
| const { logoutUri } = clientInfo; | const { logoutUri } = clientInfo; | ||||
| location.replace(logoutUri); | location.replace(logoutUri); | ||||
| } | } | ||||
| // setTimeout(() => { | |||||
| // gotoLoginPage(); | |||||
| // }, 1000); | |||||
| }; | }; | ||||
| const actionClassName = useEmotionCss(({ token }) => { | const actionClassName = useEmotionCss(({ token }) => { | ||||
| return { | return { | ||||
| @@ -113,7 +113,7 @@ const AuthUserTableList: React.FC = () => { | |||||
| dataIndex: 'createTime', | dataIndex: 'createTime', | ||||
| valueType: 'dateRange', | valueType: 'dateRange', | ||||
| render: (_, record) => { | render: (_, record) => { | ||||
| return <span>{record.createTime.toString()} </span>; | |||||
| return <span>{record.createTime?.toString()} </span>; | |||||
| }, | }, | ||||
| hideInSearch: true, | hideInSearch: true, | ||||
| }, | }, | ||||
| @@ -84,7 +84,7 @@ const UserSelectorModal: React.FC<DataScopeFormProps> = (props) => { | |||||
| valueType: 'dateRange', | valueType: 'dateRange', | ||||
| hideInSearch: true, | hideInSearch: true, | ||||
| render: (_, record) => { | render: (_, record) => { | ||||
| return <span>{record.createTime.toString()} </span>; | |||||
| return <span>{record.createTime?.toString()} </span>; | |||||
| }, | }, | ||||
| }, | }, | ||||
| ]; | ]; | ||||
| @@ -240,7 +240,7 @@ const RoleTableList: React.FC = () => { | |||||
| dataIndex: 'createTime', | dataIndex: 'createTime', | ||||
| valueType: 'dateRange', | valueType: 'dateRange', | ||||
| render: (_, record) => { | render: (_, record) => { | ||||
| return <span>{record.createTime.toString()} </span>; | |||||
| return <span>{record.createTime?.toString()} </span>; | |||||
| }, | }, | ||||
| search: { | search: { | ||||
| transform: (value) => { | transform: (value) => { | ||||
| @@ -267,14 +267,14 @@ export const hasNoValue = (value?: any | null): boolean => { | |||||
| /** | /** | ||||
| * 获取 git 仓库的 url | * 获取 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 | * @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'. | * 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'. | * 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) { | if (!url) { | ||||
| return ''; | return ''; | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| import { canBeConvertToDate } from '../src/utils/date'; | import { canBeConvertToDate } from '../src/utils/date'; | ||||
| describe('canBeConvertToDate()', () => { | |||||
| describe('test canBeConvertToDate()', () => { | |||||
| test('null', () => { | test('null', () => { | ||||
| expect(canBeConvertToDate(null)).toBe(false); | expect(canBeConvertToDate(null)).toBe(false); | ||||
| }); | }); | ||||
| @@ -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', | |||||
| ); | |||||
| }); | |||||
| }); | |||||
| @@ -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', | |||||
| ); | |||||
| }); | |||||
| }); | |||||