feat(support-info): add app support information

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-09 09:52:45 +08:00
1 parent 328147b559
commit 28db8bc1b8
16 files changed
+564 -3

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
import type { AppSupportInfo } from "@/lib/backend/tauri";
export interface AppSupportInfoLabels {
appVersion: string;
runtime: string;
runtimeDesktop: string;
runtimeWeb: string;
operatingSystem: string;
architecture: string;
unknown: string;
}
export interface AppSupportInfoRow {
key: keyof Pick<AppSupportInfoLabels, "appVersion" | "runtime" | "operatingSystem" | "architecture">;
label: string;
value: string;
}
export function normalizeSupportInfoVersion(version: string | null | undefined, unknownLabel: string): string {
const trimmed = version?.trim();
if (!trimmed) return unknownLabel;
return trimmed.startsWith("v") || trimmed.startsWith("V") ? `v${trimmed.slice(1)}` : `v${trimmed}`;
}
export function formatSupportInfoRuntime(runtime: AppSupportInfo["runtime"], labels: AppSupportInfoLabels): string {
if (runtime === "desktop") return labels.runtimeDesktop;
if (runtime === "web") return labels.runtimeWeb;
return labels.unknown;
}
export function formatSupportInfoOperatingSystem(info: AppSupportInfo, unknownLabel: string): string {
const name = info.osName?.trim();
const version = info.osVersion?.trim();
if (!name && !version) return unknownLabel;
return [name, version].filter(Boolean).join(" ");
}
export function buildAppSupportInfoRows(info: AppSupportInfo, labels: AppSupportInfoLabels): AppSupportInfoRow[] {
return [
{
key: "appVersion",
label: labels.appVersion,
value: normalizeSupportInfoVersion(info.appVersion, labels.unknown),
},
{
key: "runtime",
label: labels.runtime,
value: formatSupportInfoRuntime(info.runtime, labels),
},
{
key: "operatingSystem",
label: labels.operatingSystem,
value: formatSupportInfoOperatingSystem(info, labels.unknown),
},
{
key: "architecture",
label: labels.architecture,
value: info.arch?.trim() || labels.unknown,
},
];
}
export function formatAppSupportInfoForClipboard(info: AppSupportInfo, labels: AppSupportInfoLabels): string {
return buildAppSupportInfoRows(info, labels)
.map((row) => `${row.label}: ${row.value}`)
.join("\n");
}
+2
View File
@@ -440,6 +440,7 @@ export const checkForUpdates = forward("checkForUpdates");
export const getSystemProxyUrl = forward("getSystemProxyUrl");
export const downloadAndInstallUpdate = forward("downloadAndInstallUpdate");
export const getAppVersion = forward("getAppVersion");
export const getAppSupportInfo = forward("getAppSupportInfo");
// Layout
export const saveSidebarLayout = forward("saveSidebarLayout");
@@ -450,6 +451,7 @@ export const loadSidebarLayout = forward("loadSidebarLayout");
// ---------------------------------------------------------------------------
export type {
AppSupportInfo,
AiMessage,
AiCompletionRequest,
AiTaskContract,
+12
View File
@@ -97,6 +97,7 @@ import type {
ExplainSqlBuildResult,
DroppedFilePreviewSqlOptions,
MongoGridFsFileInfo,
AppSupportInfo,
} from "@/lib/backend/tauri";
import type { QueryEditability } from "@/lib/sql/sqlAnalysis";
import type {
@@ -2102,6 +2103,17 @@ export async function getAppVersion(): Promise<string> {
return res.version;
}
export async function getAppSupportInfo(): Promise<AppSupportInfo> {
const appVersion = await getAppVersion();
return {
appVersion,
runtime: "web",
osName: navigator.platform || "web",
osVersion: null,
arch: "",
};
}
// ---------------------------------------------------------------------------
// Layout
// ---------------------------------------------------------------------------
+12
View File
@@ -200,6 +200,14 @@ export interface WebDavSyncSecretsStatus {
hasSavedPassphrase: boolean;
}
export interface AppSupportInfo {
appVersion: string;
runtime: "desktop" | "web";
osName: string;
osVersion?: string | null;
arch: string;
}
export interface QueryPagination {
limit: number;
offset: number;
@@ -1301,6 +1309,10 @@ export async function getAppVersion(): Promise<string> {
return getVersion();
}
export async function getAppSupportInfo(): Promise<AppSupportInfo> {
return invoke<AppSupportInfo>("get_app_support_info");
}
// --- Redis ---
export interface RedisKeyInfo {
key_display: string;