添加重新加载窗口功能

This commit is contained in:
dinglili 2024-07-31 15:38:26 +08:00 committed by wangpenglong
parent b6c330a46f
commit 4b4477794a
4 changed files with 45 additions and 7 deletions

View File

@ -532,7 +532,7 @@
],
"helpDocUrl":"https://gitee.com/openkylin/extensions-repo/blob/master/user-guide/%E7%9B%AE%E5%BD%95.md",
"updateCheckUrl":"https://kylinhorn.cn/updateCheck/kylinide",
"gIndexUrl":"https://gitee.com/openkylin/extensions-repo/raw/master/inst-configs-repo/kylin-code/config/g_index.json",
"gIndexUrl":"https://gitee.com/openkylin/extensions-repo/raw/master/inst-configs-repo/kylin-code/0.4.0/g_index.json",
"deployFunc":true,
"feedbackUrl":"https://gitee.com/openkylin/kylin-code/issues",
"extensionsControlManifest":{

View File

@ -1490,7 +1490,7 @@ export class CodeApplication extends Disposable {
if (fs.existsSync(flagFilePath)) {
res = false; // 标记文件存在,不是首次启动
} else {
fs.writeFileSync(flagFilePath, ''); // 创建标记文件
fs.writeFileSync(flagFilePath, '1'); // 创建标记文件
res = true; // 标记文件不存在,是首次启动
}
return res;

View File

@ -35,6 +35,7 @@ class deployWindow {
gSoftInstNum = 0;
gExtInst = 0;
extAddressPath = '';
reloadWindowFlag = 0;
extInstallState = new Map();
extMap = {};
@ -271,10 +272,10 @@ class deployWindow {
if (writeKeyJson.length > 0) {
ipcRenderer.send("kylinide.installWizard.init", { type: "writeKey", keys: writeKeyJson });
}
showContext += "点击结束按钮退出开发环境快速部署\n"
showContext += "点击结束按钮退出开发环境快速部署\n";
let allSuccess = this.checkAllInstalledSucc(this.extInstallState);
this.goFinish(showContext, false, allSuccess);
console.log("安装结束:成功");
console.log("安装结束");
}
}
// preElement.scrollTop = preElement.scrollHeight;
@ -338,6 +339,7 @@ class deployWindow {
this.showTab(this.currentTab);
this.removeAllListeners();
this.registerEventListener();
this.reloadWindowFlag = 0;
}
// setHeader() {
@ -580,6 +582,9 @@ class deployWindow {
this.removeAllListeners();
ipcRenderer.send('kylinide.installWizard.closeWizard', { type: "close" });
console.log("renderer send kylinide.installWizard.closeWizard", 'close');
if (this.reloadWindowFlag) {
ipcRenderer.send('kylinide.installWizard.reloadwindow');
}
this.custom_print("nextPrev onlineInstallTab4");
return;
}
@ -749,6 +754,9 @@ class deployWindow {
else {
ipcRenderer.send('kylinide.installWizard.closeWizard', { type: "close" });
this.removeAllListeners();
if (this.reloadWindowFlag) {
ipcRenderer.send('kylinide.installWizard.reloadwindow');
}
}
});
/**
@ -1172,6 +1180,7 @@ class deployWindow {
if (flagjson > 0) {
return false;
} else {
this.reloadWindowFlag = 1;
return true;
}
}

View File

@ -17,7 +17,7 @@ import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/e
import { IDeployMainService, DeployWindowConfiguration, DeployData } from 'vs/platform/issue/common/deploy';
import { ILogger } from 'vs/platform/log/common/log';
import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService';
// import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
import product from 'vs/platform/product/common/product';
import { IProductService } from 'vs/platform/product/common/productService';
import { IIPCObjectUrl, IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol';
@ -64,6 +64,7 @@ export class DeployMainService implements IDeployMainService {
// private static readonly DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
private DeployWindow: BrowserWindow | null = null;
private deployWindowrParentWindow: BrowserWindow | null = null;
private selectObject = {
dirPath: "",
@ -123,6 +124,7 @@ export class DeployMainService implements IDeployMainService {
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@ILoggerMainService private readonly loggerMainService: ILoggerMainService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService,
@INativeHostMainService private readonly nativeHostMainService: INativeHostMainService,
@IProductService private readonly productService: IProductService,
) {
this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0, osrelease: "", supportList: [] };
@ -134,6 +136,9 @@ export class DeployMainService implements IDeployMainService {
this.loggerSoft = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/softdetail.log"));
this.removeListeners();
this.registerListeners();
this.deployWindowrParentWindow?.on('close', () => {
this.deployWindowrParentWindow = null;
})
}
reset() {
this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0, osrelease: "", supportList: [] };
@ -205,6 +210,7 @@ export class DeployMainService implements IDeployMainService {
}
this.closeWindow();
};
listenerInstallProcess = async (event: IpcMainEvent, msg: any) => {
@ -971,6 +977,7 @@ export class DeployMainService implements IDeployMainService {
validatedIpcMain.removeListener('kylinide.installWizard.msg.process', this.listenerInstallProcess);
validatedIpcMain.removeListener('kylinide.installWizard.removeFileLister', this.listenerRemoveFileLister);
validatedIpcMain.removeListener('kylinide.installWizard.init', this.listenerWriteSelectJson);
validatedIpcMain.removeListener('kylinide.installWizard.reloadwindow', this.listenerReloadWindow);
}
private registerListeners(): void {
this.logger.info("注册监听器");
@ -982,6 +989,7 @@ export class DeployMainService implements IDeployMainService {
validatedIpcMain.on('kylinide.installWizard.msg.process', this.listenerInstallProcess);
validatedIpcMain.on('kylinide.installWizard.removeFileLister', this.listenerRemoveFileLister);
validatedIpcMain.on('kylinide.installWizard.init', this.listenerWriteSelectJson);
validatedIpcMain.on('kylinide.installWizard.reloadwindow', this.listenerReloadWindow);
//handle从渲染进程发送的消息
validatedIpcMain.handle('kylinide.installWizard.init.configVersify', this.handleInitConfigVersify);
@ -1183,9 +1191,12 @@ export class DeployMainService implements IDeployMainService {
//#region Used by renderer
async openDeployWindow(flag: boolean = true): Promise<void> {
return new Promise(async (resolve, reject) => {
if (!this.DeployWindow) {
if (!flag)
this.deployWindowrParentWindow = BrowserWindow.getFocusedWindow();
this.reset();
@ -1231,8 +1242,6 @@ export class DeployMainService implements IDeployMainService {
resolve(void 0);
}
});
const listenerSkipWizard = async (event: IpcMainEvent) => {
this.logger.info("跳过配置");
if (this.DeployWindow && this.DeployWindow != undefined) {
@ -1247,6 +1256,26 @@ export class DeployMainService implements IDeployMainService {
}
});
}
listenerReloadWindow = async (event: IpcMainEvent, msg: any) => {
if (this.deployWindowrParentWindow) {
this.deployWindowrParentWindow.show();
dialog.showMessageBox(this.deployWindowrParentWindow, {
type: 'question',
title: "确认",
buttons: ["是", '否'],
defaultId: 0,
message: "是否重新加载窗口?",
detail: '开发环境快速部署安装插件后需要重载窗口使插件生效',
}).then(res => {
if (res.response === 0) {
if (this.deployWindowrParentWindow)
this.nativeHostMainService.reload(this.deployWindowrParentWindow.id);
}
})
}
}
private createDeployBrowserWindow<T>(position: IWindowState, ipcObjectUrl: IIPCObjectUrl<T>, windowKind: string): BrowserWindow {
const window = new BrowserWindow({
fullscreen: false,