-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create simple router to make svelte happy use vite to build electron stuff specify target to simplify locale initialization
- Loading branch information
Showing
14 changed files
with
240 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ipcRenderer } from 'electron' | ||
|
||
export const electronAPI = { | ||
ipcRenderer: { | ||
send: (channel: string, ...args: any[]) => { | ||
ipcRenderer.send(channel, ...args) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { contextBridge } from 'electron' | ||
import { electronAPI } from './api.js'; | ||
|
||
if (process.contextIsolated) { | ||
try { | ||
contextBridge.exposeInMainWorld('electron', electronAPI); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} else { | ||
(window as any).electron = electronAPI; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,8 @@ | |
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"src/preload.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "Preserve", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": false | ||
}, | ||
"include": [ | ||
"src/preload.ts" | ||
], | ||
"exclude": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { electronAPI } from '../src-electron/src/api.js' | ||
|
||
declare global { | ||
interface Window { | ||
electron: typeof electronAPI; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export async function openWindow(options: { url: string, title: string }) { | ||
if (window.electron) { | ||
window.electron.ipcRenderer.send("window/create", options); | ||
return; | ||
} | ||
|
||
const tauri = await import("@tauri-apps/api/webviewWindow"); | ||
const settingsWindow = new tauri.WebviewWindow("settings", options); | ||
|
||
settingsWindow.once("tauri://created", () => { | ||
console.log("Window created"); | ||
}); | ||
|
||
settingsWindow.once("tauri://error", async (err) => { | ||
console.log(err); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.