feat(settings): embed version changelog in About page
This commit is contained in:
1 parent
e9e59113a3
commit
aff9c8515d
20 files changed
+546
-1
No files matched your search
@@ -0,0 +1,76 @@
|
||||
export type ChangelogItem = {
|
||||
title: string;
|
||||
desc: string;
|
||||
};
|
||||
|
||||
export type ChangelogSection = {
|
||||
type: string;
|
||||
title: string;
|
||||
items: ChangelogItem[];
|
||||
};
|
||||
|
||||
export type ChangelogRelease = {
|
||||
tag: string;
|
||||
name: string;
|
||||
date: string;
|
||||
sections: ChangelogSection[];
|
||||
};
|
||||
|
||||
export type ChangelogData = {
|
||||
updatedAt: string;
|
||||
releases: ChangelogRelease[];
|
||||
};
|
||||
|
||||
export type ChangelogLang = "en" | "cn";
|
||||
|
||||
const cache = new Map<ChangelogLang, Promise<ChangelogData>>();
|
||||
|
||||
export function createLatestRequestGuard() {
|
||||
let latestRequestId = 0;
|
||||
return {
|
||||
begin: () => ++latestRequestId,
|
||||
isCurrent: (requestId: number) => requestId === latestRequestId,
|
||||
};
|
||||
}
|
||||
|
||||
export function changelogLangFromLocale(locale: string): ChangelogLang {
|
||||
return locale === "zh-CN" || locale === "zh-TW" ? "cn" : "en";
|
||||
}
|
||||
|
||||
export function changelogWebsiteUrl(lang: ChangelogLang): string {
|
||||
return `https://dbxio.com/${lang}/changelog`;
|
||||
}
|
||||
|
||||
export function changelogReleaseUrl(tag: string): string {
|
||||
return `https://github.com/t8y2/dbx/releases/tag/${encodeURIComponent(tag)}`;
|
||||
}
|
||||
|
||||
export async function fetchChangelog(lang: ChangelogLang, options: { force?: boolean } = {}): Promise<ChangelogData> {
|
||||
if (options.force) {
|
||||
cache.delete(lang);
|
||||
}
|
||||
|
||||
let pending = cache.get(lang);
|
||||
if (!pending) {
|
||||
pending = loadChangelog(lang).catch((error) => {
|
||||
cache.delete(lang);
|
||||
throw error;
|
||||
});
|
||||
cache.set(lang, pending);
|
||||
}
|
||||
|
||||
return pending;
|
||||
}
|
||||
|
||||
async function loadChangelog(lang: ChangelogLang): Promise<ChangelogData> {
|
||||
const { fetchChangelog: fetchChangelogViaBackend } = await import("@/lib/backend/api");
|
||||
const data = await fetchChangelogViaBackend(lang);
|
||||
if (!data || !Array.isArray(data.releases)) {
|
||||
throw new Error("Invalid changelog payload");
|
||||
}
|
||||
|
||||
return {
|
||||
updatedAt: typeof data.updatedAt === "string" ? data.updatedAt : "",
|
||||
releases: data.releases.filter((release) => release && typeof release.tag === "string"),
|
||||
};
|
||||
}
|
||||
@@ -466,6 +466,7 @@ export const deleteHistoryEntry = forward("deleteHistoryEntry");
|
||||
export const checkMcpServerStatus = forward("checkMcpServerStatus");
|
||||
export const installMcpServer = forward("installMcpServer");
|
||||
export const checkForUpdates = forward("checkForUpdates");
|
||||
export const fetchChangelog = forward("fetchChangelog");
|
||||
export const getSystemProxyUrl = forward("getSystemProxyUrl");
|
||||
export const downloadAndInstallUpdate = forward("downloadAndInstallUpdate");
|
||||
export const getAppVersion = forward("getAppVersion");
|
||||
|
||||
@@ -2166,6 +2166,11 @@ export async function checkForUpdates(locale?: string): Promise<UpdateInfo> {
|
||||
return get(`/api/update/check${query}`);
|
||||
}
|
||||
|
||||
export async function fetchChangelog(lang?: string): Promise<import("@/lib/app/changelog").ChangelogData> {
|
||||
const query = lang ? `?lang=${encodeURIComponent(lang)}` : "";
|
||||
return get(`/api/changelog${query}`);
|
||||
}
|
||||
|
||||
export async function checkMcpServerStatus(): Promise<import("@/lib/backend/tauri").McpServerStatus> {
|
||||
return {
|
||||
installed: false,
|
||||
|
||||
@@ -1392,6 +1392,10 @@ export async function checkForUpdates(locale?: string): Promise<UpdateInfo> {
|
||||
return invoke("check_for_updates", { locale });
|
||||
}
|
||||
|
||||
export async function fetchChangelog(lang?: string): Promise<import("@/lib/app/changelog").ChangelogData> {
|
||||
return invoke("fetch_changelog", { lang });
|
||||
}
|
||||
|
||||
export async function getSystemProxyUrl(): Promise<string | null> {
|
||||
return invoke("get_system_proxy_url");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user