feat: init window.affine (#2682)

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

No files matched your search

+23
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,
});
}