Refactor(Router): Change home to repository

Change home route to repository. Switch repository and store place in menu.
This commit is contained in:
2024-04-30 17:08:19 +08:00
parent c65c548ecc
commit e209bea2f3
9 changed files with 38 additions and 42 deletions

View File

@@ -78,11 +78,7 @@ const SignIn = () => {
setTimeout(() => { setTimeout(() => {
void getUserInfo().then((user) => { void getUserInfo().then((user) => {
refreshRouter() refreshRouter()
if (searchParams.has('redirect')) { navigate(searchParams.get('redirect') ?? '/repository')
navigate(searchParams.get('redirect') ?? '/')
} else {
navigate('/')
}
notification.success({ notification.success({
message: '欢迎回来', message: '欢迎回来',
@@ -262,7 +258,7 @@ const SignIn = () => {
navigate('/') navigate('/')
}} }}
> >
</a> </a>
<a <a
onClick={() => { onClick={() => {

View File

@@ -81,7 +81,7 @@ const Verify = () => {
break break
case PERMISSION_NO_VERIFICATION_REQUIRED: case PERMISSION_NO_VERIFICATION_REQUIRED:
void message.warning('账户已验证') void message.warning('账户已验证')
navigate('/') navigate('/repository')
break break
default: default:
void message.error('出错了,请稍后重试') void message.error('出错了,请稍后重试')
@@ -128,11 +128,7 @@ const Verify = () => {
setTimeout(() => { setTimeout(() => {
void requestUserInfo().then(() => { void requestUserInfo().then(() => {
refreshRouter() refreshRouter()
if (searchParams.has('redirect')) { navigate(searchParams.get('redirect') ?? '/repository')
navigate(searchParams.get('redirect') ?? '/')
} else {
navigate('/')
}
}) })
}, 1500) }, 1500)
break break

View File

@@ -62,7 +62,7 @@ const Code = () => {
case DATABASE_NO_RECORD_FOUND: case DATABASE_NO_RECORD_FOUND:
void message.error('未找到指定工具') void message.error('未找到指定工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:

View File

@@ -51,7 +51,7 @@ const Execute = () => {
case DATABASE_NO_RECORD_FOUND: case DATABASE_NO_RECORD_FOUND:
void message.error('未找到指定工具') void message.error('未找到指定工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/system/tools')
}, 3000) }, 3000)
break break
default: default:

View File

@@ -118,13 +118,13 @@ const Edit = () => {
case TOOL_UNDER_REVIEW: case TOOL_UNDER_REVIEW:
void message.error('保存失败:工具审核中') void message.error('保存失败:工具审核中')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
case TOOL_HAS_BEEN_PUBLISHED: case TOOL_HAS_BEEN_PUBLISHED:
void message.error('保存失败:工具已发布') void message.error('保存失败:工具已发布')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
@@ -184,13 +184,13 @@ const Edit = () => {
case TOOL_UNDER_REVIEW: case TOOL_UNDER_REVIEW:
void message.error('保存失败:工具审核中') void message.error('保存失败:工具审核中')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
case TOOL_HAS_BEEN_PUBLISHED: case TOOL_HAS_BEEN_PUBLISHED:
void message.error('保存失败:工具已发布') void message.error('保存失败:工具已发布')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
@@ -245,20 +245,20 @@ const Edit = () => {
case 'PROCESSING': case 'PROCESSING':
void message.warning('工具审核中,请勿修改') void message.warning('工具审核中,请勿修改')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
void message.warning('请先创建新版本后编辑工具') void message.warning('请先创建新版本后编辑工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
} }
break break
case DATABASE_NO_RECORD_FOUND: case DATABASE_NO_RECORD_FOUND:
void message.error('未找到指定工具') void message.error('未找到指定工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
@@ -322,7 +322,7 @@ const Edit = () => {
useEffect(() => { useEffect(() => {
if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) { if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) {
navigate('/') navigate('/repository')
return return
} }
getTool() getTool()

View File

@@ -49,7 +49,7 @@ const Source = () => {
case DATABASE_NO_RECORD_FOUND: case DATABASE_NO_RECORD_FOUND:
void message.error('未找到指定工具') void message.error('未找到指定工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
@@ -65,7 +65,7 @@ const Source = () => {
useEffect(() => { useEffect(() => {
if (username === '!' && !getLoginStatus()) { if (username === '!' && !getLoginStatus()) {
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
return return
} }
@@ -78,7 +78,7 @@ const Source = () => {
return return
} }
if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) { if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) {
navigate('/') navigate('/repository')
return return
} }
getTool() getTool()

View File

@@ -72,7 +72,7 @@ const View = () => {
case DATABASE_NO_RECORD_FOUND: case DATABASE_NO_RECORD_FOUND:
void message.error('未找到指定工具') void message.error('未找到指定工具')
setTimeout(() => { setTimeout(() => {
navigate('/') navigate('/repository')
}, 3000) }, 3000)
break break
default: default:
@@ -101,7 +101,7 @@ const View = () => {
return return
} }
if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) { if (!['WEB', 'DESKTOP', 'ANDROID'].includes(searchParams.get('platform')!)) {
navigate('/') navigate('/repository')
return return
} }
getTool() getTool()

View File

@@ -13,13 +13,13 @@ const ToolsFramework = () => {
<Sidebar.ItemList> <Sidebar.ItemList>
<Sidebar.Item <Sidebar.Item
end end
path={'/'} path={'/store'}
icon={tools[0].icon} icon={tools[0].icon}
text={tools[0].name} text={tools[0].name}
/> />
<Sidebar.Item <Sidebar.Item
end end
path={'/store'} path={'/repository'}
icon={tools[1].icon} icon={tools[1].icon}
text={tools[1].name} text={tools[1].name}
/> />
@@ -29,8 +29,8 @@ const ToolsFramework = () => {
<Sidebar.ItemList> <Sidebar.ItemList>
{tools.map((tool) => { {tools.map((tool) => {
return tool.menu && return tool.menu &&
tool.id !== 'tools' && tool.id !== 'tools-store' &&
tool.id !== 'tools-store' ? ( tool.id !== 'tools-repository' ? (
<Sidebar.Item <Sidebar.Item
path={tool.absolutePath} path={tool.absolutePath}
icon={tool.icon} icon={tool.icon}

View File

@@ -1,14 +1,4 @@
export const tools: RouteJsonObject[] = [ export const tools: RouteJsonObject[] = [
{
path: '',
absolutePath: '/',
id: 'tools',
component: lazy(() => import('@/pages/Tools')),
name: '主页',
icon: lazy(() => import('~icons/oxygen/home')),
menu: true,
auth: false
},
{ {
path: 'store', path: 'store',
absolutePath: '/store', absolutePath: '/store',
@@ -19,6 +9,21 @@ export const tools: RouteJsonObject[] = [
icon: lazy(() => import('~icons/oxygen/store')), icon: lazy(() => import('~icons/oxygen/store')),
menu: true menu: true
}, },
{
path: 'repository',
absolutePath: '/repository',
id: 'tools-repository',
component: lazy(() => import('@/pages/Tools')),
name: '个人仓库',
titlePostfix: ' - 仓库',
icon: lazy(() => import('~icons/oxygen/home')),
menu: true
},
{
path: '',
absolutePath: '/',
element: <Navigate to="/store" replace />
},
{ {
path: 'store/:username', path: 'store/:username',
absolutePath: '/store', absolutePath: '/store',
@@ -34,7 +39,6 @@ export const tools: RouteJsonObject[] = [
name: '创建工具', name: '创建工具',
titlePostfix: ' - 创建新工具', titlePostfix: ' - 创建新工具',
icon: lazy(() => import('~icons/oxygen/newProject')), icon: lazy(() => import('~icons/oxygen/newProject')),
menu: false,
auth: true auth: true
}, },
{ {