feat: init window.affine (#2682)

This commit is contained in:
Himself65
2023-06-06 11:43:34 +08:00
committed by GitHub
parent d00d0bd951
commit 8f6db00402
5 changed files with 155 additions and 20 deletions

View File

@@ -9,3 +9,26 @@ if (config.enablePlugin && !environment.isServer) {
if (!environment.isServer) {
import('@affine/bookmark-block');
}
if (!environment.isDesktop && !environment.isServer) {
// Polyfill Electron
const unimplemented = () => {
throw new Error('AFFiNE Plugin Web will be supported in the future');
};
const affine = {
ipcRenderer: {
invoke: unimplemented,
send: unimplemented,
on: unimplemented,
once: unimplemented,
removeListener: unimplemented,
},
};
Object.freeze(affine);
Object.defineProperty(window, 'affine', {
value: affine,
writable: false,
});
}