fix(web): allow workbench without projects

This commit is contained in:
2026-07-24 10:33:46 +08:00
parent 9900235eaa
commit fd8a2110a1
4 changed files with 20 additions and 15 deletions

View File

@@ -123,7 +123,7 @@ function App() {
}, [session, workspaces])
const dark = theme === 'dark'
const activeWorkspace = workspaces.find((workspace) => workspace.project.id === activeProjectID) ?? workspaces[0]
const activeWorkspace = workspaces.find((workspace) => workspace.project.id === activeProjectID)
const activeTagOptions = activeWorkspace?.tags.filter((tag) => tag !== 'all' && tag !== '全部') ?? []
function selectActiveProject(projectID: string) {
@@ -142,7 +142,7 @@ function App() {
const requestedProjectID = latestProjectID !== projectIDWhenStarted
? latestProjectID
: preferredProjectID ?? latestProjectID
const nextProjectID = backendWorkspaces.find((workspace) => workspace.project.id === requestedProjectID)?.project.id ?? backendWorkspaces[0]?.project.id ?? ''
const nextProjectID = backendWorkspaces.find((workspace) => workspace.project.id === requestedProjectID)?.project.id ?? ''
selectActiveProject(nextProjectID)
return backendWorkspaces
}
@@ -152,9 +152,9 @@ function App() {
try {
setApiBaseUrl(input.server)
const nextSession = await login(input.email, input.password)
const backendWorkspaces = await loadWorkspaces(nextSession, '')
await loadWorkspaces(nextSession, '')
setSession(nextSession)
selectActiveProject(backendWorkspaces[0]?.project.id ?? '')
selectActiveProject('')
setActiveChannel('overview')
setActiveView('workspace')
setScreen('workbench')
@@ -385,7 +385,7 @@ function App() {
<Spin loading={loading} style={{ width: '100%' }}>
<LoginPage onLogin={handleLogin} />
</Spin>
) : activeWorkspace && session ? (
) : session ? (
<ProjectPage
activeView={activeView}
activeWorkspace={activeWorkspace}