mirror of
https://github.com/A-Star100/simpliplay-desktop.git
synced 2025-09-17 22:29:38 +00:00
Update main.js
This commit is contained in:
parent
e5c2badb8d
commit
daead7a5f7
@ -185,6 +185,12 @@ app.whenReady().then(() => {
|
|||||||
createWindow();
|
createWindow();
|
||||||
setupMenu();
|
setupMenu();
|
||||||
|
|
||||||
|
// Handle file opening from command-line arguments (Windows/Linux)
|
||||||
|
const args = process.argv.slice(1); // Skip the first argument (app path)
|
||||||
|
const fileArg = args.find(arg => !arg.startsWith('-') && !arg.includes('electron'));
|
||||||
|
|
||||||
|
if (fileArg) openFileSafely(fileArg);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.on("focus", () => {
|
mainWindow.on("focus", () => {
|
||||||
@ -195,9 +201,10 @@ app.whenReady().then(() => {
|
|||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
// Handle file opening from Finder (macOS)
|
||||||
app.on("open-file", (event, filePath) => {
|
app.on("open-file", (event, filePath) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
openFile(filePath);
|
openFileSafely(filePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("activate", () => {
|
app.on("activate", () => {
|
||||||
@ -205,6 +212,16 @@ app.whenReady().then(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let hasOpenedFile = false;
|
||||||
|
|
||||||
|
function openFileSafely(filePath) {
|
||||||
|
if (!hasOpenedFile) {
|
||||||
|
hasOpenedFile = true;
|
||||||
|
openFile(filePath);
|
||||||
|
setTimeout(() => hasOpenedFile = false, 1000); // Reset after 1 sec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregisterAll();
|
||||||
|
Loading…
Reference in New Issue
Block a user