MCPcopy Create free account
hub / github.com/experdot/pointer / initializeWorkspaceSystem

Function initializeWorkspaceSystem

src/renderer/src/services/workspaceService.ts:74–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72 * 在账户初始化后调用
73 */
74export async function initializeWorkspaceSystem(): Promise<void> {
75 const { workspace } = stores
76
77 // 初始化工作区 store
78 await workspace.init()
79
80 // 如果没有工作区,创建默认工作区
81 if (workspace.workspaces.length === 0) {
82 const defaultWorkspace = await workspace.initDefaultWorkspace()
83 await workspace.setCurrentWorkspaceId(defaultWorkspace.id)
84 }
85
86 // 如果没有当前工作区,设置为第一个工作区
87 if (!workspace.currentWorkspaceId && workspace.workspaces.length > 0) {
88 await workspace.setCurrentWorkspaceId(workspace.workspaces[0].id)
89 }
90
91 if (workspace.currentWorkspace) {
92 await commitWorkspaceContext(workspace.currentWorkspace.accountId, workspace.currentWorkspace.path)
93 } else {
94 const accountId = persistence.database.getActiveContext().accountId
95 if (!accountId) {
96 throw new Error('No active account context')
97 }
98 await commitWorkspaceContext(accountId, null)
99 }
100 await cleanupWorkspaceTempAttachments()
101
102 // 初始化工作区级 stores
103 await initWorkspaceStores()
104}
105
106// ==================== 工作区切换 ====================
107

Callers 2

initializeAccountSystemFunction · 0.90
switchAccountFunction · 0.90

Calls 7

commitWorkspaceContextFunction · 0.85
initWorkspaceStoresFunction · 0.85
getActiveContextMethod · 0.80
initMethod · 0.65
initDefaultWorkspaceMethod · 0.65
setCurrentWorkspaceIdMethod · 0.65

Tested by

no test coverage detected