Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

style: format files to fix CI

t8y2243b49038a47
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index ddd4678d1d..f0053885b1 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -1543,12 +1543,7 @@ onUnmounted(() => {
@download-and-install="downloadAndInstallUpdate"
@restart="restartApp"
/>
- <CloseActionPromptDialog
- v-if="isDesktop"
- v-model:open="showCloseActionPrompt"
- @quit="chooseQuit"
- @minimize="chooseMinimize"
- />
+ <CloseActionPromptDialog v-if="isDesktop" v-model:open="showCloseActionPrompt" @quit="chooseQuit" @minimize="chooseMinimize" />
<QuickOpenDialog :open="showQuickOpen" @update:open="showQuickOpen = $event" @select="handleQuickOpenSelect" />
</div>
<Teleport to="body">
diff --git a/apps/desktop/src/lib/dataGridColumnLayoutStorage.ts b/apps/desktop/src/lib/dataGridColumnLayoutStorage.ts
index 21d8955a49..d1e868b104 100644
--- a/apps/desktop/src/lib/dataGridColumnLayoutStorage.ts
+++ b/apps/desktop/src/lib/dataGridColumnLayoutStorage.ts
@@ -4,65 +4,55 @@ const STORAGE_PREFIX = "dbx-data-grid-column-layout:";
const STORAGE_VERSION = 1;
export interface DataGridColumnLayoutScope {
- connectionId?: string;
- database?: string;
- schema?: string;
- context?: string;
- tableSchema?: string;
- tableName?: string;
- sql?: string;
- columns: readonly string[];
- sourceColumns?: readonly (string | undefined)[];
+ connectionId?: string;
+ database?: string;
+ schema?: string;
+ context?: string;
+ tableSchema?: string;
+ tableName?: string;
+ sql?: string;
+ columns: readonly string[];
+ sourceColumns?: readonly (string | undefined)[];
}
interface StoredDataGridColumnLayout {
- version: number;
- columnSignature: string;
- order: string[];
+ version: number;
+ columnSignature: string;
+ order: string[];
}
function normalizeSql(sql?: string): string {
- return (sql ?? "").replace(/\s+/g, " ").trim();
+ return (sql ?? "").replace(/\s+/g, " ").trim();
}
export function dataGridColumnLayoutScopeKey(scope: DataGridColumnLayoutScope): string {
- const columnSignature = scope.columns.join("\0");
- const sourceSignature = (scope.sourceColumns ?? []).map((column) => column ?? "").join("\0");
- return [
- scope.connectionId ?? "",
- scope.database ?? "",
- scope.schema ?? "",
- scope.context ?? "",
- scope.tableSchema ?? "",
- scope.tableName ?? "",
- scope.tableName ? "" : normalizeSql(scope.sql),
- columnSignature,
- sourceSignature,
- ].join("\u0001");
+ const columnSignature = scope.columns.join("\0");
+ const sourceSignature = (scope.sourceColumns ?? []).map((column) => column ?? "").join("\0");
+ return [scope.connectionId ?? "", scope.database ?? "", scope.schema ?? "", scope.context ?? "", scope.tableSchema ?? "", scope.tableName ?? "", scope.tableName ? "" : normalizeSql(scope.sql), columnSignature, sourceSignature].join("\u0001");
}
export function loadDataGridColumnOrder(scopeKey: string, columnKeys: readonly string[]): string[] {
- const raw = safeLocalStorageGet(`${STORAGE_PREFIX}${scopeKey}`);
- if (!raw) return [];
- try {
- const parsed = JSON.parse(raw) as Partial<StoredDataGridColumnLayout>;
- if (parsed.version !== STORAGE_VERSION || !Array.isArray(parsed.order)) return [];
- if (parsed.columnSignature && parsed.columnSignature !== columnKeys.join("\0")) return [];
- return parsed.order.filter((key): key is string => typeof key === "string");
- } catch {
- return [];
- }
+ const raw = safeLocalStorageGet(`${STORAGE_PREFIX}${scopeKey}`);
+ if (!raw) return [];
+ try {
+ const parsed = JSON.parse(raw) as Partial<StoredDataGridColumnLayout>;
+ if (parsed.version !== STORAGE_VERSION || !Array.isArray(parsed.order)) return [];
+ if (parsed.columnSignature && parsed.columnSignature !== columnKeys.join("\0")) return [];
+ return parsed.order.filter((key): key is string => typeof key === "string");
+ } catch {
+ return [];
+ }
}
export function saveDataGridColumnOrder(scopeKey: string, columnKeys: readonly string[], order: readonly string[]) {
- const payload: StoredDataGridColumnLayout = {
- version: STORAGE_VERSION,
- columnSignature: columnKeys.join("\0"),
- order: [...order],
- };
- safeLocalStorageSet(`${STORAGE_PREFIX}${scopeKey}`, JSON.stringify(payload));
+ const payload: StoredDataGridColumnLayout = {
+ version: STORAGE_VERSION,
+ columnSignature: columnKeys.join("\0"),
+ order: [...order],
+ };
+ safeLocalStorageSet(`${STORAGE_PREFIX}${scopeKey}`, JSON.stringify(payload));
}
export function removeDataGridColumnOrder(scopeKey: string) {
- safeLocalStorageRemove(`${STORAGE_PREFIX}${scopeKey}`);
+ safeLocalStorageRemove(`${STORAGE_PREFIX}${scopeKey}`);
}
diff --git a/apps/desktop/src/lib/dataGridColumnOrder.ts b/apps/desktop/src/lib/dataGridColumnOrder.ts
index 12ee0fa1c5..62c363ceca 100644
--- a/apps/desktop/src/lib/dataGridColumnOrder.ts
+++ b/apps/desktop/src/lib/dataGridColumnOrder.ts
@@ -1,67 +1,67 @@
export function uniqueDataGridColumnOrderKeys(columns: readonly string[], sourceColumns?: readonly (string | undefined)[]): string[] {
- const counts = new Map<string, number>();
- return columns.map((column, index) => {
- const base = sourceColumns?.[index] || column || `#${index + 1}`;
- const count = counts.get(base) ?? 0;
- counts.set(base, count + 1);
- return `${base}\u0000${count}`;
- });
+ const counts = new Map<string, number>();
+ return columns.map((column, index) => {
+ const base = sourceColumns?.[index] || column || `#${index + 1}`;
+ const count = counts.get(base) ?? 0;
+ counts.set(base, count + 1);
+ return `${base}\u0000${count}`;
+ });
}
export function orderedColumnIndexes(options: { availableIndexes: readonly number[]; columnKeys: readonly string[]; orderedKeys: readonly string[] }): number[] {
- const available = new Set(options.availableIndexes);
- const indexByKey = new Map<string, number>();
- for (const index of options.availableIndexes) {
- const key = options.columnKeys[index];
- if (key) indexByKey.set(key, index);
- }
+ const available = new Set(options.availableIndexes);
+ const indexByKey = new Map<string, number>();
+ for (const index of options.availableIndexes) {
+ const key = options.columnKeys[index];
+ if (key) indexByKey.set(key, index);
+ }
- const used = new Set<number>();
- const ordered: number[] = [];
- for (const key of options.orderedKeys) {
- const index = indexByKey.get(key);
- if (index === undefined || !available.has(index) || used.has(index)) continue;
- ordered.push(index);
- used.add(index);
- }
+ const used = new Set<number>();
+ const ordered: number[] = [];
+ for (const key of options.orderedKeys) {
+ const index = indexByKey.get(key);
+ if (index === undefined || !available.has(index) || used.has(index)) continue;
+ ordered.push(index);
+ used.add(index);
+ }
- for (const index of options.availableIndexes) {
- if (!used.has(index)) ordered.push(index);
- }
+ for (const index of options.availableIndexes) {
+ if (!used.has(index)) ordered.push(index);
+ }
- return ordered;
+ return ordered;
}
export function moveVisibleColumnIndex(options: { orderedIndexes: readonly number[]; hiddenIndexes: ReadonlySet<number>; fromVisibleIndex: number; toVisibleIndex: number }): number[] {
- const visibleIndexes = options.orderedIndexes.filter((index) => !options.hiddenIndexes.has(index));
- const fromActualIndex = visibleIndexes[options.fromVisibleIndex];
- if (fromActualIndex === undefined) return [...options.orderedIndexes];
+ const visibleIndexes = options.orderedIndexes.filter((index) => !options.hiddenIndexes.has(index));
+ const fromActualIndex = visibleIndexes[options.fromVisibleIndex];
+ if (fromActualIndex === undefined) return [...options.orderedIndexes];
- const withoutSource = options.orderedIndexes.filter((index) => index !== fromActualIndex);
- const visibleWithoutSource = visibleIndexes.filter((index) => index !== fromActualIndex);
- const targetVisibleIndex = Math.max(0, Math.min(options.toVisibleIndex, visibleWithoutSource.length));
- if (options.fromVisibleIndex === targetVisibleIndex) return [...options.orderedIndexes];
+ const withoutSource = options.orderedIndexes.filter((index) => index !== fromActualIndex);
+ const visibleWithoutSource = visibleIndexes.filter((index) => index !== fromActualIndex);
+ const targetVisibleIndex = Math.max(0, Math.min(options.toVisibleIndex, visibleWithoutSource.length));
+ if (options.fromVisibleIndex === targetVisibleIndex) return [...options.orderedIndexes];
- const next = [...withoutSource];
- if (targetVisibleIndex >= visibleWithoutSource.length) {
- const lastVisibleIndex = visibleWithoutSource[visibleWithoutSource.length - 1];
- const insertAfterIndex = lastVisibleIndex === undefined ? next.length - 1 : next.indexOf(lastVisibleIndex);
- next.splice(insertAfterIndex + 1, 0, fromActualIndex);
- return next;
- }
-
- const targetActualIndex = visibleWithoutSource[targetVisibleIndex];
- const insertIndex = targetActualIndex === undefined ? next.length : next.indexOf(targetActualIndex);
- if (insertIndex < 0) return [...options.orderedIndexes];
- next.splice(insertIndex, 0, fromActualIndex);
+ const next = [...withoutSource];
+ if (targetVisibleIndex >= visibleWithoutSource.length) {
+ const lastVisibleIndex = visibleWithoutSource[visibleWithoutSource.length - 1];
+ const insertAfterIndex = lastVisibleIndex === undefined ? next.length - 1 : next.indexOf(lastVisibleIndex);
+ next.splice(insertAfterIndex + 1, 0, fromActualIndex);
return next;
+ }
+
+ const targetActualIndex = visibleWithoutSource[targetVisibleIndex];
+ const insertIndex = targetActualIndex === undefined ? next.length : next.indexOf(targetActualIndex);
+ if (insertIndex < 0) return [...options.orderedIndexes];
+ next.splice(insertIndex, 0, fromActualIndex);
+ return next;
}
export function columnOrderKeysForIndexes(indexes: readonly number[], columnKeys: readonly string[]): string[] {
- return indexes.map((index) => columnKeys[index]).filter((key): key is string => !!key);
+ return indexes.map((index) => columnKeys[index]).filter((key): key is string => !!key);
}
export function isDefaultColumnOrder(availableIndexes: readonly number[], orderedIndexes: readonly number[]): boolean {
- if (availableIndexes.length !== orderedIndexes.length) return false;
- return availableIndexes.every((index, position) => orderedIndexes[position] === index);
+ if (availableIndexes.length !== orderedIndexes.length) return false;
+ return availableIndexes.every((index, position) => orderedIndexes[position] === index);
}