feat(electron): enable vscode debugger for electron (#9333)
This commit is contained in:
@@ -34,7 +34,12 @@ function spawnOrReloadElectron() {
|
|||||||
const ext = process.platform === 'win32' ? '.cmd' : '';
|
const ext = process.platform === 'win32' ? '.cmd' : '';
|
||||||
const exe = resolve(rootDir, 'node_modules', '.bin', `electron${ext}`);
|
const exe = resolve(rootDir, 'node_modules', '.bin', `electron${ext}`);
|
||||||
|
|
||||||
delete process.env['NODE_OPTIONS'];
|
// remove import loader option
|
||||||
|
const NODE_OPTIONS = process.env.NODE_OPTIONS;
|
||||||
|
if (NODE_OPTIONS) {
|
||||||
|
process.env.NODE_OPTIONS = NODE_OPTIONS.replace(/--import=[^\s]*/, '');
|
||||||
|
}
|
||||||
|
|
||||||
spawnProcess = spawn(exe, ['.'], {
|
spawnProcess = spawn(exe, ['.'], {
|
||||||
cwd: electronDir,
|
cwd: electronDir,
|
||||||
env: process.env,
|
env: process.env,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { Display } from 'electron';
|
|||||||
import { BrowserWindow, screen } from 'electron';
|
import { BrowserWindow, screen } from 'electron';
|
||||||
|
|
||||||
import { isMacOS } from '../../shared/utils';
|
import { isMacOS } from '../../shared/utils';
|
||||||
|
import { isDev } from '../config';
|
||||||
import { onboardingViewUrl } from '../constants';
|
import { onboardingViewUrl } from '../constants';
|
||||||
// import { getExposedMeta } from './exposed';
|
// import { getExposedMeta } from './exposed';
|
||||||
import { logger } from '../logger';
|
import { logger } from '../logger';
|
||||||
@@ -90,6 +91,10 @@ async function createOnboardingWindow(additionalArguments: string[]) {
|
|||||||
fullscreenAndCenter(browserWindow);
|
fullscreenAndCenter(browserWindow);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
|
browserWindow.webContents.openDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
await browserWindow.loadURL(onboardingViewUrl);
|
await browserWindow.loadURL(onboardingViewUrl);
|
||||||
|
|
||||||
return browserWindow;
|
return browserWindow;
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ export class DesktopApiService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setupCommonUIEvents() {
|
private setupCommonUIEvents() {
|
||||||
|
if (this.api.appInfo.windowName !== 'main') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const handleMaximized = (maximized: boolean | undefined) => {
|
const handleMaximized = (maximized: boolean | undefined) => {
|
||||||
document.documentElement.dataset.maximized = String(maximized);
|
document.documentElement.dataset.maximized = String(maximized);
|
||||||
};
|
};
|
||||||
@@ -102,12 +106,13 @@ export class DesktopApiService extends Service {
|
|||||||
.isFullScreen()
|
.isFullScreen()
|
||||||
.then(handleFullscreen)
|
.then(handleFullscreen)
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
|
||||||
this.api.events.ui.onMaximized(handleMaximized);
|
this.api.events.ui.onMaximized(handleMaximized);
|
||||||
this.api.events.ui.onFullScreen(handleFullscreen);
|
this.api.events.ui.onFullScreen(handleFullscreen);
|
||||||
|
|
||||||
const tabId = this.api.appInfo.viewId;
|
const tabId = this.api.appInfo.viewId;
|
||||||
|
|
||||||
if (tabId && this.api.appInfo.windowName === 'main') {
|
if (tabId) {
|
||||||
let isActive = false;
|
let isActive = false;
|
||||||
const handleActiveTabChange = (active: boolean) => {
|
const handleActiveTabChange = (active: boolean) => {
|
||||||
isActive = active;
|
isActive = active;
|
||||||
|
|||||||
Reference in New Issue
Block a user