improve(settings): rework about support info and debug log layout
This commit is contained in:
13 files changed
+152
-41
No files matched your search
@@ -7,6 +7,10 @@ export interface AppSupportInfoLabels {
|
||||
runtimeWeb: string;
|
||||
operatingSystem: string;
|
||||
architecture: string;
|
||||
userAgent: string;
|
||||
databaseTypes: string;
|
||||
localDriverVersions: string;
|
||||
aiProviders: string;
|
||||
unknown: string;
|
||||
}
|
||||
|
||||
@@ -35,6 +39,10 @@ export function formatSupportInfoOperatingSystem(info: AppSupportInfo, unknownLa
|
||||
return [name, version].filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
export function collectBrowserSupportInfo(): string {
|
||||
return typeof navigator === "undefined" ? "" : navigator.userAgent?.trim() || "";
|
||||
}
|
||||
|
||||
export function buildAppSupportInfoRows(info: AppSupportInfo, labels: AppSupportInfoLabels): AppSupportInfoRow[] {
|
||||
return [
|
||||
{
|
||||
@@ -61,7 +69,13 @@ export function buildAppSupportInfoRows(info: AppSupportInfo, labels: AppSupport
|
||||
}
|
||||
|
||||
export function formatAppSupportInfoForClipboard(info: AppSupportInfo, labels: AppSupportInfoLabels): string {
|
||||
return buildAppSupportInfoRows(info, labels)
|
||||
.map((row) => `${row.label}: ${row.value}`)
|
||||
.join("\n");
|
||||
const rows = buildAppSupportInfoRows(info, labels).map((row) => `${row.label}: ${row.value}`);
|
||||
const extraRows: Array<[string, string | null | undefined]> = [];
|
||||
if (info.userAgent?.trim()) extraRows.push([labels.userAgent, info.userAgent]);
|
||||
if (info.databaseTypes?.length) extraRows.push([labels.databaseTypes, info.databaseTypes.join(", ")]);
|
||||
if (info.localDriverVersions?.length) {
|
||||
extraRows.push([labels.localDriverVersions, info.localDriverVersions.map((driver) => `${driver.dbType} ${driver.version}`).join(", ")]);
|
||||
}
|
||||
if (info.aiProviders?.length) extraRows.push([labels.aiProviders, info.aiProviders.join(", ")]);
|
||||
return rows.concat(extraRows.map(([label, value]) => `${label}: ${value?.trim() || labels.unknown}`)).join("\n");
|
||||
}
|
||||
@@ -247,6 +247,7 @@ import type {
|
||||
} from "@/types/nacos";
|
||||
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
|
||||
import { appendDebugLog, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
|
||||
import { collectBrowserSupportInfo } from "@/lib/app/supportInfo";
|
||||
import { normalizeConnectionTestResult } from "@/lib/connection/connectionDatabaseInfo";
|
||||
import type { AnnotationFile, SchemaSnapshot } from "@/docs/types";
|
||||
|
||||
@@ -4526,6 +4527,7 @@ export async function getAppSupportInfo(): Promise<AppSupportInfo> {
|
||||
osName: navigator.platform || "web",
|
||||
osVersion: null,
|
||||
arch: "",
|
||||
userAgent: collectBrowserSupportInfo(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { invoke as tauriInvoke } from "@tauri-apps/api/core";
|
||||
import { assertUpdateAllowsCommand } from "@/lib/app/updatePreparation";
|
||||
import { collectBrowserSupportInfo } from "@/lib/app/supportInfo";
|
||||
|
||||
function invoke<T>(command: string, args?: Record<string, unknown>): Promise<T> {
|
||||
assertUpdateAllowsCommand(command);
|
||||
@@ -371,6 +372,10 @@ export interface AppSupportInfo {
|
||||
osName: string;
|
||||
osVersion?: string | null;
|
||||
arch: string;
|
||||
userAgent?: string;
|
||||
databaseTypes?: string[];
|
||||
localDriverVersions?: Array<{ dbType: string; version: string }>;
|
||||
aiProviders?: string[];
|
||||
}
|
||||
|
||||
export interface QueryPagination {
|
||||
@@ -2559,7 +2564,8 @@ export async function getAppVersion(): Promise<string> {
|
||||
}
|
||||
|
||||
export async function getAppSupportInfo(): Promise<AppSupportInfo> {
|
||||
return invoke<AppSupportInfo>("get_app_support_info");
|
||||
const info = await invoke<AppSupportInfo>("get_app_support_info");
|
||||
return { ...info, userAgent: collectBrowserSupportInfo() };
|
||||
}
|
||||
|
||||
// --- Redis ---
|
||||
|
||||
Reference in new issue
Block a user