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

Function initializeAccountSystem

src/renderer/src/services/accountService.ts:22–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20
21// 初始化账户系统
22export async function initializeAccountSystem(): Promise<void> {
23 const { account } = stores
24
25 // 初始化持久化层(确保 appDataPath 已初始化)
26 await persistence.database.init()
27
28 // 初始化账户 store
29 await account.init()
30
31 // 如果没有账户,创建默认账户
32 if (account.accounts.length === 0) {
33 const defaultAccount = createDefaultAccount()
34 await account.create({
35 id: defaultAccount.id,
36 name: defaultAccount.name,
37 avatar: defaultAccount.avatar
38 })
39 await account.setCurrentAccountId(defaultAccount.id)
40 }
41
42 // 如果没有当前账户,设置为第一个账户
43 if (!account.currentAccountId && account.accounts.length > 0) {
44 await account.setCurrentAccountId(account.accounts[0].id)
45 }
46
47 // 设置当前账户路径
48 const accountId = account.currentAccountId || getDefaultAccountId()
49 await persistence.database.commitContext({
50 accountId,
51 workspacePath: null
52 })
53
54 // 初始化账户级 stores
55 await initAccountStores()
56
57 // 初始化工作区系统
58 await initializeWorkspaceSystem()
59
60 account.setInitialized(true)
61}
62
63// 切换账户
64export async function switchAccount(accountId: string): Promise<void> {

Callers 1

AppContentFunction · 0.90

Calls 9

createDefaultAccountFunction · 0.90
getDefaultAccountIdFunction · 0.90
initAccountStoresFunction · 0.85
createMethod · 0.80
commitContextMethod · 0.80
setInitializedMethod · 0.80
initMethod · 0.65
setCurrentAccountIdMethod · 0.65

Tested by

no test coverage detected