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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,4 @@
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',
absolutePath: '/store',
@@ -19,6 +9,21 @@ export const tools: RouteJsonObject[] = [
icon: lazy(() => import('~icons/oxygen/store')),
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',
absolutePath: '/store',
@@ -34,7 +39,6 @@ export const tools: RouteJsonObject[] = [
name: '创建工具',
titlePostfix: ' - 创建新工具',
icon: lazy(() => import('~icons/oxygen/newProject')),
menu: false,
auth: true
},
{