mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 16:16:46 +08:00
104c21d84c
@affine/workspace -> (@affine/workspace, @affine/workspace-impl)
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { WorkspaceList, WorkspaceManager } from '@affine/workspace';
|
|
|
|
import {
|
|
cloudWorkspaceFactory,
|
|
createCloudWorkspaceListProvider,
|
|
} from './cloud';
|
|
import {
|
|
createLocalWorkspaceListProvider,
|
|
LOCAL_WORKSPACE_LOCAL_STORAGE_KEY,
|
|
localWorkspaceFactory,
|
|
} from './local';
|
|
|
|
const list = new WorkspaceList([
|
|
createLocalWorkspaceListProvider(),
|
|
createCloudWorkspaceListProvider(),
|
|
]);
|
|
|
|
export const workspaceManager = new WorkspaceManager(list, [
|
|
localWorkspaceFactory,
|
|
cloudWorkspaceFactory,
|
|
]);
|
|
|
|
(window as any).workspaceManager = workspaceManager;
|
|
|
|
export * from './cloud';
|
|
export * from './local';
|
|
|
|
/**
|
|
* a hack for directly add local workspace to workspace list
|
|
* Used after copying sqlite database file to appdata folder
|
|
*/
|
|
export function _addLocalWorkspace(id: string) {
|
|
const allWorkspaceIDs: string[] = JSON.parse(
|
|
localStorage.getItem(LOCAL_WORKSPACE_LOCAL_STORAGE_KEY) ?? '[]'
|
|
);
|
|
allWorkspaceIDs.push(id);
|
|
localStorage.setItem(
|
|
LOCAL_WORKSPACE_LOCAL_STORAGE_KEY,
|
|
JSON.stringify(allWorkspaceIDs)
|
|
);
|
|
}
|