mirror of
https://github.com/rubickCenter/rubick
synced 2025-11-19 07:07:45 +08:00
🐛 修复构建bug
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import getMacApps from "get-mac-apps";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import getMacApps from "./get-mac-app";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
@@ -84,7 +86,7 @@ async function getAppIcon(
|
||||
}
|
||||
|
||||
export default async (nativeImage: any) => {
|
||||
let apps = await getMacApps.getApps();
|
||||
let apps: any = await getMacApps.getApps();
|
||||
|
||||
apps = apps.filter((app: any) => {
|
||||
const extname = path.extname(app.path);
|
||||
|
||||
43
src/core/app-search/get-mac-app/getApps.ts
Normal file
43
src/core/app-search/get-mac-app/getApps.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { spawn } from "child_process";
|
||||
import plist from "plist";
|
||||
|
||||
export default function getApps(resolve, reject, filterByAppName = false) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
let resultBuffer = new Buffer.from([]);
|
||||
|
||||
const profileInstalledApps = spawn("/usr/sbin/system_profiler", [
|
||||
"-xml",
|
||||
"-detailLevel",
|
||||
"mini",
|
||||
"SPApplicationsDataType"
|
||||
]);
|
||||
|
||||
profileInstalledApps.stdout.on("data", chunckBuffer => {
|
||||
resultBuffer = Buffer.concat([resultBuffer, chunckBuffer]);
|
||||
});
|
||||
|
||||
profileInstalledApps.on("exit", exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
reject([]);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const [installedApps] = plist.parse(resultBuffer.toString());
|
||||
if (!filterByAppName) return resolve(installedApps._items);
|
||||
return resolve(
|
||||
installedApps._items.filter(apps => apps._name === filterByAppName)
|
||||
.length !== 0
|
||||
);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
profileInstalledApps.on("error", err => {
|
||||
reject(err);
|
||||
});
|
||||
};
|
||||
10
src/core/app-search/get-mac-app/index.ts
Normal file
10
src/core/app-search/get-mac-app/index.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import getApps from "./getApps";
|
||||
|
||||
export default {
|
||||
getApps: () => {
|
||||
return new Promise((resolve, reject) => getApps(resolve, reject));
|
||||
},
|
||||
isInstalled: (appName) => {
|
||||
return new Promise((resolve, reject) => getApps(resolve, reject, appName));
|
||||
},
|
||||
};
|
||||
@@ -6,8 +6,11 @@ import fs from "fs-extra";
|
||||
import search, { Result } from "libnpmsearch";
|
||||
import path from "path";
|
||||
import got from "got";
|
||||
import fixPath from "fix-path";
|
||||
|
||||
import spwan from "cross-spawn";
|
||||
import spawn from "cross-spawn";
|
||||
|
||||
fixPath();
|
||||
|
||||
/**
|
||||
* 系统插件管理器
|
||||
@@ -146,7 +149,7 @@ class AdapterHandler {
|
||||
.concat("--save");
|
||||
if (cmd !== "uninstall")
|
||||
args = args.concat(`--registry=${this.registry}`);
|
||||
const npm = spwan("npm", args, {
|
||||
const npm = spawn("npm", args, {
|
||||
cwd: this.baseDir,
|
||||
});
|
||||
|
||||
|
||||
@@ -8,11 +8,14 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
return new Promise((resolve) => {
|
||||
let icon;
|
||||
if (commonConst.macOS()) {
|
||||
icon = "./icon@3x.png";
|
||||
icon = "./icons/icon@3x.png";
|
||||
} else if (commonConst.windows()) {
|
||||
icon = parseInt(os.release()) < 10 ? "./icon@2x.png" : "./icon.ico";
|
||||
icon =
|
||||
parseInt(os.release()) < 10
|
||||
? "./icons/icon@2x.png"
|
||||
: "./icons/icon.ico";
|
||||
} else {
|
||||
icon = "icon@2x.png";
|
||||
icon = "./icons/icon@2x.png";
|
||||
}
|
||||
const appIcon = new Tray(path.join(__static, icon));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
|
||||
Reference in New Issue
Block a user