-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate from Tauri to Electron, refactor project files, and add…
… app setup components
- Loading branch information
Showing
145 changed files
with
5,272 additions
and
57,184 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
# Dester Desktop App | ||
# React + TypeScript + Vite | ||
|
||
***Coming Soon*** | ||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
``` | ||
|
||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
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,72 @@ | ||
import { ipcMain, dialog, app, BrowserWindow } from "electron"; | ||
import { fileURLToPath } from "node:url"; | ||
import path from "node:path"; | ||
import { exec } from "child_process"; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
process.env.APP_ROOT = path.join(__dirname, ".."); | ||
const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"]; | ||
const MAIN_DIST = path.join(process.env.APP_ROOT, "dist-electron"); | ||
const RENDERER_DIST = path.join(process.env.APP_ROOT, "dist"); | ||
process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, "public") : RENDERER_DIST; | ||
let win; | ||
ipcMain.on("open-vlc", () => { | ||
const videoPath = "/Users/alken/Desktop/dester/ffmpeg/video.mkv"; | ||
const vlcCommand = `"${path.join( | ||
"/Applications/VLC.app/Contents/MacOS/VLC" | ||
)}" "${videoPath}"`; | ||
exec(vlcCommand, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error opening VLC: ${error.message}`); | ||
return; | ||
} | ||
if (stderr) { | ||
console.error(`VLC stderr: ${stderr}`); | ||
return; | ||
} | ||
console.log(`VLC stdout: ${stdout}`); | ||
}); | ||
}); | ||
ipcMain.handle("select-folder", async () => { | ||
const result = await dialog.showOpenDialog({ | ||
properties: ["openDirectory"] | ||
}); | ||
return result; | ||
}); | ||
function createWindow() { | ||
win = new BrowserWindow({ | ||
titleBarStyle: "hidden", | ||
icon: path.join(__dirname, "path-to-your-icon", "electron-vite.svg"), | ||
webPreferences: { | ||
preload: path.join(__dirname, "preload.mjs") | ||
} | ||
}); | ||
win.webContents.on("did-finish-load", () => { | ||
win == null ? void 0 : win.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString()); | ||
}); | ||
win.webContents.openDevTools(); | ||
if (process.env.VITE_DEV_SERVER_URL) { | ||
win.loadURL(process.env.VITE_DEV_SERVER_URL); | ||
} else { | ||
win.loadFile(path.join(__dirname, "dist", "index.html")); | ||
} | ||
ipcMain.handle("check-fullscreen", () => { | ||
return win == null ? void 0 : win.isFullScreen(); | ||
}); | ||
} | ||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
win = null; | ||
} | ||
}); | ||
app.on("activate", () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
app.whenReady().then(createWindow); | ||
export { | ||
MAIN_DIST, | ||
RENDERER_DIST, | ||
VITE_DEV_SERVER_URL | ||
}; |
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,28 @@ | ||
"use strict"; | ||
const electron = require("electron"); | ||
electron.contextBridge.exposeInMainWorld("ipcRenderer", { | ||
on(...args) { | ||
const [channel, listener] = args; | ||
return electron.ipcRenderer.on( | ||
channel, | ||
(event, ...args2) => listener(event, ...args2) | ||
); | ||
}, | ||
off(...args) { | ||
const [channel, ...omit] = args; | ||
return electron.ipcRenderer.off(channel, ...omit); | ||
}, | ||
send(...args) { | ||
const [channel, ...omit] = args; | ||
return electron.ipcRenderer.send(channel, ...omit); | ||
}, | ||
invoke(...args) { | ||
const [channel, ...omit] = args; | ||
return electron.ipcRenderer.invoke(channel, ...omit); | ||
}, | ||
openVLC: () => electron.ipcRenderer.send("open-vlc"), | ||
isFullscreen: () => electron.ipcRenderer.invoke("check-fullscreen"), | ||
selectFolder: () => electron.ipcRenderer.invoke("select-folder") | ||
// You can expose other APTs you need here. | ||
// ... | ||
}); |
Oops, something went wrong.