bugfix: #44,支持windows应用图标展示

This commit is contained in:
muwoo 2021-09-07 16:58:04 +08:00
parent 651e202ab1
commit 424c40a99c
2 changed files with 23 additions and 0 deletions

View File

@ -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",

View File

@ -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);
});
}