mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
chore: move client folders (#948)
This commit is contained in:
5
apps/desktop/src/preload/Readme.md
Normal file
5
apps/desktop/src/preload/Readme.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Preload Scripts
|
||||
|
||||
Here are preload scripts (See [tauri's doc](https://tauri.app/v1/references/architecture/inter-process-communication/isolation)). This is simillar to Electron's [preload script](https://www.electronjs.org/docs/latest/tutorial/sandbox#preload-scripts).
|
||||
|
||||
We pass env variables to AFFiNE side from here.
|
||||
18
apps/desktop/src/preload/index.ts
Normal file
18
apps/desktop/src/preload/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
|
||||
// tauri preload script can't have `export {}`
|
||||
// @ts-ignore 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.ts(1208)
|
||||
window.__TAURI_ISOLATION_HOOK__ = payload => {
|
||||
console.log('Tauri isolation hook', payload);
|
||||
|
||||
return payload;
|
||||
};
|
||||
|
||||
/**
|
||||
* Give AFFiNE app code some env to know it is inside a tauri app.
|
||||
*/
|
||||
function setEnvironmentVariables() {
|
||||
window.CLIENT_APP = true;
|
||||
}
|
||||
|
||||
setEnvironmentVariables();
|
||||
8
apps/desktop/src/preload/type.ts
Normal file
8
apps/desktop/src/preload/type.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
CLIENT_APP?: boolean;
|
||||
__editoVersion?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
Reference in New Issue
Block a user