feat(updater): add entry to roll back to older versions
This commit is contained in:
15 files changed
+356
-18
No files matched your search
@@ -2,7 +2,7 @@
|
||||
import { createApp, defineComponent, h, reactive, nextTick, type App } from "vue";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import i18n from "@/i18n";
|
||||
import { useAppUpdater } from "@/composables/useAppUpdater";
|
||||
import { isNewerRemoteVersion, resolveReleaseTagUrl, useAppUpdater } from "@/composables/useAppUpdater";
|
||||
const mocks = vi.hoisted(() => ({
|
||||
checkForUpdates: vi.fn(),
|
||||
downloadUpdate: vi.fn(),
|
||||
@@ -71,6 +71,23 @@ afterEach(() => {
|
||||
app?.unmount();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
describe("older version release pages", () => {
|
||||
it("maps a historical version to the matching GitHub release page", () => {
|
||||
expect(resolveReleaseTagUrl("0.5.59", "official")).toBe("https://github.com/t8y2/dbx/releases/tag/v0.5.59");
|
||||
expect(resolveReleaseTagUrl("v0.5.59", "official")).toBe("https://github.com/t8y2/dbx/releases/tag/v0.5.59");
|
||||
});
|
||||
|
||||
it("uses the CNB release page when the CNB download source is selected", () => {
|
||||
expect(resolveReleaseTagUrl("v0.5.59", "cnb")).toBe("https://cnb.cool/dbxio.com/dbx/-/releases/tag/v0.5.59");
|
||||
});
|
||||
|
||||
it("treats only strictly older releases as rollback candidates", () => {
|
||||
expect(isNewerRemoteVersion("0.5.60", "v0.5.59")).toBe(true);
|
||||
expect(isNewerRemoteVersion("0.5.60", "v0.5.60")).toBe(false);
|
||||
expect(isNewerRemoteVersion("0.5.60", "v0.5.61")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("silent update lifecycle", () => {
|
||||
it("checks and shows a badge without downloading when automatic downloads are disabled", async () => {
|
||||
settings.autoUpdateApp = false;
|
||||
|
||||
@@ -106,6 +106,18 @@ export function resolveUpdateReleaseUrl(info: api.UpdateInfo | null, source: unk
|
||||
return info?.release_url || fallbackUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按版本 tag 解析“下载页”地址:CNB 源指向 CNB 的 release 页,其余指向 GitHub release 页。
|
||||
* 用于历史版本回退:只做跳转,不在应用内下载/安装旧版本。
|
||||
*/
|
||||
export function resolveReleaseTagUrl(tag: string, source: unknown): string {
|
||||
const normalizedTag = tagVersion(tag);
|
||||
if (normalizeUpdateDownloadSource(source) === "cnb") {
|
||||
return `https://cnb.cool/dbxio.com/dbx/-/releases/tag/${encodeURIComponent(normalizedTag)}`;
|
||||
}
|
||||
return `https://github.com/t8y2/dbx/releases/tag/${encodeURIComponent(normalizedTag)}`;
|
||||
}
|
||||
|
||||
export async function resolveUpdaterProxy(): Promise<string | undefined> {
|
||||
if (!isTauriRuntime()) return undefined;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user