6 Commits

Author SHA1 Message Date
Vendicated
a12ba017bc bump to 0.1.8 2023-04-15 20:24:09 +02:00
Vendicated
7a2161d746 Make IS_DEV force new instance 2023-04-15 20:23:47 +02:00
Vendicated
d0e7a319d6 Spoof UserAgent as browser. Fixes VCs????? 2023-04-15 20:13:18 +02:00
Vendicated
4afafa5038 bump 2023-04-15 12:38:17 +02:00
Ryan Cao
583680d311 feat: reuse built-in menus in system menubar (#12)
* fix: add edit menu on macOS to allow clipboard actions

* feat: reuse more built-in menus

* re-add zoom shortcut fix

---------

Co-authored-by: V <vendicated@riseup.net>
2023-04-15 10:37:52 +00:00
Vendicated
70dd38f79d make spellcheck use all system locales 2023-04-14 04:05:56 +02:00
7 changed files with 49 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "VencordDesktop",
"version": "0.1.6",
"version": "0.1.8",
"private": true,
"description": "",
"keywords": [],

View File

@@ -28,12 +28,10 @@ const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDeskto
let mainWin: BrowserWindow | null = null;
if (!app.requestSingleInstanceLock()) {
console.log("Vencord Desktop is already running. Quitting...");
app.quit();
} else {
app.on("second-instance", () => {
if (mainWin) {
function init() {
app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => {
if (data.IS_DEV) app.quit();
else if (mainWin) {
if (mainWin.isMinimized()) mainWin.restore();
if (!mainWin.isVisible()) mainWin.show();
mainWin.focus();
@@ -53,6 +51,18 @@ if (!app.requestSingleInstanceLock()) {
});
}
if (!app.requestSingleInstanceLock({ IS_DEV })) {
if (IS_DEV) {
console.log("Vencord Desktop is already running. Quitting previous instance...");
init();
} else {
console.log("Vencord Desktop is already running. Quitting...");
app.quit();
}
} else {
init();
}
async function createWindows() {
const splash = createSplashWindow();

View File

@@ -4,7 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
import { app, dialog, ipcMain, shell } from "electron";
import { app, dialog, ipcMain, session, shell } from "electron";
import { existsSync, readFileSync, watch } from "fs";
import { open, readFile } from "fs/promises";
import { join } from "path";
@@ -60,6 +60,14 @@ ipcMain.handle(IpcEvents.CLOSE, e => {
e.sender.close();
});
ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
const ses = session.defaultSession;
const available = ses.availableSpellCheckerLanguages;
const applicable = languages.filter(l => available.includes(l)).slice(0, 3);
if (applicable.length) ses.setSpellCheckerLanguages(applicable);
});
ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
const res = await dialog.showOpenDialog(mainWin!, {
properties: ["openDirectory"]

View File

@@ -84,9 +84,11 @@ function initMenuBar(win: BrowserWindow) {
const menu = Menu.buildFromTemplate([
{
label: "Vencord Desktop",
role: "appMenu",
submenu: [
{
label: "About Vencord Desktop",
role: "about",
click: createAboutWindow
},
{
@@ -98,28 +100,6 @@ function initMenuBar(win: BrowserWindow) {
},
toolTip: "Vencord Desktop will automatically restart after this operation"
},
{
label: "Toggle Developer Tools",
accelerator: "CmdOrCtrl+Shift+I",
click() {
BrowserWindow.getFocusedWindow()!.webContents.toggleDevTools();
}
},
{
label: "Toggle Developer Tools (Hidden)",
accelerator: "F12",
visible: false,
click() {
BrowserWindow.getFocusedWindow()!.webContents.toggleDevTools();
}
},
{
label: "Reload Window",
accelerator: "CmdOrCtrl+R",
click() {
BrowserWindow.getFocusedWindow()!.webContents.reload();
}
},
{
label: "Relaunch",
accelerator: "CmdOrCtrl+Shift+R",
@@ -132,6 +112,7 @@ function initMenuBar(win: BrowserWindow) {
label: "Quit",
accelerator: wantCtrlQ ? "CmdOrCtrl+Q" : void 0,
visible: !isWindows,
role: "quit",
click() {
app.quit();
}
@@ -140,34 +121,28 @@ function initMenuBar(win: BrowserWindow) {
label: "Quit",
accelerator: isWindows ? "Alt+F4" : void 0,
visible: isWindows,
role: "quit",
click() {
app.quit();
}
}
]
},
{ role: "fileMenu" },
{ role: "editMenu" },
{ role: "viewMenu" },
{ role: "windowMenu" },
{
label: "Zoom",
submenu: [
{
label: "Zoom in",
accelerator: "CmdOrCtrl+Plus",
role: "zoomIn"
},
// Fix for zoom in on keyboards with dedicated + like QWERTZ (or numpad)
// See https://github.com/electron/electron/issues/14742 and https://github.com/electron/electron/issues/5256
{
label: "Zoom in",
accelerator: "CmdOrCtrl+=",
role: "zoomIn",
visible: false
},
{
label: "Zoom out",
accelerator: "CmdOrCtrl+-",
role: "zoomOut"
role: "zoomIn"
}
]
],
visible: false
}
]);
@@ -281,6 +256,10 @@ export function createMainWindow() {
makeLinksOpenExternally(win);
initSettingsListeners(win);
win.webContents.setUserAgent(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
);
const subdomain =
Settings.store.discordBranch === "canary" || Settings.store.discordBranch === "ptb"
? `${Settings.store.discordBranch}.`

View File

@@ -23,6 +23,10 @@ export const VencordDesktopNative = {
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
set: (settings: Settings, path?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, path)
},
spellcheck: {
setLanguages: (languages: readonly string[]) => invoke<void>(IpcEvents.SPELLCHECK_SET_LANGUAGES, languages)
// todo: perhaps add ways to learn words
},
win: {
focus: () => invoke<void>(IpcEvents.FOCUS)
}

View File

@@ -39,5 +39,6 @@ if (IS_DEV) {
document.getElementById("vcd-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
});
}
// #endregion
VencordDesktopNative.spellcheck.setLanguages(window.navigator.languages);

View File

@@ -25,5 +25,7 @@ export const enum IpcEvents {
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
UPDATE_IGNORE = "VCD_UPDATE_IGNORE",
SPELLCHECK_SET_LANGUAGES = "VCD_SPELLCHECK_SET_LANGUAGES",
CLOSE = "VCD_CLOSE"
}