fix(web): fetch hello-world from local (#3062)

This commit is contained in:
Alex Yang
2023-07-06 17:46:17 +08:00
committed by GitHub
parent bda28e0404
commit e30c67482f
11 changed files with 36 additions and 8 deletions

View File

@@ -0,0 +1,26 @@
import type { BlobStorage } from '@blocksuite/store';
export const createStaticStorage = (): BlobStorage => {
return {
crud: {
get: async (key: string) => {
if (key.startsWith('/static/')) {
const response = await fetch(key);
return response.blob();
}
return null;
},
set: async (key: string) => {
// ignore
return key;
},
delete: async () => {
// ignore
},
list: async () => {
// ignore
return [];
},
},
};
};

View File

@@ -15,6 +15,7 @@ import { createIndexeddbStorage, Workspace } from '@blocksuite/store';
import { rootStore } from '@toeverything/plugin-infra/manager';
import { rootWorkspacesMetadataAtom } from './atom';
import { createStaticStorage } from './blob/local-static-storage';
import { createSQLiteStorage } from './blob/sqlite-blob-storage';
export function cleanupWorkspace(flavour: WorkspaceFlavour) {
@@ -98,6 +99,7 @@ export function createEmptyBlockSuiteWorkspace(
}
providerCreators.push(...createLocalProviders());
}
blobStorages.push(createStaticStorage);
const workspace = new Workspace({
id,