删除监听事件
This commit is contained in:
parent
9e714c643f
commit
2a2a520b14
|
@ -183,6 +183,14 @@
|
|||
|
||||
ipcRenderer.removeListener(channel, listener);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeAllListeners(channel) {
|
||||
validateIPC(channel);
|
||||
|
||||
ipcRenderer.removeAllListeners(channel);
|
||||
|
||||
return this;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -112,6 +112,7 @@ export interface IpcRenderer {
|
|||
// */
|
||||
// postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
|
||||
removeListener(channel: string, listener: (...args: any[]) => void): this;
|
||||
removeAllListeners(channel: string): this;
|
||||
/**
|
||||
* Send an asynchronous message to the main process via `channel`, along with
|
||||
* arguments. Arguments will be serialized with the Structured Clone Algorithm,
|
||||
|
|
|
@ -128,8 +128,6 @@
|
|||
</div>
|
||||
<div class="devContent">
|
||||
<form id="checkboxForm">
|
||||
<script src="common.js"></script>
|
||||
<!-- 复选框列表 -->
|
||||
</form>
|
||||
|
||||
<div class="formSeparator"></div>
|
||||
|
@ -143,20 +141,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="tab" id="onlineInstallTab4">
|
||||
<div class="progress-container" style="display: none">
|
||||
<progress class="download-view" value="60" max="100"> </progress>
|
||||
<span class="progress-download">插件下载进度:60%</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-container" style="display: none">
|
||||
<progress class="install-view" value="50" max="100"></progress>
|
||||
<span class="progress-install">插件安装进度:50%</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-container" style="display: none">
|
||||
<progress class="pkg-install-view" value="50" max="100" style="overflow:hidden;"></progress>
|
||||
<span class="pkg-progress-install"></span>
|
||||
</div>
|
||||
<div class="progress-container">
|
||||
<progress class="progress-view" value="50" max="100" style="overflow:hidden;"></progress>
|
||||
<span class="progressinfo"></span>
|
||||
|
|
|
@ -28,8 +28,6 @@ import { KeyCode } from 'vs/base/common/keyCodes';
|
|||
import { mainWindow } from 'vs/base/browser/window';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import * as utils from 'vs/platform/issue/electron-main/utils';
|
||||
|
||||
import { addDisposableListener, EventType, getWindow, getWindowId, hide, show } from 'vs/base/browser/dom';
|
||||
import { isDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
@ -124,7 +122,6 @@ class deployWindow {
|
|||
this.nextPrev(1);
|
||||
} else if (msg.type === "osinfo") {
|
||||
console.log("ipcRenderer osinfo ");
|
||||
// this.readOSInfo(msg);
|
||||
const parentdiv = document.getElementById('osInfo') as HTMLDivElement;
|
||||
const parentdivshow = document.getElementById('osInfoShow') as HTMLDivElement;
|
||||
parentdiv.innerHTML = "";
|
||||
|
@ -185,16 +182,6 @@ class deployWindow {
|
|||
}
|
||||
else if (msg.type == "downloadExtDone") {
|
||||
this.extDownloadDoneCounter++;
|
||||
let num = msg.extTotal;
|
||||
|
||||
let downloadViews = document.getElementsByClassName("download-view") as HTMLCollectionOf<HTMLProgressElement>;
|
||||
var val = downloadViews[0].value
|
||||
val = (this.extDownloadDoneCounter / num) * 100;
|
||||
val = parseInt(val.toFixed(2));
|
||||
console.log(msg.extName + "下载完成" + msg.fileName + ":" + num);
|
||||
if (val > 99) val = 100;
|
||||
downloadViews[0].value = val;
|
||||
document.getElementsByClassName("progress-download")[0].innerHTML = "插件下载进度:" + val + "%";
|
||||
const installMsg = {
|
||||
type: "installExt",
|
||||
extList: this.extList,
|
||||
|
@ -207,21 +194,9 @@ class deployWindow {
|
|||
}
|
||||
else if (msg.type == "extInstalled") {
|
||||
this.progressNum++;
|
||||
|
||||
const extName = this.getKeyByValue(msg.extFileName, this.extMap);
|
||||
this.extInstallDoneCounter++;
|
||||
let num = msg.extTotal;
|
||||
|
||||
let installViews = document.getElementsByClassName("install-view") as HTMLCollectionOf<HTMLProgressElement>;
|
||||
var val = installViews[0].value;
|
||||
val = (this.extInstallDoneCounter / num) * 100;
|
||||
val = parseInt(val.toFixed(2));
|
||||
if (val > 99) val = 100;
|
||||
console.log("extInstalled: " + extName + ":" + val);
|
||||
|
||||
this.extInstallState.set(extName, 12);
|
||||
installViews[0].value = val;
|
||||
document.getElementsByClassName("progress-install")[0].innerHTML = "插件安装进度:" + val + "%";
|
||||
}
|
||||
else if (msg.type == "extInstalledFail") {
|
||||
this.progressNum++;
|
||||
|
@ -250,23 +225,9 @@ class deployWindow {
|
|||
}
|
||||
}
|
||||
else if (msg.type == "depInstallSucc") {
|
||||
console.log("------dll---depInstallSucc");
|
||||
this.progressNum++;
|
||||
let num = this.depList.length;
|
||||
|
||||
let pkgInstallViews = document.getElementsByClassName("pkg-install-view") as HTMLCollectionOf<HTMLProgressElement>;
|
||||
var val = pkgInstallViews[0].value;
|
||||
pkgInstallViews[0].value = 0;
|
||||
document.getElementsByClassName("pkg-progress-install")[0].innerHTML = "软件安装进度:0%";
|
||||
|
||||
let succVal = (msg.succ / num) * 100;
|
||||
succVal = parseInt(succVal.toFixed(2));
|
||||
if (succVal > val)
|
||||
val = succVal;
|
||||
if (val > 99) val = 100;
|
||||
this.extInstallState.set(msg.depName, 12);
|
||||
|
||||
pkgInstallViews[0].value = val;
|
||||
document.getElementsByClassName("pkg-progress-install")[0].innerHTML = "软件安装进度:" + val + "%";
|
||||
this.checkScripts(msg);
|
||||
}
|
||||
else if (msg.type === "depInstallFail") {
|
||||
|
@ -484,6 +445,7 @@ class deployWindow {
|
|||
this.prevBtn = document.getElementById("prevStep") as HTMLButtonElement;
|
||||
this.cancelBtn = document.getElementById('cancel') as HTMLButtonElement;
|
||||
this.showTab(this.currentTab);
|
||||
this.removeAllListeners();
|
||||
this.registerEventListener();
|
||||
}
|
||||
|
||||
|
@ -586,26 +548,6 @@ class deployWindow {
|
|||
progress_view[0].value = 0;
|
||||
document.getElementsByClassName("progressinfo")[0].innerHTML = "安装进度:0%";
|
||||
|
||||
if (this.depList.length === 0) {
|
||||
let cname = document.getElementsByClassName("pkg-install-view")[0];
|
||||
if (cname) {
|
||||
document.getElementsByClassName("pkg-progress-install")[0].innerHTML = " ";
|
||||
cname.className = "grey-progress-view";
|
||||
}
|
||||
let grey_progress_view = document.getElementsByClassName("pkg-progress-install") as HTMLCollectionOf<HTMLProgressElement>;
|
||||
grey_progress_view[0].value = 0;
|
||||
// document.getElementsByClassName("pkg-progress-install")[0].style = "display: inline-block; background-color: gray;";
|
||||
}
|
||||
else {
|
||||
let cname = document.getElementsByClassName("pkg-install-view")[0];
|
||||
if (!cname) {
|
||||
document.getElementsByClassName("grey-progress-view")[0].className = "pkg-install-view";
|
||||
}
|
||||
let pkg_install_view = document.getElementsByClassName("pkg-install-view") as HTMLCollectionOf<HTMLProgressElement>;
|
||||
pkg_install_view[0].value = 0;
|
||||
document.getElementsByClassName("pkg-progress-install")[0].innerHTML = "软件安装进度:0%";
|
||||
}
|
||||
|
||||
let extPreElement = document.getElementById("extInstallLogPre");
|
||||
extPreElement!.innerHTML = "";
|
||||
|
||||
|
@ -620,9 +562,9 @@ class deployWindow {
|
|||
ipcRenderer.send('kylinide.installWizard.msg.process', installPkgMsg);
|
||||
ipcRenderer.send('kylinide.installWizard.init', { type: "writeJson", });
|
||||
} else if (this.onlineInstallTabArray[this.onlineInstallTabArrayIndex] === "onlineInstallTab4") {
|
||||
ipcRenderer.send('kylinide.installWizard.ok');
|
||||
console.log("onlineInstallTab4");
|
||||
this.removeAllListeners();
|
||||
ipcRenderer.send('kylinide.installWizard.skipWizard');
|
||||
console.log("onlineInstallTab4");
|
||||
return;
|
||||
}
|
||||
if (this.onlineInstallTabArrayIndex < this.onlineInstallTabArray.length - 1) {
|
||||
|
@ -694,6 +636,7 @@ class deployWindow {
|
|||
// ipcRenderer.send('kylinide.installWizard.closeBefore', { type: "processterm" });
|
||||
}
|
||||
else {
|
||||
console.log("this -------------closeBtn");
|
||||
ipcRenderer.send('kylinide.installWizard.closeWizard', { type: "close" });
|
||||
this.removeAllListeners();
|
||||
}
|
||||
|
@ -798,47 +741,6 @@ class deployWindow {
|
|||
}
|
||||
}
|
||||
|
||||
//显示系统信息
|
||||
readOSInfo(os: string) {
|
||||
console.log('readosinf');
|
||||
const parentdiv = document.getElementById('osInfo') as HTMLDivElement;
|
||||
const parentdivshow = document.getElementById('osInfoShow') as HTMLDivElement;
|
||||
parentdiv.innerHTML = "";
|
||||
parentdivshow.innerHTML = "";
|
||||
const kyinfoPath = '/etc/.kyinfo';
|
||||
const osReleasePath = '/etc/os-release';
|
||||
let osinfo;
|
||||
if (!os) {
|
||||
osinfo = `<h3>操作系统信息</h3><p>操作系统检测脚本运行失败,未成功检测到操作系统类型</p>`
|
||||
} else {
|
||||
osinfo = `<h3>操作系统信息</h3><p>已检测到当前操作系统信息为:<span style="color:#1177BB;">${os}</span></p>`;
|
||||
}
|
||||
parentdiv.innerHTML = osinfo;
|
||||
|
||||
let data = "";
|
||||
let osdiv;
|
||||
const fs = require('fs');
|
||||
if (fs.existsSync(kyinfoPath)) {
|
||||
try {
|
||||
osdiv = `<p>判断依据:</p><p>cat /etc/.kyinfo</p>`
|
||||
data = fs.readFileSync(kyinfoPath, 'utf8');
|
||||
data = data.replace(/\n/g, '<br>');
|
||||
} catch (err) {
|
||||
}
|
||||
} else if (fs.existsSync(osReleasePath)) {
|
||||
try {
|
||||
osdiv = "操作系统信息:cat /etc/os-release"
|
||||
data = fs.readFileSync(osReleasePath, 'utf8');
|
||||
data = data.replace(/\n/g, '<br>');
|
||||
} catch (err) { }
|
||||
}
|
||||
if (osdiv == "" && data == "") {
|
||||
parentdivshow.innerHTML = "读取操作系统信息失败";
|
||||
} else {
|
||||
parentdivshow.innerHTML = `${osdiv}<p>${data}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
setFisrtClass(depDataObject: any, jsonSelectKey: string[]) {
|
||||
var form = document.getElementById("checkboxForm");
|
||||
// var depDataObject = JSON.parse(fs.readFileSync(depPath, 'utf-8'));
|
||||
|
@ -1100,8 +1002,7 @@ class deployWindow {
|
|||
type: "installScript",
|
||||
extList: this.extList,
|
||||
depList: this.depList,
|
||||
script: obj,
|
||||
dst: utils.configDir()
|
||||
script: obj
|
||||
};
|
||||
ipcRenderer.send("kylinide.installWizard.msg.process", installMsg);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,23 +0,0 @@
|
|||
// import * as os from 'os';
|
||||
// import * as fs from 'fs';
|
||||
|
||||
//获取全局变量g_index.json下载网络
|
||||
export function get_g_index_url() {
|
||||
let { gIndexUrl } = require('../../../../../../product.json');
|
||||
return gIndexUrl;
|
||||
}
|
||||
|
||||
export function configDir() {
|
||||
// 获取用户目录
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const userHome = os.homedir();
|
||||
// 创建日志目录
|
||||
const configDir = `${userHome}/.config/Kylin-Code/installconfig`;
|
||||
if (!fs.existsSync(configDir)) {
|
||||
fs.mkdirSync(configDir, { recursive: true }); // 递归创建目录
|
||||
}
|
||||
return configDir;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue