(workspaceId: string)
| 109 | * 切换工作区 |
| 110 | */ |
| 111 | export async function switchWorkspace(workspaceId: string): Promise<void> { |
| 112 | const { workspace } = stores |
| 113 | |
| 114 | // 验证工作区存在 |
| 115 | const targetWorkspace = await workspace.getById(workspaceId) |
| 116 | if (!targetWorkspace) { |
| 117 | throw new Error(`Workspace not found: ${workspaceId}`) |
| 118 | } |
| 119 | |
| 120 | await runSwitchTransaction('workspace', targetWorkspace.name, async () => { |
| 121 | await workspace.setCurrentWorkspaceId(workspaceId) |
| 122 | await commitWorkspaceContext(targetWorkspace.accountId, targetWorkspace.path) |
| 123 | await cleanupWorkspaceTempAttachments() |
| 124 | resetWorkspaceStores() |
| 125 | await initWorkspaceStores() |
| 126 | }) |
| 127 | } |
| 128 | |
| 129 | // ==================== 自定义工作区 ==================== |
| 130 |
no test coverage detected