ref: 优化window读取系统应用icon展示

This commit is contained in:
muwoo 2021-09-09 11:21:19 +08:00
parent 5118fa6ca4
commit d047119076
2 changed files with 10 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{
"name": "rubick2",
"version": "0.0.3-beta.14",
"version": "0.0.4",
"author": "muwoo <2424880409@qq.com>",
"description": "An electron-vue project",
"license": null,
@ -69,7 +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",
"extract-file-icon": "^0.3.2",
"iohook": "^0.9.3",
"is-chinese": "^1.4.2",
"jian-pinyin": "^0.2.3",

View File

@ -3,8 +3,7 @@ import path from 'path';
import os from 'os';
import translate from './translate';
import {shell} from 'electron';
const fii = require('file-icon-info');
const fileIcon = require('extract-file-icon');
const filePath = path.resolve('C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs');
const fileLists = [];
@ -15,16 +14,13 @@ const exists = fs.existsSync(icondir);
if (!exists) { fs.mkdirSync(icondir) }
const getico = app =>{
fii.getIcon(app.desc, data => {
let iconpath = path.join(icondir, `${app.name}.png`)
fs.exists(iconpath, exists => {
if (!exists) {
fs.writeFile(iconpath, data, 'base64', err => {
if (err) { console.log(err); }
})
}
});
});
try {
const buffer = fileIcon(app.desc, 32);
const iconpath = path.join(icondir, `${app.name}.png`);
fs.writeFileSync(iconpath, buffer, 'base64');
} catch(e) {
console.log(e, app.desc);
}
}
function fileDisplay(filePath){