diff --git a/assets/index.js b/assets/index.js index 20aeed2..27e8cf6 100644 --- a/assets/index.js +++ b/assets/index.js @@ -1,27 +1,29 @@ checkUpdate = () => { - let cv = 'v0.0.5', - pg = 'https://yuanliao.info/d/296'; - if (!utools.db.get(cv)) { - $.get(pg, data => { - data = /\[插件\]\[关闭进程 ProcessKiller (.*?)\](.*?) - 猿料<\/title>/.exec(data); - let lv = data[1], + let p = window.pluginInfo; + if (!utools.db.get(p.version)) { + $.get(p.publishPage, data => { + var re = new RegExp(`<title>\\[插件\\]\\[${p.pluginName} (.*?)\\](.*?) - 猿料<\\/title>`) + data = re.exec(data); + let lastVer = data[1], desc = data[2]; - if (lv != cv) { + if (lastVer != p.version) { options = { type: 'info', title: '插件有可用更新', - icon: window.getLogo(), + icon: window.logo, cancelId: 1, - message: `发现新版本 ${lv},是否前往更新?\n更新内容:\n${desc}`, + message: `发现新版本 ${lastVer},是否前往更新?\n更新内容:\n${desc}`, buttons: ['起驾', '朕知道了', '别再烦朕'] }; window.messageBox(options, index => { if (index == 0) { - window.open(pg) + window.open(p.publishPage) } else if (index == 2) { - utools.db.put({ _id: cv, data: "pass" }) + utools.db.put({ _id: p.version, data: "pass" }) } }) + } else { + console.log('当前已是最新版本!'); } }) } diff --git a/plugin.json b/plugin.json index 8574306..6ff1c25 100644 --- a/plugin.json +++ b/plugin.json @@ -2,9 +2,10 @@ "pluginName": "关闭进程", "description": "列出当前运行的所有进程,左键进行关闭,右键进行重启", "main": "index.html", - "version": "0.0.5", + "version": "0.0.6", "author": "云之轩", "homepage":"https://github.com/fofolee/uTools-ProcessKiller", + "publishPage": "https://yuanliao.info/d/296", "logo": "logo.png", "platform": ["win32", "darwin"], "unpack":"{IconExtractor.exe,Newtonsoft.Json.dll,file-icon}", diff --git a/preload.js b/preload.js index b4c69e4..8a6a633 100644 --- a/preload.js +++ b/preload.js @@ -1,18 +1,15 @@ const os = require('os') const iconv = require('iconv-lite') const { spawn, exec } = require("child_process") + +//-------checkUpdate------ +const fs = require('fs') +const path = require("path") const { dialog, BrowserWindow, nativeImage } = require('electron').remote const { shell } = require('electron'); -const path = require("path") - -isWin = os.platform() == 'win32' ? true : false; - -getIco = isWin ? require('icon-extractor') : require('file-icon'); - -totalMem = os.totalmem(); - -getLogo = () => nativeImage.createFromPath(path.join(__dirname, 'logo.png')); +pluginInfo = JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json'))); +logo = nativeImage.createFromPath(path.join(__dirname, 'logo.png')); messageBox = (options, callback) => { dialog.showMessageBox(BrowserWindow.getFocusedWindow(), options, index => { @@ -23,6 +20,13 @@ messageBox = (options, callback) => { open = url => { shell.openExternal(url); } +// ------------------------ + +isWin = os.platform() == 'win32' ? true : false; + +getIco = isWin ? require('icon-extractor') : require('file-icon'); + +totalMem = os.totalmem(); powershell = (cmd, callback) => { const ps = spawn('powershell', ['-Command', cmd], { encoding: 'buffer' }) diff --git a/readme.md b/readme.md index b41cc5e..a0995b8 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# ProcessKiller V0.0.5 +# ProcessKiller V0.0.6 ### 简介 @@ -6,6 +6,11 @@ ### 更新日志 +**v0.0.6** + +- 更新`windos`下显示`内存`百分比及`用户`的功能,以及默认按照内存占用率进行排序 +- 微调获取进程的相关命令语句 + **v0.0.5** - 更新了对`macOS`的支持,`macOS`相比`window`多了显示`CPU`,`内存`百分比及`用户`的功能,以及默认按照内存占用率进行排序 diff --git a/releases/ProcessKiller-0.0.6.upx b/releases/ProcessKiller-0.0.6.upx new file mode 100644 index 0000000..d0bf1b3 Binary files /dev/null and b/releases/ProcessKiller-0.0.6.upx differ