mirror of
https://github.com/rubickCenter/rubick
synced 2025-07-27 19:49:31 +08:00
bugfix: #42; ref: 支持windows拼音搜索系统应用
This commit is contained in:
parent
f287d10ca9
commit
614d5ae369
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rubick2",
|
"name": "rubick2",
|
||||||
"version": "0.0.3-beta.11",
|
"version": "0.0.3-beta.12",
|
||||||
"author": "muwoo <2424880409@qq.com>",
|
"author": "muwoo <2424880409@qq.com>",
|
||||||
"description": "An electron-vue project",
|
"description": "An electron-vue project",
|
||||||
"license": null,
|
"license": null,
|
||||||
@ -69,6 +69,7 @@
|
|||||||
"download-git-repo": "^3.0.2",
|
"download-git-repo": "^3.0.2",
|
||||||
"electron-is-dev": "^2.0.0",
|
"electron-is-dev": "^2.0.0",
|
||||||
"electron-store": "^8.0.0",
|
"electron-store": "^8.0.0",
|
||||||
|
"icon-extractor": "^1.0.3",
|
||||||
"iohook": "^0.9.3",
|
"iohook": "^0.9.3",
|
||||||
"is-chinese": "^1.4.2",
|
"is-chinese": "^1.4.2",
|
||||||
"jian-pinyin": "^0.2.3",
|
"jian-pinyin": "^0.2.3",
|
||||||
|
@ -7,7 +7,7 @@ const configPath = path.join(getlocalDataFile(), './rubick-config.json')
|
|||||||
|
|
||||||
let defaultConfig = {
|
let defaultConfig = {
|
||||||
Darwin: {
|
Darwin: {
|
||||||
version: 2,
|
version: 3,
|
||||||
perf: {
|
perf: {
|
||||||
shortCut: {
|
shortCut: {
|
||||||
showAndHidden: 'Option+R',
|
showAndHidden: 'Option+R',
|
||||||
@ -32,7 +32,7 @@ let defaultConfig = {
|
|||||||
global: []
|
global: []
|
||||||
},
|
},
|
||||||
Windows_NT: {
|
Windows_NT: {
|
||||||
version: 2,
|
version: 3,
|
||||||
perf: {
|
perf: {
|
||||||
shortCut: {
|
shortCut: {
|
||||||
showAndHidden: 'Option+R',
|
showAndHidden: 'Option+R',
|
||||||
@ -57,7 +57,7 @@ let defaultConfig = {
|
|||||||
global: []
|
global: []
|
||||||
},
|
},
|
||||||
Linux: {
|
Linux: {
|
||||||
version: 1,
|
version: 3,
|
||||||
perf: {
|
perf: {
|
||||||
shortCut: {
|
shortCut: {
|
||||||
showAndHidden: 'Option+R',
|
showAndHidden: 'Option+R',
|
||||||
@ -85,13 +85,13 @@ let defaultConfig = {
|
|||||||
global.opConfig = {
|
global.opConfig = {
|
||||||
config: null,
|
config: null,
|
||||||
get() {
|
get() {
|
||||||
const platform = os.type()
|
const platform = os.type();
|
||||||
try {
|
try {
|
||||||
if (!opConfig.config) {
|
if (!opConfig.config) {
|
||||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
|
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
|
||||||
}
|
}
|
||||||
// 重置
|
// 重置
|
||||||
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
if (!opConfig.config.version || opConfig.config.version < defaultConfig[platform].version) {
|
||||||
opConfig.config = defaultConfig[platform]
|
opConfig.config = defaultConfig[platform]
|
||||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ global.opConfig = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
set(key, value) {
|
set(key, value) {
|
||||||
opConfig.config[key] = value
|
opConfig.config[key] = value;
|
||||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,22 @@ import path from "path";
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import child from 'child_process';
|
import child from 'child_process';
|
||||||
import iconv from 'iconv-lite';
|
import iconv from 'iconv-lite';
|
||||||
|
import translate from "./translate";
|
||||||
|
|
||||||
const fileLists = [];
|
const fileLists = [];
|
||||||
|
const isZhRegex = /[\u4e00-\u9fa5]/;
|
||||||
|
|
||||||
|
const getico = apps =>{
|
||||||
|
const iconExtractor = require('icon-extractor');
|
||||||
|
|
||||||
|
iconExtractor.emitter.on('icon', function (data) {
|
||||||
|
apps[data.Context].icon = 'data:image/png;base64,' + data.Base64ImageData;
|
||||||
|
});
|
||||||
|
|
||||||
|
apps.forEach((app, i) => {
|
||||||
|
iconExtractor.getIcon(i, app.desc);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const powershell = (cmd, callback) => {
|
const powershell = (cmd, callback) => {
|
||||||
const ps = child.spawn('powershell', ['-NoProfile', '-Command', cmd], { encoding: 'buffer' })
|
const ps = child.spawn('powershell', ['-NoProfile', '-Command', cmd], { encoding: 'buffer' })
|
||||||
@ -29,9 +43,8 @@ const getWinAppList = () => {
|
|||||||
let Wow6432Node = `Get-ItemProperty HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | ${filterValues}`;
|
let Wow6432Node = `Get-ItemProperty HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | ${filterValues}`;
|
||||||
let x64 = process.arch === 'x64' ? `;${Wow6432Node}` : '';
|
let x64 = process.arch === 'x64' ? `;${Wow6432Node}` : '';
|
||||||
powershell(`${localMatcine};${currentUser}${x64}`, (stdout, stderr) => {
|
powershell(`${localMatcine};${currentUser}${x64}`, (stdout, stderr) => {
|
||||||
let applist = [];
|
|
||||||
let apps = stdout.trim().replace(/\r\n[ ]{10,}/g,"").split('\r\n\r\n');
|
let apps = stdout.trim().replace(/\r\n[ ]{10,}/g,"").split('\r\n\r\n');
|
||||||
for (var app of apps) {
|
for (const app of apps) {
|
||||||
const dict = {}
|
const dict = {}
|
||||||
let lines = app.split('\r\n')
|
let lines = app.split('\r\n')
|
||||||
for (var line of lines) {
|
for (var line of lines) {
|
||||||
@ -44,7 +57,19 @@ const getWinAppList = () => {
|
|||||||
if (dict.DisplayName && dict.DisplayIcon && dict.DisplayIcon.indexOf('.exe') >= 0) {
|
if (dict.DisplayName && dict.DisplayIcon && dict.DisplayIcon.indexOf('.exe') >= 0) {
|
||||||
dict.LegalName = dict.DisplayName.replace(/[\\\/\:\*\?\"\<\>\|]/g, "");
|
dict.LegalName = dict.DisplayName.replace(/[\\\/\:\*\?\"\<\>\|]/g, "");
|
||||||
dict.Icon = path.join(os.tmpdir(), 'ProcessIcon', `${encodeURIComponent(dict.LegalName)}.png`);
|
dict.Icon = path.join(os.tmpdir(), 'ProcessIcon', `${encodeURIComponent(dict.LegalName)}.png`);
|
||||||
const appPath = dict.DisplayIcon.split(',')[0];
|
const firstLatter = dict.DisplayName.split(' ').map(name => name[0]).join('');
|
||||||
|
const appPath = dict.DisplayIcon.split(',')[0].replace(/"/g, '');
|
||||||
|
const keyWords = [dict.DisplayName, firstLatter];
|
||||||
|
if (isZhRegex.test(dict.DisplayName)) {
|
||||||
|
const py = translate(dict.DisplayName);
|
||||||
|
const pinyinArr = py.split(',');
|
||||||
|
const zh_firstLatter = pinyinArr.map(py => py[0]);
|
||||||
|
// 拼音
|
||||||
|
keyWords.push(pinyinArr.join(''));
|
||||||
|
// 缩写
|
||||||
|
keyWords.push(zh_firstLatter.join(''));
|
||||||
|
}
|
||||||
|
|
||||||
fileLists.push({
|
fileLists.push({
|
||||||
...dict,
|
...dict,
|
||||||
value: 'plugin',
|
value: 'plugin',
|
||||||
@ -52,11 +77,12 @@ const getWinAppList = () => {
|
|||||||
desc: appPath,
|
desc: appPath,
|
||||||
type: 'app',
|
type: 'app',
|
||||||
action: `start "dummyclient" "${appPath}"`,
|
action: `start "dummyclient" "${appPath}"`,
|
||||||
keyWords: [dict.DisplayName],
|
keyWords: keyWords,
|
||||||
name: dict.DisplayName,
|
name: dict.DisplayName,
|
||||||
names: [dict.DisplayName],
|
names: JSON.parse(JSON.stringify(keyWords)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
getico(fileLists);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user