mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-17 04:37:34 +08:00
bugfix: 修复 windows 搜索系统应用报错问题
This commit is contained in:
parent
a04efd0d4f
commit
f287d10ca9
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rubick2",
|
||||
"version": "0.0.3-beta.10",
|
||||
"version": "0.0.3-beta.11",
|
||||
"author": "muwoo <2424880409@qq.com>",
|
||||
"description": "An electron-vue project",
|
||||
"license": null,
|
||||
@ -69,7 +69,6 @@
|
||||
"download-git-repo": "^3.0.2",
|
||||
"electron-is-dev": "^2.0.0",
|
||||
"electron-store": "^8.0.0",
|
||||
"icon-extractor": "^1.0.3",
|
||||
"iohook": "^0.9.3",
|
||||
"is-chinese": "^1.4.2",
|
||||
"jian-pinyin": "^0.2.3",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from 'os';
|
||||
import child from 'child_process';
|
||||
@ -6,31 +5,6 @@ import iconv from 'iconv-lite';
|
||||
|
||||
const fileLists = [];
|
||||
|
||||
const getico = apps =>{
|
||||
const iconExtractor = require('icon-extractor');
|
||||
iconExtractor.emitter.on('icon', function (data) {
|
||||
let icondir = path.join(os.tmpdir(), 'ProcessIcon')
|
||||
fs.exists(icondir, exists => {
|
||||
if (!exists) { fs.mkdirSync(icondir) }
|
||||
let iconpath = path.join(icondir, `${data.Context}.png`)
|
||||
fs.exists(iconpath, exists => {
|
||||
if (!exists) {
|
||||
fs.writeFile(iconpath, data.Base64ImageData, "base64", err => {
|
||||
if (err) { console.log(err); }
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
for (var app of apps) {
|
||||
if (app.DisplayIcon !== undefined) {
|
||||
app.DisplayIcon = app.DisplayIcon.split(',')[0];
|
||||
}
|
||||
iconExtractor.getIcon(app.LegalName, app.DisplayIcon);
|
||||
}
|
||||
}
|
||||
|
||||
const powershell = (cmd, callback) => {
|
||||
const ps = child.spawn('powershell', ['-NoProfile', '-Command', cmd], { encoding: 'buffer' })
|
||||
let chunks = [];
|
||||
@ -60,7 +34,7 @@ const getWinAppList = () => {
|
||||
for (var app of apps) {
|
||||
const dict = {}
|
||||
let lines = app.split('\r\n')
|
||||
for (const line of lines) {
|
||||
for (var line of lines) {
|
||||
if (line) {
|
||||
const key = line.split(/\s+:\s*/)[0];
|
||||
const value = line.split(/\s+:\s*/)[1];
|
||||
@ -70,20 +44,20 @@ const getWinAppList = () => {
|
||||
if (dict.DisplayName && dict.DisplayIcon && dict.DisplayIcon.indexOf('.exe') >= 0) {
|
||||
dict.LegalName = dict.DisplayName.replace(/[\\\/\:\*\?\"\<\>\|]/g, "");
|
||||
dict.Icon = path.join(os.tmpdir(), 'ProcessIcon', `${encodeURIComponent(dict.LegalName)}.png`);
|
||||
const appPath = dict.DisplayIcon.split(',')[0];
|
||||
fileLists.push({
|
||||
...dict,
|
||||
value: 'plugin',
|
||||
icon: dict.Icon,
|
||||
desc: dict.DisplayIcon,
|
||||
desc: appPath,
|
||||
type: 'app',
|
||||
action: `start "dummyclient" "${dict.DisplayIcon}"`,
|
||||
action: `start "dummyclient" "${appPath}"`,
|
||||
keyWords: [dict.DisplayName],
|
||||
name: dict.DisplayName,
|
||||
names: [dict.DisplayName],
|
||||
});
|
||||
}
|
||||
}
|
||||
getico(fileLists);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user