feat: use ipc provider when client app's preload script inject the global flag.

This commit is contained in:
Lin Onetwo 2023-01-05 20:47:10 +08:00
parent c83537aac6
commit b9c0669a15
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import { getApis, Apis } from './apis/index.js';
import { AffineProvider, BaseProvider } from './provider/index.js';
import { LocalProvider } from './provider/index.js';
import { getKVConfigure } from './store.js';
import { TauriIPCProvider } from './provider/tauri-ipc/index.js';
// load workspace's config
type LoadConfig = {
@ -43,6 +44,10 @@ export class DataCenter {
const dc = new DataCenter(debug);
dc.addProvider(AffineProvider);
dc.addProvider(LocalProvider);
// use ipc provider when client app's preload script inject the global flag.
if (typeof window !== 'undefined' && window.CLIENT_APP) {
dc.addProvider(TauriIPCProvider);
}
return dc;
}

View File

@ -0,0 +1,8 @@
declare global {
interface Window {
CLIENT_APP?: boolean;
__editoVersion?: string;
}
}
export {};