feat(driver): honor selected driver download source

This commit is contained in:
二丫讲梵 2026-07-17 15:30:04 +08:00 committed by GitHub
parent 1e1d424164
commit f6ecd3c881
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 1 deletions

View File

@ -239,6 +239,7 @@ const usageSummary = computed(() => {
];
});
const canClearDownloadCache = computed(() => !clearingDownloadCache.value && installing.value === null && !upgradingAll.value && reinstallingJre.value === null && downloadCacheBytes.value > 0);
const downloadSourceBusy = computed(() => refreshing.value || installing.value !== null || upgradingAll.value || queuedDriverInstalls.value.length > 0 || reinstallingJre.value !== null);
const jreUsageByKey = computed(() => {
const map = new Map<string, number>();
for (const item of driverStoreUsage.value?.jres || []) {
@ -330,6 +331,13 @@ async function forceRefresh() {
}
}
function setUpdateDownloadSource(value: unknown) {
if (value !== "official" && value !== "cnb" && value !== "atomgit") return;
if (value === settingsStore.editorSettings.updateDownloadSource) return;
settingsStore.updateEditorSettings({ updateDownloadSource: value });
void forceRefresh().catch(() => undefined);
}
async function loadJavaRuntimeConfig() {
const config = await api.getAgentJavaRuntimeConfig();
javaRuntimeConfig.value = config;
@ -1143,7 +1151,20 @@ watch(driverStoreTab, (tab) => {
{{ t("driverStore.storageTab") }}
</TabsTrigger>
</TabsList>
<div v-if="driverStoreTab !== 'storage'" class="flex items-center gap-2">
<div v-if="driverStoreTab !== 'storage'" class="flex flex-wrap items-center gap-2">
<div v-if="driverStoreTab === 'agent' && !isWeb" class="flex items-center gap-1.5">
<span class="text-xs text-muted-foreground">{{ t("settings.updateDownloadSource") }}</span>
<Select :model-value="settingsStore.editorSettings.updateDownloadSource" :disabled="downloadSourceBusy" @update:model-value="setUpdateDownloadSource">
<SelectTrigger class="h-7 w-[160px] rounded-[6px] text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="official">{{ t("settings.updateDownloadSourceOfficial") }}</SelectItem>
<SelectItem value="cnb">{{ t("settings.updateDownloadSourceCnb") }}</SelectItem>
<SelectItem value="atomgit">{{ t("settings.updateDownloadSourceAtomgit") }}</SelectItem>
</SelectContent>
</Select>
</div>
<Button variant="ghost" size="sm" class="h-7 rounded-[6px] text-xs gap-1 text-muted-foreground" :disabled="importingZip" @click="importOfflineZip">
<FileUp class="h-3.5 w-3.5" />
{{ importingZip ? t("driverStore.importing") : t("driverStore.importOfflinePackage") }}

View File

@ -0,0 +1,23 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
import { test } from "vitest";
function source(relativePath: string): string {
return readFileSync(path.resolve(relativePath), "utf8");
}
test("shares the configured download source with agent driver management", () => {
const driverStore = source("apps/desktop/src/components/config/DriverStoreDialog.vue");
const backendApi = source("apps/desktop/src/lib/backend/api.ts");
assert.match(driverStore, /driverStoreTab === 'agent' && !isWeb/);
assert.match(driverStore, /:model-value="settingsStore\.editorSettings\.updateDownloadSource"/);
assert.match(driverStore, /settingsStore\.updateEditorSettings\(\{ updateDownloadSource: value \}\)/);
assert.match(driverStore, /void forceRefresh\(\)\.catch\(\(\) => undefined\)/);
assert.match(backendApi, /backend\.listInstalledAgents\(useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
assert.match(backendApi, /backend\.installAgent\(dbType, useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
assert.match(backendApi, /backend\.upgradeAllAgents\(useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
assert.match(backendApi, /backend\.reinstallJre\(jreKey, useSettingsStore\(\)\.editorSettings\.updateDownloadSource\)/);
});