Translation and Bugfix

This commit is contained in:
sguenter 2024-02-16 09:56:06 +01:00
parent a634fb2a95
commit 9677d0c3e8
6 changed files with 38 additions and 15 deletions

View File

@ -132,8 +132,7 @@ export class ElectronCapacitorApp {
}, },
}); });
this.mainWindowState.manage(this.MainWindow); this.mainWindowState.manage(this.MainWindow);
this.MainWindow.webContents.postMessage("port", null, [this.channels.port1]); Actions.setMainWindow(this.MainWindow);
Actions.setVideoWindowPort(this.channels.port2);
if (this.CapacitorFileConfig.backgroundColor) { if (this.CapacitorFileConfig.backgroundColor) {
this.MainWindow.setBackgroundColor(this.CapacitorFileConfig.electron.backgroundColor); this.MainWindow.setBackgroundColor(this.CapacitorFileConfig.electron.backgroundColor);

View File

@ -1,5 +1,15 @@
{ {
"app": { "app": {
"title": "Easy Youtube" "title": "Easy Youtube"
} },
"form.bottom": "Abstand Unten",
"form.id": "Video-ID/Link",
"form.left": "Abstand Links",
"form.mute": "Stumm",
"form.right": "Abstand Rechts",
"form.tilt": "Trapez-Korrektur",
"form.top": "Abstand Oben",
"window.close": "Video schließen",
"window.fullscreen": "Vollbild",
"window.open": "Video öffnen"
} }

View File

@ -1,5 +1,15 @@
{ {
"app": { "app": {
"title": "Easy Youtube" "title": "Easy Youtube"
} },
"form.bottom": "Space Bottom",
"form.id": "Video-ID/Link",
"form.left": "Space Left",
"form.mute": "Mute",
"form.right": "Space Right",
"form.tilt": "Tilt",
"form.top": "Space Top",
"window.close": "Close Video",
"window.fullscreen": "Fullscreen",
"window.open": "Open Video"
} }

View File

@ -14,7 +14,7 @@
"eslint:fix": "npm run eslint -- --fix", "eslint:fix": "npm run eslint -- --fix",
"postinstall": "patch-package && cd electron && npm install && cd ..", "postinstall": "patch-package && cd electron && npm install && cd ..",
"electron:prepare": "cp -f src/electron/Actions.ts src/electron/Bridge.ts electron/src/ && bin/export.sh", "electron:prepare": "cp -f src/electron/Actions.ts src/electron/Bridge.ts electron/src/ && bin/export.sh",
"electron": "npm run electron:prepare && cap sync @capacitor-community/electron && cap open @capacitor-community/electron", "electron": "export ELECTRON_ENABLE_LOGGING=1 && npm run electron:prepare && cap sync @capacitor-community/electron && cd electron && npm run electron:start",
"electron:copy": "npm run electron:prepare && cap copy @capacitor-community/electron", "electron:copy": "npm run electron:prepare && cap copy @capacitor-community/electron",
"electron:pack": "npm run electron:prepare && cap copy @capacitor-community/electron && cd electron && npm run electron:pack && cd .." "electron:pack": "npm run electron:prepare && cap copy @capacitor-community/electron && cd electron && npm run electron:pack && cd .."
}, },

View File

@ -1,17 +1,16 @@
import { BrowserWindow, app } from "electron"; import { BrowserWindow, MessageChannelMain, app } from "electron";
import { join } from "path"; import { join } from "path";
import type { MessagePortMain } from "electron";
let videoWindow: BrowserWindow | undefined; let videoWindow: BrowserWindow | undefined;
let isDev = false; let isDev = false;
let videoWindowPort: MessagePortMain | undefined; let mainWindow: BrowserWindow | undefined;
export const Actions = { export const Actions = {
setIsDev(newIsDev: boolean) { setIsDev(newIsDev: boolean) {
isDev = newIsDev; isDev = newIsDev;
}, },
setVideoWindowPort(port: MessagePortMain) { setMainWindow(newMainWindow: BrowserWindow) {
videoWindowPort = port; mainWindow = newMainWindow;
}, },
startNewWindow: async (videoId: string) => { startNewWindow: async (videoId: string) => {
const preloadPath = join(app.getAppPath(), 'build', 'src', 'preload.js'); const preloadPath = join(app.getAppPath(), 'build', 'src', 'preload.js');
@ -20,6 +19,7 @@ export const Actions = {
try { try {
videoWindow.close(); videoWindow.close();
} catch (e) { } catch (e) {
console.error(e);
} }
} }
@ -36,16 +36,18 @@ export const Actions = {
} }
await videoWindow.loadURL(`capacitor-electron://app/fullscreen.html?id=${videoId}`); await videoWindow.loadURL(`capacitor-electron://app/fullscreen.html?id=${videoId}`);
if (videoWindowPort) { if (mainWindow) {
videoWindow.webContents.postMessage("port", null, [videoWindowPort]); const newChannel = new MessageChannelMain();
mainWindow.webContents.postMessage("port", null, [newChannel.port1]);
videoWindow.webContents.postMessage("port", null, [newChannel.port2]);
} }
}, },
closeVideoWindow() { closeVideoWindow() {
if (videoWindow) { if (videoWindow) {
try { try {
videoWindow.close(); videoWindow.close();
} catch (e) { } catch (e) {
console.error(e);
} }
videoWindow = undefined; videoWindow = undefined;
} }

View File

@ -51,7 +51,7 @@ function Index(_: IndexProps) {
Actions.startNewWindow(id); Actions.startNewWindow(id);
Bridge.send("dimensions", dimension); Bridge.send("dimensions", dimension);
Bridge.send("tilt", tilt); Bridge.send("tilt", tilt);
}, [dimension, id]); }, [dimension, id, tilt]);
const closeWindow = useCallback(() => { const closeWindow = useCallback(() => {
Actions.closeVideoWindow(); Actions.closeVideoWindow();
@ -210,6 +210,7 @@ function Index(_: IndexProps) {
<Input value={dimension.left} onChangeText={updateLeft} label={t("form.left")} type="number"/> <Input value={dimension.left} onChangeText={updateLeft} label={t("form.left")} type="number"/>
</GridItem> </GridItem>
<GridItem size={4}> <GridItem size={4}>
<Text>{t("form.tilt")}</Text>
<Flex horizontal={true}> <Flex horizontal={true}>
<Grow> <Grow>
<Slider value={tilt} onChangeValue={updateTilt} step={1} min={-90} max={90}/> <Slider value={tilt} onChangeValue={updateTilt} step={1} min={-90} max={90}/>
@ -249,7 +250,8 @@ function Index(_: IndexProps) {
<Grow> <Grow>
<Slider value={currentTime} onChangeValue={updateLocalCurrentTime} step={1} <Slider value={currentTime} onChangeValue={updateLocalCurrentTime} step={1}
min={Math.min(duration, 1)} min={Math.min(duration, 1)}
max={duration}/> max={duration}
/>
</Grow> </Grow>
<Input value={parsableTime} onChangeText={updateLocalParsableTime} onChangeDone={parseTime} <Input value={parsableTime} onChangeText={updateLocalParsableTime} onChangeDone={parseTime}
className={styles.timeInput}/> className={styles.timeInput}/>