win增加内存排序、显示用户名功能

This commit is contained in:
fofolee 2019-05-03 23:19:27 +08:00
parent d30887651f
commit f629b8ef71
5 changed files with 34 additions and 22 deletions

View File

@ -1,27 +1,29 @@
checkUpdate = () => { checkUpdate = () => {
let cv = 'v0.0.5', let p = window.pluginInfo;
pg = 'https://yuanliao.info/d/296'; if (!utools.db.get(p.version)) {
if (!utools.db.get(cv)) { $.get(p.publishPage, data => {
$.get(pg, data => { var re = new RegExp(`<title>\\[插件\\]\\[${p.pluginName} (.*?)\\](.*?) - 猿料<\\/title>`)
data = /<title>\[插件\]\[关闭进程 ProcessKiller (.*?)\](.*?) - 猿料<\/title>/.exec(data); data = re.exec(data);
let lv = data[1], let lastVer = data[1],
desc = data[2]; desc = data[2];
if (lv != cv) { if (lastVer != p.version) {
options = { options = {
type: 'info', type: 'info',
title: '插件有可用更新', title: '插件有可用更新',
icon: window.getLogo(), icon: window.logo,
cancelId: 1, cancelId: 1,
message: `发现新版本 ${lv},是否前往更新?\n更新内容:\n${desc}`, message: `发现新版本 ${lastVer},是否前往更新?\n更新内容:\n${desc}`,
buttons: ['起驾', '朕知道了', '别再烦朕'] buttons: ['起驾', '朕知道了', '别再烦朕']
}; };
window.messageBox(options, index => { window.messageBox(options, index => {
if (index == 0) { if (index == 0) {
window.open(pg) window.open(p.publishPage)
} else if (index == 2) { } else if (index == 2) {
utools.db.put({ _id: cv, data: "pass" }) utools.db.put({ _id: p.version, data: "pass" })
} }
}) })
} else {
console.log('当前已是最新版本!');
} }
}) })
} }

View File

@ -2,9 +2,10 @@
"pluginName": "关闭进程", "pluginName": "关闭进程",
"description": "列出当前运行的所有进程,左键进行关闭,右键进行重启", "description": "列出当前运行的所有进程,左键进行关闭,右键进行重启",
"main": "index.html", "main": "index.html",
"version": "0.0.5", "version": "0.0.6",
"author": "云之轩", "author": "云之轩",
"homepage":"https://github.com/fofolee/uTools-ProcessKiller", "homepage":"https://github.com/fofolee/uTools-ProcessKiller",
"publishPage": "https://yuanliao.info/d/296",
"logo": "logo.png", "logo": "logo.png",
"platform": ["win32", "darwin"], "platform": ["win32", "darwin"],
"unpack":"{IconExtractor.exe,Newtonsoft.Json.dll,file-icon}", "unpack":"{IconExtractor.exe,Newtonsoft.Json.dll,file-icon}",

View File

@ -1,18 +1,15 @@
const os = require('os') const os = require('os')
const iconv = require('iconv-lite') const iconv = require('iconv-lite')
const { spawn, exec } = require("child_process") const { spawn, exec } = require("child_process")
//-------checkUpdate------
const fs = require('fs')
const path = require("path")
const { dialog, BrowserWindow, nativeImage } = require('electron').remote const { dialog, BrowserWindow, nativeImage } = require('electron').remote
const { shell } = require('electron'); const { shell } = require('electron');
const path = require("path")
pluginInfo = JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')));
isWin = os.platform() == 'win32' ? true : false; logo = nativeImage.createFromPath(path.join(__dirname, 'logo.png'));
getIco = isWin ? require('icon-extractor') : require('file-icon');
totalMem = os.totalmem();
getLogo = () => nativeImage.createFromPath(path.join(__dirname, 'logo.png'));
messageBox = (options, callback) => { messageBox = (options, callback) => {
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), options, index => { dialog.showMessageBox(BrowserWindow.getFocusedWindow(), options, index => {
@ -23,6 +20,13 @@ messageBox = (options, callback) => {
open = url => { open = url => {
shell.openExternal(url); shell.openExternal(url);
} }
// ------------------------
isWin = os.platform() == 'win32' ? true : false;
getIco = isWin ? require('icon-extractor') : require('file-icon');
totalMem = os.totalmem();
powershell = (cmd, callback) => { powershell = (cmd, callback) => {
const ps = spawn('powershell', ['-Command', cmd], { encoding: 'buffer' }) const ps = spawn('powershell', ['-Command', cmd], { encoding: 'buffer' })

View File

@ -1,4 +1,4 @@
# ProcessKiller V0.0.5 # ProcessKiller V0.0.6
### 简介 ### 简介
@ -6,6 +6,11 @@
### 更新日志 ### 更新日志
**v0.0.6**
- 更新`windos`下显示`内存`百分比及`用户`的功能,以及默认按照内存占用率进行排序
- 微调获取进程的相关命令语句
**v0.0.5** **v0.0.5**
- 更新了对`macOS`的支持,`macOS`相比`window`多了显示`CPU`,`内存`百分比及`用户`的功能,以及默认按照内存占用率进行排序 - 更新了对`macOS`的支持,`macOS`相比`window`多了显示`CPU`,`内存`百分比及`用户`的功能,以及默认按照内存占用率进行排序

Binary file not shown.