diff --git a/package.json b/package.json index 186dd07..823e0c8 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "download-git-repo": "^3.0.2", "electron-is-dev": "^2.0.0", "electron-store": "^8.0.0", + "file-icon-info": "^1.1.1", "iohook": "^0.9.3", "is-chinese": "^1.4.2", "jian-pinyin": "^0.2.3", diff --git a/src/renderer/assets/common/win-app.js b/src/renderer/assets/common/win-app.js index ac9451d..25dfcde 100644 --- a/src/renderer/assets/common/win-app.js +++ b/src/renderer/assets/common/win-app.js @@ -1,3 +1,4 @@ +import fs from 'fs'; import path from "path"; import os from 'os'; import child from 'child_process'; @@ -7,6 +8,26 @@ import translate from "./translate"; const fileLists = []; const isZhRegex = /[\u4e00-\u9fa5]/; +const getico = apps =>{ + const fii = require('file-icon-info'); + const icondir = path.join(os.tmpdir(), 'ProcessIcon'); + const exists = fs.existsSync(icondir); + if (!exists) { fs.mkdirSync(icondir) } + + apps.forEach((app, i) => { + fii.getIcon(app.desc, data => { + let iconpath = path.join(icondir, `${app.LegalName}.png`) + fs.exists(iconpath, exists => { + if (!exists) { + fs.writeFile(iconpath, data, "base64", err => { + if (err) { console.log(err); } + }) + } + }); + }); + }); +} + const powershell = (cmd, callback) => { const ps = child.spawn('powershell', ['-NoProfile', '-Command', cmd], { encoding: 'buffer' }) let chunks = []; @@ -71,6 +92,7 @@ const getWinAppList = () => { }); } } + getico(fileLists); }); }