From e15ef0b7ba818087a287cddb64eb4e02c0919dba Mon Sep 17 00:00:00 2001 From: dinglili Date: Thu, 30 May 2024 10:05:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B7=B3=E8=BF=87=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vs/code/electron-main/app.ts | 23 ++++++++++++++++- .../issue/electron-main/deployMainService.ts | 25 ++----------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 7f577371..09be5bd5 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -122,6 +122,8 @@ import { IAuxiliaryWindowsMainService, isAuxiliaryWindow } from 'vs/platform/aux import { AuxiliaryWindowsMainService } from 'vs/platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService'; import { IDeployMainService } from 'vs/platform/issue/common/deploy'; import { DeployMainService } from 'vs/platform/issue/electron-main/deployMainService'; +import * as fs from 'fs'; +import * as path from 'path'; /** * The main VS Code application. There will only ever be one instance, @@ -634,7 +636,10 @@ export class CodeApplication extends Disposable { this.lifecycleMainService.phase = LifecycleMainPhase.Ready; //install window wait to do by dll - await appInstantiationService.invokeFunction(accessor => this.openDeploylWindow(accessor)); + if (await this.isFirstLoad()) { + await appInstantiationService.invokeFunction(accessor => this.openDeploylWindow(accessor)); + } + // Open Windows await appInstantiationService.invokeFunction(accessor => this.openFirstWindow(accessor, initialProtocolUrls)); @@ -1474,4 +1479,20 @@ export class CodeApplication extends Disposable { this.logService.error(error); } } + private async isFirstLoad(): Promise { + let res = false; + const userDataPath = path.join(this.environmentMainService.userHome.fsPath, '.config', 'Kylin-IDE', 'installconfig'); + const flagFilePath = path.join(userDataPath, 'first-run.flag'); + + if (!fs.existsSync(userDataPath)) { + fs.mkdirSync(userDataPath, { recursive: true }); // 递归创建目录 + } + if (fs.existsSync(flagFilePath)) { + res = false; // 标记文件存在,不是首次启动 + } else { + fs.writeFileSync(flagFilePath, ''); // 创建标记文件 + res = true; // 标记文件不存在,是首次启动 + } + return res; + } } diff --git a/src/vs/platform/issue/electron-main/deployMainService.ts b/src/vs/platform/issue/electron-main/deployMainService.ts index 42b8daeb..e408d8ff 100644 --- a/src/vs/platform/issue/electron-main/deployMainService.ts +++ b/src/vs/platform/issue/electron-main/deployMainService.ts @@ -530,15 +530,11 @@ export class DeployMainService implements IDeployMainService { } //#region Used by renderer - async openDeployWindow(flag?: boolean): Promise { + async openDeployWindow(flag: boolean = true): Promise { return new Promise(async (resolve, reject) => { - let isFirstLoad; if (!this.DeployWindow) { const data = {} as DeployData; - if (flag === undefined) { - isFirstLoad = await this.isFirstLoad(); - } const DeployDisposables = new DisposableStore(); const deployWindowConfigUrl = DeployDisposables.add(this.protocolMainService.createIPCObjectUrl()); console.log("---------------------deployWindowConfigUrl", deployWindowConfigUrl.resource.toString()); @@ -560,7 +556,7 @@ export class DeployMainService implements IDeployMainService { // // Menu.setApplicationMenu(null); let initData = { - isFirstLoad: flag === undefined ? isFirstLoad : flag, + isFirstLoad: flag, } this.DeployWindow.webContents.on('did-finish-load', () => { if (this.DeployWindow) { @@ -949,23 +945,6 @@ export class DeployMainService implements IDeployMainService { } return url; } - //ide是否首次启动,如果是首次启动返回true,否则返回false - private async isFirstLoad(): Promise { - let res = false; - const userDataPath = path.join(this.environmentMainService.userHome.fsPath, '.config', 'Kylin-Code', 'installconfig'); - const flagFilePath = path.join(userDataPath, 'first-run.flag'); - - if (!fs.existsSync(userDataPath)) { - fs.mkdirSync(userDataPath, { recursive: true }); // 递归创建目录 - } - if (fs.existsSync(flagFilePath)) { - res = false; // 标记文件存在,不是首次启动 - } else { - fs.writeFileSync(flagFilePath, ''); // 创建标记文件 - res = true; // 标记文件不存在,是首次启动 - } - return res; - } private getPublicKeyPem(publicKeyPath: string) { const data = fs.readFileSync(publicKeyPath, 'utf-8'); return data;