fix(saved-sql): 修复 SQL 库连接关联丢失与历史文件不可见

* fix: 持久化并显示 SQL 库连接关联

* fix: 补充 SQL 库关联状态翻译

* chore: 修复数据标签页策略格式

---------

Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
zipgandzipg authored and GitHub committed 2026-08-05 23:58:32 +08:00
1 parent 580b70e1d4
commit 445b6473f4
18 files changed
+336 -115

No files matched your search

+13 -15
View File
@@ -7,6 +7,7 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";
import * as api from "@/lib/backend/api";
import type { SqlFileEntry } from "@/lib/backend/api";
import { getSqlFileFolderPaths, sqlFileFoldersVersion } from "@/lib/sqlFile/sqlFileFolders";
import i18n from "@/i18n";
const REMOTE_SEARCH_DEBOUNCE_MS = 180;
const REMOTE_SEARCH_MIN_QUERY_LENGTH = 2;
@@ -118,25 +119,22 @@ export function useQuickOpen() {
let sqlFilesLoadGeneration = 0;
function getConnectionLabel(connectionId: string): string {
if (!connectionId) return i18n.global.t("sqlLibrary.unassociated");
const conn = connectionStore.connections.find((c) => c.id === connectionId);
return conn?.name || connectionId;
return conn?.name || i18n.global.t("sqlLibrary.deletedConnection");
}
const sqlLibraryAllItems = computed<QuickOpenItem[]>(() => {
const activeConnectionIds = new Set(connectionStore.connections.map((c) => c.id));
const orphanedIds = savedSqlStore.orphanedFileIds(activeConnectionIds);
return savedSqlStore.allFiles
.filter((file) => !orphanedIds.has(file.id))
.map((file) => ({
id: `sqllib-${file.id}`,
type: "sql_library_file" as const,
label: file.name,
description: getConnectionLabel(file.connectionId),
connectionId: file.connectionId,
connectionName: getConnectionLabel(file.connectionId),
sqlFileId: file.id,
searchText: `${file.name} ${getConnectionLabel(file.connectionId)}`,
}));
return savedSqlStore.allFiles.map((file) => ({
id: `sqllib-${file.id}`,
type: "sql_library_file" as const,
label: file.name,
description: getConnectionLabel(file.connectionId),
connectionId: file.connectionId,
connectionName: getConnectionLabel(file.connectionId),
sqlFileId: file.id,
searchText: `${file.name} ${getConnectionLabel(file.connectionId)}`,
}));
});
const sqlLibraryRecentItems = computed<QuickOpenItem[]>(() => {