mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-29 01:02:47 +08:00
✨ suport linux
This commit is contained in:
parent
751c73b3a6
commit
842a44a6d1
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-2019]
|
os: [macos-latest, windows-2019, ubuntu-latest]
|
||||||
|
|
||||||
# create steps
|
# create steps
|
||||||
steps:
|
steps:
|
||||||
|
@ -35,7 +35,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getSystemDetail() {
|
async getSystemDetail() {
|
||||||
let targetPath = "/plugins/system.json";
|
let targetPath = "plugins/system.json";
|
||||||
if (access_token) {
|
if (access_token) {
|
||||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ export default {
|
|||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getWorkerDetail() {
|
async getWorkerDetail() {
|
||||||
let targetPath = "/plugins/worker.json";
|
let targetPath = "plugins/worker.json";
|
||||||
if (access_token) {
|
if (access_token) {
|
||||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getSearchDetail() {
|
async getSearchDetail() {
|
||||||
let targetPath = "/plugins/search.json";
|
let targetPath = "plugins/search.json";
|
||||||
if (access_token) {
|
if (access_token) {
|
||||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ export default {
|
|||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getDevDetail() {
|
async getDevDetail() {
|
||||||
let targetPath = "/plugins/dev.json";
|
let targetPath = "plugins/dev.json";
|
||||||
if (access_token) {
|
if (access_token) {
|
||||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,7 @@ const deletePlugin = async (plugin) => {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
border-right: 1px solid #eee;
|
border-right: 1px solid #eee;
|
||||||
|
overflow: auto;
|
||||||
.item {
|
.item {
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rubick",
|
"name": "rubick",
|
||||||
"version": "2.0.1-beta.18",
|
"version": "2.0.1-beta.19",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
@ -14,12 +14,14 @@
|
|||||||
"postuninstall": "electron-builder install-app-deps"
|
"postuninstall": "electron-builder install-app-deps"
|
||||||
},
|
},
|
||||||
"main": "background.js",
|
"main": "background.js",
|
||||||
|
"optionalDependencies": {
|
||||||
|
"electron-clipboard-ex": "^1.3.3"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-scroll/core": "^2.4.2",
|
"@better-scroll/core": "^2.4.2",
|
||||||
"ant-design-vue": "^2.2.8",
|
"ant-design-vue": "^2.2.8",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"electron-clipboard-ex": "^1.3.3",
|
|
||||||
"extract-file-icon": "^0.3.2",
|
"extract-file-icon": "^0.3.2",
|
||||||
"fix-path": "^3.0.0",
|
"fix-path": "^3.0.0",
|
||||||
"get-mac-apps": "^1.0.2",
|
"get-mac-apps": "^1.0.2",
|
||||||
|
2
public/feature/css/app.efef6e76.css
Normal file
2
public/feature/css/app.efef6e76.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>feature</title><link href="css/app.f8214d90.css" rel="preload" as="style"><link href="js/app.1b7d9360.js" rel="preload" as="script"><link href="js/chunk-vendors.335eb4e0.js" rel="preload" as="script"><link href="css/app.f8214d90.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but feature doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.335eb4e0.js"></script><script src="js/app.1b7d9360.js"></script></body></html>
|
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>feature</title><link href="css/app.efef6e76.css" rel="preload" as="style"><link href="js/app.b6f0fed9.js" rel="preload" as="script"><link href="js/chunk-vendors.335eb4e0.js" rel="preload" as="script"><link href="css/app.efef6e76.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but feature doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.335eb4e0.js"></script><script src="js/app.b6f0fed9.js"></script></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
public/feature/js/app.b6f0fed9.js
Normal file
2
public/feature/js/app.b6f0fed9.js
Normal file
File diff suppressed because one or more lines are too long
1
public/feature/js/app.b6f0fed9.js.map
Normal file
1
public/feature/js/app.b6f0fed9.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -1,3 +1,217 @@
|
|||||||
|
import path from "path";
|
||||||
|
import originfs from "original-fs";
|
||||||
|
|
||||||
|
const app_paths = [
|
||||||
|
"/usr/share/applications",
|
||||||
|
"/var/lib/snapd/desktop/applications",
|
||||||
|
`${window.process.env.HOME}/.local/share/applications`,
|
||||||
|
];
|
||||||
|
const emptyIcon = "";
|
||||||
|
|
||||||
|
function dirAppRead(dir, target) {
|
||||||
|
let files: Array<string> | null = null;
|
||||||
|
try {
|
||||||
|
if (!originfs.existsSync(dir)) return;
|
||||||
|
files = originfs.readdirSync(dir);
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (files.length !== 0) {
|
||||||
|
for (const file of files) {
|
||||||
|
const app = path.join(dir, file);
|
||||||
|
path.extname(app) === ".desktop" && target.push(app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertEntryFile2Feature(appPath) {
|
||||||
|
let appInfo: any = null;
|
||||||
|
try {
|
||||||
|
appInfo = originfs.readFileSync(appPath, "utf8");
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!appInfo.includes("[Desktop Entry]")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
appInfo = appInfo
|
||||||
|
.substr(appInfo.indexOf("[Desktop Entry]"))
|
||||||
|
.replace("[Desktop Entry]", "")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* appInfo eg:
|
||||||
|
* Version=1.0
|
||||||
|
* Name=FireFox
|
||||||
|
* Name[ar]=***
|
||||||
|
* Name[ast]=***
|
||||||
|
* [Desktop Action new-private-window]
|
||||||
|
* Name=***
|
||||||
|
*/
|
||||||
|
const splitIndex = appInfo.indexOf("\n[");
|
||||||
|
|
||||||
|
if (splitIndex > 0) {
|
||||||
|
appInfo = appInfo.substr(0, splitIndex).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetAppInfo: any = {};
|
||||||
|
appInfo.match(/^[\w\-[\]]+ ?=.*$/gm).forEach((e) => {
|
||||||
|
const index = e.indexOf("=");
|
||||||
|
targetAppInfo[e.substr(0, index).trim()] = e.substr(index + 1).trim();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* targetAppInfo = {
|
||||||
|
* Type: "Application",
|
||||||
|
* Version: "1.0",
|
||||||
|
* Exec: "xxxx",
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (targetAppInfo.Type !== "Application") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!targetAppInfo.Exec) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
targetAppInfo.NoDisplay === "true" &&
|
||||||
|
!targetAppInfo.Exec.startsWith("gnome-control-center")
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let os = String(window.process.env.DESKTOP_SESSION).toLowerCase();
|
||||||
|
if (os === "ubuntu") {
|
||||||
|
os = "gnome";
|
||||||
|
if (
|
||||||
|
targetAppInfo.OnlyShowIn &&
|
||||||
|
!targetAppInfo.OnlyShowIn.toLowerCase().includes(os)
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
targetAppInfo.NotShowIn &&
|
||||||
|
targetAppInfo.NotShowIn.toLowerCase().includes(os)
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let icon = targetAppInfo.Icon;
|
||||||
|
if (!icon) return null;
|
||||||
|
if (icon.startsWith("/")) {
|
||||||
|
if (!originfs.existsSync(icon)) return null;
|
||||||
|
} else if (
|
||||||
|
appPath.startsWith("/usr/share/applications") ||
|
||||||
|
appPath.startsWith("/var/lib/snapd/desktop/applications")
|
||||||
|
) {
|
||||||
|
icon = getIcon(icon);
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
!appPath.startsWith(
|
||||||
|
(window as any).process.env.HOME + "/.local/share/applications"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return null;
|
||||||
|
appPath = path.join(
|
||||||
|
(window as any).process.env.HOME,
|
||||||
|
".local/share/icons",
|
||||||
|
appPath + ".png"
|
||||||
|
);
|
||||||
|
originfs.existsSync(appPath) || (appPath = emptyIcon);
|
||||||
|
}
|
||||||
|
let desc = "";
|
||||||
|
const LANG = (window as any).process.env.LANG.split(".")[0];
|
||||||
|
if (`Comment[${LANG}]` in targetAppInfo) {
|
||||||
|
desc = targetAppInfo[`Comment[${LANG}]`];
|
||||||
|
} else if (targetAppInfo.Comment) {
|
||||||
|
desc = targetAppInfo.Comment;
|
||||||
|
} else {
|
||||||
|
desc = appPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
let execPath = targetAppInfo.Exec.replace(/ %[A-Za-z]/g, "")
|
||||||
|
.replace(/"/g, "")
|
||||||
|
.trim();
|
||||||
|
targetAppInfo.Terminal === "true" &&
|
||||||
|
(execPath = "gnome-terminal -x " + execPath);
|
||||||
|
|
||||||
|
const info = {
|
||||||
|
value: "plugin",
|
||||||
|
pluginType: "app",
|
||||||
|
desc,
|
||||||
|
icon: "file://" + icon,
|
||||||
|
keyWords: [targetAppInfo.Name],
|
||||||
|
action: execPath,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ("X-Ubuntu-Gettext-Domain" in targetAppInfo) {
|
||||||
|
const cmd = targetAppInfo["X-Ubuntu-Gettext-Domain"];
|
||||||
|
cmd && cmd !== targetAppInfo.Name && info.keyWords.push(cmd);
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIcon(filePath) {
|
||||||
|
const themes = [
|
||||||
|
"ubuntu-mono-dark",
|
||||||
|
"ubuntu-mono-light",
|
||||||
|
"Yaru",
|
||||||
|
"hicolor",
|
||||||
|
"Adwaita",
|
||||||
|
"Humanity",
|
||||||
|
];
|
||||||
|
|
||||||
|
const sizes = ["48x48", "48", "scalable", "256x256", "512x512", "256", "512"];
|
||||||
|
const types = [
|
||||||
|
"apps",
|
||||||
|
"categories",
|
||||||
|
"devices",
|
||||||
|
"mimetypes",
|
||||||
|
"legacy",
|
||||||
|
"actions",
|
||||||
|
"places",
|
||||||
|
"status",
|
||||||
|
"mimes",
|
||||||
|
];
|
||||||
|
const exts = [".png", ".svg"];
|
||||||
|
for (const theme of themes) {
|
||||||
|
for (const size of sizes) {
|
||||||
|
for (const type of types) {
|
||||||
|
for (const ext of exts) {
|
||||||
|
let iconPath = path.join(
|
||||||
|
"/usr/share/icons",
|
||||||
|
theme,
|
||||||
|
size,
|
||||||
|
type,
|
||||||
|
filePath + ext
|
||||||
|
);
|
||||||
|
if (originfs.existsSync(iconPath)) return iconPath;
|
||||||
|
iconPath = path.join(
|
||||||
|
"/usr/share/icons",
|
||||||
|
theme,
|
||||||
|
type,
|
||||||
|
size,
|
||||||
|
filePath + ext
|
||||||
|
);
|
||||||
|
if (originfs.existsSync(iconPath)) return iconPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return originfs.existsSync(path.join("/usr/share/pixmaps", filePath + ".png"))
|
||||||
|
? path.join("/usr/share/pixmaps", filePath + ".png")
|
||||||
|
: emptyIcon;
|
||||||
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
// todo linux search
|
const apps: any = [];
|
||||||
|
const fileList = [];
|
||||||
|
app_paths.forEach((dir) => {
|
||||||
|
dirAppRead(dir, fileList);
|
||||||
|
});
|
||||||
|
|
||||||
|
fileList.forEach((e) => {
|
||||||
|
apps.push(convertEntryFile2Feature(e));
|
||||||
|
});
|
||||||
|
return apps.filter((app) => !!app);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user