mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 01:10:16 +08:00
update:apm管理改为应用管理
This commit is contained in:
@@ -791,10 +791,58 @@ ipcMain.on("remove-installed", async (_event, payload) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle("list-installed", async () => {
|
ipcMain.handle(
|
||||||
|
"list-installed",
|
||||||
|
async (_event, origin: "apm" | "spark" = "apm") => {
|
||||||
const apmBasePath = "/var/lib/apm/apm/files/ace-env/var/lib/apm";
|
const apmBasePath = "/var/lib/apm/apm/files/ace-env/var/lib/apm";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const installedApps: Array<{
|
||||||
|
pkgname: string;
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
arch: string;
|
||||||
|
flags: string;
|
||||||
|
origin: "spark" | "apm";
|
||||||
|
icon?: string;
|
||||||
|
isDependency: boolean;
|
||||||
|
}> = [];
|
||||||
|
|
||||||
|
if (origin === "spark") {
|
||||||
|
const { code, stdout } = await runCommandCapture("dpkg-query", [
|
||||||
|
"-W",
|
||||||
|
"-f=${Package} ${Version} ${Architecture}\\n",
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (code !== 0) {
|
||||||
|
logger.warn(`Failed to list installed packages: ${stdout}`);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to list installed packages",
|
||||||
|
apps: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const lines = stdout.split("\n");
|
||||||
|
for (const line of lines) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed) continue;
|
||||||
|
const parts = trimmed.split(" ");
|
||||||
|
if (parts.length >= 3) {
|
||||||
|
installedApps.push({
|
||||||
|
pkgname: parts[0],
|
||||||
|
name: parts[0],
|
||||||
|
version: parts[1],
|
||||||
|
arch: parts[2],
|
||||||
|
flags: "[installed]",
|
||||||
|
origin: "spark",
|
||||||
|
isDependency: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { success: true, apps: installedApps };
|
||||||
|
}
|
||||||
|
|
||||||
// 使用 apm list --installed 获取所有已安装应用
|
// 使用 apm list --installed 获取所有已安装应用
|
||||||
const { code, stdout } = await runCommandCapture("apm", [
|
const { code, stdout } = await runCommandCapture("apm", [
|
||||||
"list",
|
"list",
|
||||||
@@ -810,17 +858,6 @@ ipcMain.handle("list-installed", async () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const installedApps: Array<{
|
|
||||||
pkgname: string;
|
|
||||||
name: string;
|
|
||||||
version: string;
|
|
||||||
arch: string;
|
|
||||||
flags: string;
|
|
||||||
origin: "spark" | "apm";
|
|
||||||
icon?: string;
|
|
||||||
isDependency: boolean;
|
|
||||||
}> = [];
|
|
||||||
|
|
||||||
const cleanStdout = stdout.replace(
|
const cleanStdout = stdout.replace(
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
/\x1b\[[0-9;]*m/g,
|
/\x1b\[[0-9;]*m/g,
|
||||||
@@ -923,7 +960,8 @@ ipcMain.handle("list-installed", async () => {
|
|||||||
apps: [],
|
apps: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
ipcMain.handle("list-upgradable", async () => {
|
ipcMain.handle("list-upgradable", async () => {
|
||||||
const { code, stdout, stderr } = await runCommandCapture("apm", [
|
const { code, stdout, stderr } = await runCommandCapture("apm", [
|
||||||
|
|||||||
628
package-lock.json
generated
628
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
src/App.vue
26
src/App.vue
@@ -116,9 +116,11 @@
|
|||||||
:apps="installedApps"
|
:apps="installedApps"
|
||||||
:loading="installedLoading"
|
:loading="installedLoading"
|
||||||
:error="installedError"
|
:error="installedError"
|
||||||
|
:active-origin="activeInstalledOrigin"
|
||||||
@close="closeInstalledModal"
|
@close="closeInstalledModal"
|
||||||
@refresh="refreshInstalledApps"
|
@refresh="refreshInstalledApps"
|
||||||
@uninstall="uninstallInstalledApp"
|
@uninstall="uninstallInstalledApp"
|
||||||
|
@switch-origin="handleSwitchOrigin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UpdateAppsModal
|
<UpdateAppsModal
|
||||||
@@ -240,6 +242,7 @@ const loading = ref(true);
|
|||||||
const showDownloadDetailModal = ref(false);
|
const showDownloadDetailModal = ref(false);
|
||||||
const currentDownload: Ref<DownloadItem | null> = ref(null);
|
const currentDownload: Ref<DownloadItem | null> = ref(null);
|
||||||
const showInstalledModal = ref(false);
|
const showInstalledModal = ref(false);
|
||||||
|
const activeInstalledOrigin = ref<"apm" | "spark">("apm");
|
||||||
const installedApps = ref<App[]>([]);
|
const installedApps = ref<App[]>([]);
|
||||||
const installedLoading = ref(false);
|
const installedLoading = ref(false);
|
||||||
const installedError = ref("");
|
const installedError = ref("");
|
||||||
@@ -881,11 +884,17 @@ const closeInstalledModal = () => {
|
|||||||
showInstalledModal.value = false;
|
showInstalledModal.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSwitchOrigin = (origin: "apm" | "spark") => {
|
||||||
|
activeInstalledOrigin.value = origin;
|
||||||
|
refreshInstalledApps();
|
||||||
|
};
|
||||||
|
|
||||||
const refreshInstalledApps = async () => {
|
const refreshInstalledApps = async () => {
|
||||||
installedLoading.value = true;
|
installedLoading.value = true;
|
||||||
installedError.value = "";
|
installedError.value = "";
|
||||||
try {
|
try {
|
||||||
const result = await window.ipcRenderer.invoke("list-installed");
|
const origin = activeInstalledOrigin.value;
|
||||||
|
const result = await window.ipcRenderer.invoke("list-installed", origin);
|
||||||
if (!result?.success) {
|
if (!result?.success) {
|
||||||
installedApps.value = [];
|
installedApps.value = [];
|
||||||
installedError.value = result?.message || "读取已安装应用失败";
|
installedError.value = result?.message || "读取已安装应用失败";
|
||||||
@@ -894,7 +903,16 @@ const refreshInstalledApps = async () => {
|
|||||||
|
|
||||||
installedApps.value = [];
|
installedApps.value = [];
|
||||||
for (const app of result.apps) {
|
for (const app of result.apps) {
|
||||||
let appInfo = apps.value.find((a) => a.pkgname === app.pkgname);
|
// Find matching remote app to enrich data. We look exactly for that origin.
|
||||||
|
let appInfo = apps.value.find(
|
||||||
|
(a) => a.pkgname === app.pkgname && a.origin === origin,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (origin === "spark" && !appInfo) {
|
||||||
|
// Only show Spark packages that exist in the App Store catalogue
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (appInfo) {
|
if (appInfo) {
|
||||||
appInfo.flags = app.flags;
|
appInfo.flags = app.flags;
|
||||||
appInfo.arch = app.arch;
|
appInfo.arch = app.arch;
|
||||||
@@ -1298,7 +1316,9 @@ onMounted(async () => {
|
|||||||
} else {
|
} else {
|
||||||
// 如果找不到应用,回退到搜索模式
|
// 如果找不到应用,回退到搜索模式
|
||||||
searchQuery.value = data.pkgname;
|
searchQuery.value = data.pkgname;
|
||||||
logger.warn(`Deep link: app ${data.pkgname} not found, fallback to search`);
|
logger.warn(
|
||||||
|
`Deep link: app ${data.pkgname} not found, fallback to search`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
@click="$emit('list')"
|
@click="$emit('list')"
|
||||||
>
|
>
|
||||||
<i class="fas fa-download"></i>
|
<i class="fas fa-download"></i>
|
||||||
<span>APM 应用管理</span>
|
<span>应用管理</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -23,10 +23,38 @@
|
|||||||
已安装应用
|
已安装应用
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-slate-500 dark:text-slate-400">
|
<p class="text-sm text-slate-500 dark:text-slate-400">
|
||||||
来自本机 APM 安装列表
|
管理本机安装的应用程序
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
|
<div
|
||||||
|
class="flex items-center rounded-2xl border border-slate-200/70 p-1 dark:border-slate-800/70"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="rounded-xl px-4 py-1.5 text-sm font-semibold transition"
|
||||||
|
:class="
|
||||||
|
activeOrigin === 'apm'
|
||||||
|
? 'bg-brand/10 text-brand dark:bg-brand/15'
|
||||||
|
: 'text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200'
|
||||||
|
"
|
||||||
|
@click="$emit('switch-origin', 'apm')"
|
||||||
|
>
|
||||||
|
APM 软件
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="rounded-xl px-4 py-1.5 text-sm font-semibold transition"
|
||||||
|
:class="
|
||||||
|
activeOrigin === 'spark'
|
||||||
|
? 'bg-brand/10 text-brand dark:bg-brand/15'
|
||||||
|
: 'text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200'
|
||||||
|
"
|
||||||
|
@click="$emit('switch-origin', 'spark')"
|
||||||
|
>
|
||||||
|
Spark 软件
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200/70 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-50 disabled:opacity-40 dark:border-slate-700 dark:text-slate-200"
|
class="inline-flex items-center gap-2 rounded-2xl border border-slate-200/70 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-50 disabled:opacity-40 dark:border-slate-700 dark:text-slate-200"
|
||||||
@@ -137,11 +165,13 @@ defineProps<{
|
|||||||
apps: App[];
|
apps: App[];
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: string;
|
error: string;
|
||||||
|
activeOrigin: "apm" | "spark";
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(e: "close"): void;
|
(e: "close"): void;
|
||||||
(e: "refresh"): void;
|
(e: "refresh"): void;
|
||||||
(e: "uninstall", app: App): void;
|
(e: "uninstall", app: App): void;
|
||||||
|
(e: "switch-origin", origin: "apm" | "spark"): void;
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user