Merge branch 'main' into main
This commit is contained in:
		
						commit
						dbf58a24ee
					
				
					 5 changed files with 31 additions and 20 deletions
				
			
		|  | @ -5,11 +5,22 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import { app } from "electron"; | import { app } from "electron"; | ||||||
| import { existsSync, readdirSync, renameSync, rmdirSync } from "fs"; | import { existsSync, mkdirSync, readdirSync, renameSync, rmdirSync } from "fs"; | ||||||
| import { join } from "path"; | import { dirname, join } from "path"; | ||||||
|  | 
 | ||||||
|  | const vesktopDir = dirname(process.execPath); | ||||||
|  | 
 | ||||||
|  | export const PORTABLE = | ||||||
|  |     process.platform === "win32" && | ||||||
|  |     !process.execPath.toLowerCase().endsWith("electron.exe") && | ||||||
|  |     !existsSync(join(vesktopDir, "Uninstall Vesktop.exe")); | ||||||
| 
 | 
 | ||||||
| const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop"); | const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop"); | ||||||
| export const DATA_DIR = process.env.VENCORD_USER_DATA_DIR || join(app.getPath("userData")); | export const DATA_DIR = | ||||||
|  |     process.env.VENCORD_USER_DATA_DIR || (PORTABLE ? join(vesktopDir, "Data") : join(app.getPath("userData"))); | ||||||
|  | 
 | ||||||
|  | mkdirSync(DATA_DIR, { recursive: true }); | ||||||
|  | 
 | ||||||
| // TODO: remove eventually
 | // TODO: remove eventually
 | ||||||
| if (existsSync(LEGACY_DATA_DIR)) { | if (existsSync(LEGACY_DATA_DIR)) { | ||||||
|     try { |     try { | ||||||
|  |  | ||||||
|  | @ -42,7 +42,13 @@ function init() { | ||||||
| 
 | 
 | ||||||
|     // disable renderer backgrounding to prevent the app from unloading when in the background
 |     // disable renderer backgrounding to prevent the app from unloading when in the background
 | ||||||
|     // https://github.com/electron/electron/issues/2822
 |     // https://github.com/electron/electron/issues/2822
 | ||||||
|  |     // https://github.com/GoogleChrome/chrome-launcher/blob/5a27dd574d47a75fec0fb50f7b774ebf8a9791ba/docs/chrome-flags-for-tools.md#task-throttling
 | ||||||
|     app.commandLine.appendSwitch("disable-renderer-backgrounding"); |     app.commandLine.appendSwitch("disable-renderer-backgrounding"); | ||||||
|  |     app.commandLine.appendSwitch("disable-background-timer-throttling"); | ||||||
|  |     app.commandLine.appendSwitch("disable-backgrounding-occluded-windows"); | ||||||
|  |     if (process.platform === "win32") { | ||||||
|  |         disabledFeatures.push("CalculateNativeWinOcclusion"); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     // work around chrome 66 disabling autoplay by default
 |     // work around chrome 66 disabling autoplay by default
 | ||||||
|     app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); |     app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); | ||||||
|  | @ -50,12 +56,7 @@ function init() { | ||||||
|     // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
 |     // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
 | ||||||
|     //
 |     //
 | ||||||
|     // WidgetLayering (Vencord Added): Fix DevTools context menus https://github.com/electron/electron/issues/38790
 |     // WidgetLayering (Vencord Added): Fix DevTools context menus https://github.com/electron/electron/issues/38790
 | ||||||
|     disabledFeatures.push( |     disabledFeatures.push("WinRetrieveSuggestionsOnlyOnDemand", "HardwareMediaKeyHandling", "MediaSessionService"); | ||||||
|         "WinRetrieveSuggestionsOnlyOnDemand", |  | ||||||
|         "HardwareMediaKeyHandling", |  | ||||||
|         "MediaSessionService", |  | ||||||
|         "WidgetLayering" |  | ||||||
|     ); |  | ||||||
| 
 | 
 | ||||||
|     app.commandLine.appendSwitch("enable-features", [...new Set(enabledFeatures)].filter(Boolean).join(",")); |     app.commandLine.appendSwitch("enable-features", [...new Set(enabledFeatures)].filter(Boolean).join(",")); | ||||||
|     app.commandLine.appendSwitch("disable-features", [...new Set(disabledFeatures)].filter(Boolean).join(",")); |     app.commandLine.appendSwitch("disable-features", [...new Set(disabledFeatures)].filter(Boolean).join(",")); | ||||||
|  |  | ||||||
|  | @ -403,7 +403,9 @@ function createMainWindow() { | ||||||
|             contextIsolation: true, |             contextIsolation: true, | ||||||
|             devTools: true, |             devTools: true, | ||||||
|             preload: join(__dirname, "preload.js"), |             preload: join(__dirname, "preload.js"), | ||||||
|             spellcheck: true |             spellcheck: true, | ||||||
|  |             // disable renderer backgrounding to prevent the app from unloading when in the background
 | ||||||
|  |             backgroundThrottling: false | ||||||
|         }, |         }, | ||||||
|         icon: ICON_PATH, |         icon: ICON_PATH, | ||||||
|         frame: !noFrame, |         frame: !noFrame, | ||||||
|  | @ -428,6 +430,7 @@ function createMainWindow() { | ||||||
|         autoHideMenuBar: enableMenu |         autoHideMenuBar: enableMenu | ||||||
|     })); |     })); | ||||||
|     win.setMenuBarVisibility(false); |     win.setMenuBarVisibility(false); | ||||||
|  |     if (process.platform === "darwin" && customTitleBar) win.setWindowButtonVisibility(false); | ||||||
| 
 | 
 | ||||||
