Merge 337384324b into d008f90399
				
					
				
			This commit is contained in:
		
						commit
						d9c42967cb
					
				
					 6 changed files with 46 additions and 15 deletions
				
			
		|  | @ -71,6 +71,12 @@ | ||||||
|             "package.json", |             "package.json", | ||||||
|             "LICENSE" |             "LICENSE" | ||||||
|         ], |         ], | ||||||
|  |         "protocols": { | ||||||
|  |             "name": "Discord", | ||||||
|  |             "schemes": [ | ||||||
|  |                 "discord" | ||||||
|  |             ] | ||||||
|  |         }, | ||||||
|         "beforePack": "scripts/build/sandboxFix.js", |         "beforePack": "scripts/build/sandboxFix.js", | ||||||
|         "linux": { |         "linux": { | ||||||
|             "icon": "build/icon.icns", |             "icon": "build/icon.icns", | ||||||
|  | @ -111,7 +117,8 @@ | ||||||
|                 "GenericName": "Internet Messenger", |                 "GenericName": "Internet Messenger", | ||||||
|                 "Type": "Application", |                 "Type": "Application", | ||||||
|                 "Categories": "Network;InstantMessaging;Chat;", |                 "Categories": "Network;InstantMessaging;Chat;", | ||||||
|                 "Keywords": "discord;vencord;electron;chat;" |                 "Keywords": "discord;vencord;electron;chat;", | ||||||
|  |                 "MimeType": "x-scheme-handler/discord" | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|         "mac": { |         "mac": { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ import { autoUpdater } from "electron-updater"; | ||||||
| 
 | 
 | ||||||
| import { DATA_DIR } from "./constants"; | import { DATA_DIR } from "./constants"; | ||||||
| import { createFirstLaunchTour } from "./firstLaunch"; | import { createFirstLaunchTour } from "./firstLaunch"; | ||||||
| import { createWindows, mainWin } from "./mainWindow"; | import { createWindows, restoreVesktop } from "./mainWindow"; | ||||||
| import { registerMediaPermissionsHandler } from "./mediaPermissions"; | import { registerMediaPermissionsHandler } from "./mediaPermissions"; | ||||||
| import { registerScreenShareHandler } from "./screenShare"; | import { registerScreenShareHandler } from "./screenShare"; | ||||||
| import { Settings, State } from "./settings"; | import { Settings, State } from "./settings"; | ||||||
|  | @ -27,6 +27,8 @@ if (IS_DEV) { | ||||||
| process.env.VENCORD_USER_DATA_DIR = DATA_DIR; | process.env.VENCORD_USER_DATA_DIR = DATA_DIR; | ||||||
| 
 | 
 | ||||||
| function init() { | function init() { | ||||||
|  |     app.setAsDefaultProtocolClient("discord"); | ||||||
|  | 
 | ||||||
|     const { disableSmoothScroll, hardwareAcceleration } = Settings.store; |     const { disableSmoothScroll, hardwareAcceleration } = Settings.store; | ||||||
| 
 | 
 | ||||||
|     const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(","); |     const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(","); | ||||||
|  | @ -67,12 +69,7 @@ function init() { | ||||||
|     if (isDeckGameMode) nativeTheme.themeSource = "dark"; |     if (isDeckGameMode) nativeTheme.themeSource = "dark"; | ||||||
| 
 | 
 | ||||||
|     app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { |     app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { | ||||||
|         if (data.IS_DEV) app.quit(); |         data.IS_DEV ? app.quit() : restoreVesktop(); | ||||||
|         else if (mainWin) { |  | ||||||
|             if (mainWin.isMinimized()) mainWin.restore(); |  | ||||||
|             if (!mainWin.isVisible()) mainWin.show(); |  | ||||||
|             mainWin.focus(); |  | ||||||
|         } |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     app.whenReady().then(async () => { |     app.whenReady().then(async () => { | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ import { IpcEvents } from "../shared/IpcEvents"; | ||||||
| import { setBadgeCount } from "./appBadge"; | import { setBadgeCount } from "./appBadge"; | ||||||
| import { autoStart } from "./autoStart"; | import { autoStart } from "./autoStart"; | ||||||
| import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; | import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./constants"; | ||||||
| import { mainWin } from "./mainWindow"; | import { loadUrl, mainWin } from "./mainWindow"; | ||||||
| import { Settings, State } from "./settings"; | import { Settings, State } from "./settings"; | ||||||
| import { handle, handleSync } from "./utils/ipcWrappers"; | import { handle, handleSync } from "./utils/ipcWrappers"; | ||||||
| import { PopoutWindows } from "./utils/popout"; | import { PopoutWindows } from "./utils/popout"; | ||||||
|  | @ -135,6 +135,11 @@ handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | handle(IpcEvents.FOUROHFOUR_PAGE_HANDLER, _ => { | ||||||
|  |     loadUrl(undefined); | ||||||
|  |     console.warn("caught incomplete uri scheme. dumping to main app"); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| function readCss() { | function readCss() { | ||||||
|     return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => ""); |     return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => ""); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -455,18 +455,34 @@ function createMainWindow() { | ||||||
| 
 | 
 | ||||||
|     win.webContents.setUserAgent(BrowserUserAgent); |     win.webContents.setUserAgent(BrowserUserAgent); | ||||||
| 
 | 
 | ||||||
|     const subdomain = |     let uriFiredDarwin = false; | ||||||
|         Settings.store.discordBranch === "canary" || Settings.store.discordBranch === "ptb" |     app.on("open-url", (_, url) => { | ||||||
|             ? `${Settings.store.discordBranch}.` |         uriFiredDarwin ? restoreVesktop() : loadUrl(url); | ||||||
|             : ""; |         uriFiredDarwin = true; | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     win.loadURL(`https://${subdomain}discord.com/app`); |     const uri = process.argv.find(arg => arg.startsWith("discord://")); | ||||||
|  |     uriFiredDarwin || loadUrl(uri); | ||||||
| 
 | 
 | ||||||
|     return win; |     return win; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); | const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); | ||||||
| 
 | 
 | ||||||
|  | export function loadUrl(uri: string | undefined) { | ||||||
|  |     const branch = Settings.store.discordBranch; | ||||||
|  |     const subdomain = branch === "canary" || branch === "ptb" ? `${branch}.` : ""; | ||||||
|  |     mainWin.loadURL(`https://${subdomain}discord.com/${uri?.replace(RegExp("^discord://[^/]*/?"), "") || "app"}`); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export function restoreVesktop() { | ||||||
|  |     if (mainWin) { | ||||||
|  |         if (mainWin.isMinimized()) mainWin.restore(); | ||||||
|  |         if (!mainWin.isVisible()) mainWin.show(); | ||||||
|  |         mainWin.focus(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export async function createWindows() { | export async function createWindows() { | ||||||
|     const startMinimized = process.argv.includes("--start-minimized"); |     const startMinimized = process.argv.includes("--start-minimized"); | ||||||
|     const splash = createSplashWindow(startMinimized); |     const splash = createSplashWindow(startMinimized); | ||||||
|  |  | ||||||
|  | @ -24,6 +24,10 @@ const style = document.createElement("style"); | ||||||
| style.id = "vcd-css-core"; | style.id = "vcd-css-core"; | ||||||
| style.textContent = readFileSync(rendererCss, "utf-8"); | style.textContent = readFileSync(rendererCss, "utf-8"); | ||||||
| 
 | 
 | ||||||
|  | document.addEventListener("DOMContentLoaded", () => { | ||||||
|  |     if (document.title === "Page Not Found | Discord") ipcRenderer.invoke(IpcEvents.FOUROHFOUR_PAGE_HANDLER); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| if (document.readyState === "complete") { | if (document.readyState === "complete") { | ||||||
|     document.documentElement.appendChild(style); |     document.documentElement.appendChild(style); | ||||||
| } else { | } else { | ||||||
|  |  | ||||||
|  | @ -50,5 +50,7 @@ export const enum IpcEvents { | ||||||
| 
 | 
 | ||||||
|     ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY", |     ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY", | ||||||
| 
 | 
 | ||||||
|     CLIPBOARD_COPY_IMAGE = "VCD_CLIPBOARD_COPY_IMAGE" |     CLIPBOARD_COPY_IMAGE = "VCD_CLIPBOARD_COPY_IMAGE", | ||||||
|  | 
 | ||||||
|  |     FOUROHFOUR_PAGE_HANDLER = "VCD_404_PAGE_HANDLER" | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Cookie
						Cookie