(accountId: string)
| 62 | |
| 63 | // 切换账户 |
| 64 | export async function switchAccount(accountId: string): Promise<void> { |
| 65 | const { account } = stores |
| 66 | |
| 67 | // 验证账户存在 |
| 68 | const targetAccount = account.getById(accountId) |
| 69 | if (!targetAccount) { |
| 70 | throw new Error(`Account not found: ${accountId}`) |
| 71 | } |
| 72 | |
| 73 | await runSwitchTransaction('account', targetAccount.name, async () => { |
| 74 | await account.setCurrentAccountId(accountId) |
| 75 | await persistence.database.commitContext({ |
| 76 | accountId, |
| 77 | workspacePath: null |
| 78 | }) |
| 79 | resetWorkspaceSystem() |
| 80 | resetAccountStores() |
| 81 | await initAccountStores() |
| 82 | await initializeWorkspaceSystem() |
| 83 | }) |
| 84 | } |
| 85 | |
| 86 | // 创建新账户 |
| 87 | export async function createAccount(name: string, avatar?: string): Promise<Account> { |
no test coverage detected