|     win.on("close", e => { |     win.on("close", e => { | ||||||
|         const useTray = !isDeckGameMode && Settings.store.minimizeToTray !== false && Settings.store.tray !== false; |         const useTray = !isDeckGameMode && Settings.store.minimizeToTray !== false && Settings.store.tray !== false; | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .vcd-screen-picker-selected img { | .vcd-screen-picker-selected img { | ||||||
|     border: 2px solid var(--brand-experiment); |     border: 2px solid var(--brand-500); | ||||||
|     border-radius: 3px; |     border-radius: 3px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -49,7 +49,7 @@ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .vcd-screen-picker-grid label:hover { | .vcd-screen-picker-grid label:hover { | ||||||
|     outline: 2px solid var(--brand-experiment); |     outline: 2px solid var(--brand-500); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -101,8 +101,8 @@ | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .vcd-screen-picker-radio[data-checked="true"] { | .vcd-screen-picker-radio[data-checked="true"] { | ||||||
|     background-color: var(--brand-experiment); |     background-color: var(--brand-500); | ||||||
|     border-color: var(--brand-experiment); |     border-color: var(--brand-500); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .vcd-screen-picker-radio[data-checked="true"] h2 { | .vcd-screen-picker-radio[data-checked="true"] h2 { | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import { app, BrowserWindow, shell } from "electron"; | import { app, BrowserWindow, shell } from "electron"; | ||||||
|  | import { PORTABLE } from "main/constants"; | ||||||
| import { Settings, State } from "main/settings"; | import { Settings, State } from "main/settings"; | ||||||
| import { handle } from "main/utils/ipcWrappers"; | import { handle } from "main/utils/ipcWrappers"; | ||||||
| import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally"; | import { makeLinksOpenExternally } from "main/utils/makeLinksOpenExternally"; | ||||||
|  | @ -23,17 +24,12 @@ let updateData: UpdateData; | ||||||
| 
 | 
 | ||||||
| handle(IpcEvents.UPDATER_GET_DATA, () => updateData); | handle(IpcEvents.UPDATER_GET_DATA, () => updateData); | ||||||
| handle(IpcEvents.UPDATER_DOWNLOAD, () => { | handle(IpcEvents.UPDATER_DOWNLOAD, () => { | ||||||
|     const portable = !!process.env.PORTABLE_EXECUTABLE_FILE; |  | ||||||
| 
 |  | ||||||
|     const { assets } = updateData.release; |     const { assets } = updateData.release; | ||||||
|     const url = (() => { |     const url = (() => { | ||||||
|         switch (process.platform) { |         switch (process.platform) { | ||||||
|             case "win32": |             case "win32": | ||||||
|                 return assets.find(a => { |                 return assets.find(a => { | ||||||
|                     if (!a.name.endsWith(".exe")) return false; |                     return a.name.endsWith(PORTABLE ? "win.zip" : ".exe"); | ||||||
| 
 |  | ||||||
|                     const isSetup = a.name.includes("Setup"); |  | ||||||
|                     return portable ? !isSetup : isSetup; |  | ||||||
|                 })!.browser_download_url; |                 })!.browser_download_url; | ||||||
|             case "darwin": |             case "darwin": | ||||||
|                 return assets.find(a => |                 return assets.find(a => | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Tiagoquix
						Tiagoquix