mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-05-30 01:31:06 +08:00
fix(update-center): handle missing apm and restore scrolling
This commit is contained in:
@@ -49,21 +49,6 @@ interface RemoteCategoryAppEntry {
|
||||
const REMOTE_STORE_BASE_URL = "https://erotica.spark-app.store";
|
||||
const categoryCache = new Map<string, Promise<StoreAppMetadataMap>>();
|
||||
|
||||
const isAptssAvailable = async (): Promise<boolean> => {
|
||||
return await new Promise((resolve) => {
|
||||
const child = spawn("command", ["-v", "aptss"], {
|
||||
shell: false,
|
||||
env: process.env,
|
||||
});
|
||||
child.on("close", (code) => {
|
||||
resolve(code === 0);
|
||||
});
|
||||
child.on("error", () => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const APTSS_LIST_UPGRADABLE_COMMAND = {
|
||||
command: "bash",
|
||||
args: [
|
||||
@@ -367,26 +352,23 @@ const enrichItemIcons = (items: UpdateCenterItem[]): UpdateCenterItem[] => {
|
||||
export const loadUpdateCenterItems = async (
|
||||
runCommand: UpdateCenterCommandRunner = runCommandCapture,
|
||||
): Promise<UpdateCenterLoadItemsResult> => {
|
||||
const aptssAvailable = await isAptssAvailable();
|
||||
|
||||
const [aptssResult, apmResult, aptssInstalledResult, apmInstalledResult] =
|
||||
await Promise.all([
|
||||
aptssAvailable
|
||||
? runCommand(
|
||||
runCommand(
|
||||
APTSS_LIST_UPGRADABLE_COMMAND.command,
|
||||
APTSS_LIST_UPGRADABLE_COMMAND.args,
|
||||
)
|
||||
: Promise.resolve({ code: 0, stdout: "", stderr: "" }),
|
||||
),
|
||||
runCommand("apm", ["list", "--upgradable"]),
|
||||
aptssAvailable
|
||||
? runCommand(
|
||||
runCommand(
|
||||
DPKG_QUERY_INSTALLED_COMMAND.command,
|
||||
DPKG_QUERY_INSTALLED_COMMAND.args,
|
||||
)
|
||||
: Promise.resolve({ code: 0, stdout: "", stderr: "" }),
|
||||
),
|
||||
runCommand("apm", ["list", "--installed"]),
|
||||
]);
|
||||
|
||||
const aptssAvailable =
|
||||
aptssResult.code === 0 || aptssInstalledResult.code === 0;
|
||||
|
||||
const warnings = [
|
||||
aptssAvailable
|
||||
? getCommandError("aptss upgradable query", aptssResult)
|
||||
@@ -405,10 +387,6 @@ export const loadUpdateCenterItems = async (
|
||||
const apmItems =
|
||||
apmResult.code === 0 ? parseApmUpgradableOutput(apmResult.stdout) : [];
|
||||
|
||||
if (apmResult.code !== 0) {
|
||||
throw new Error(warnings.join("; "));
|
||||
}
|
||||
|
||||
const installedSources = buildInstalledSourceMap(
|
||||
aptssAvailable && aptssInstalledResult.code === 0
|
||||
? aptssInstalledResult.stdout
|
||||
|
||||
@@ -91,6 +91,34 @@ const createStore = (
|
||||
};
|
||||
|
||||
describe("UpdateCenterModal", () => {
|
||||
it("constrains the update list so it can scroll with a visible scrollbar", () => {
|
||||
const store = createStore({
|
||||
items: Array.from({ length: 20 }, (_, index) =>
|
||||
createItem({
|
||||
taskKey: `aptss:spark-item-${index}`,
|
||||
packageName: `spark-item-${index}`,
|
||||
displayName: `Spark Item ${index}`,
|
||||
}),
|
||||
),
|
||||
tasks: [],
|
||||
warnings: [],
|
||||
hasRunningTasks: false,
|
||||
});
|
||||
|
||||
const { container } = render(UpdateCenterModal, {
|
||||
props: {
|
||||
show: true,
|
||||
store,
|
||||
},
|
||||
});
|
||||
|
||||
const scrollContainer = container.querySelector(".scrollbar-muted");
|
||||
|
||||
expect(scrollContainer?.className).toContain("overflow-y-auto");
|
||||
expect(scrollContainer?.className).toContain("flex-1");
|
||||
expect(scrollContainer?.className).toContain("overscroll-contain");
|
||||
});
|
||||
|
||||
it("renders source tags, running state, warnings, and migration marker", () => {
|
||||
const store = createStore();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="min-h-0 flex-1">
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<UpdateCenterList
|
||||
:items="store.filteredItems.value"
|
||||
:tasks="store.snapshot.value.tasks"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
class="min-h-0 overflow-y-auto overscroll-contain scrollbar-muted border-r border-slate-200/70 p-6 dark:border-slate-800/70"
|
||||
class="min-h-0 flex-1 overflow-y-auto overscroll-contain scrollbar-muted border-r border-slate-200/70 p-6 dark:border-slate-800/70"
|
||||
>
|
||||
<div
|
||||
v-if="items.length === 0"
|
||||
|
||||
Reference in New Issue
Block a user