feat: 执行查询前提示选择数据库
* Improve:执行查询前提示选择数据库 * Fix:补齐连接配置测试字段 --------- Co-authored-by: staff <staff@qimaos-MacBook-Pro.local>
This commit is contained in:
1 parent
dbfe284ca9
commit
74d57982c9
5 files changed
+91
-3
No files matched your search
@@ -5,6 +5,7 @@ import { useHistoryStore } from "@/stores/historyStore";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { isSingleDatabase } from "@/lib/databaseCapabilities";
|
||||
import { classifySqlActivityKind } from "@/lib/historyActivityKind";
|
||||
import { sqlMetadataRefreshTarget } from "@/lib/sqlMetadataRefresh";
|
||||
import { classifyRedisCommandSafety, firstRedisCommandToken } from "@/lib/redisCommandSafety";
|
||||
@@ -41,6 +42,7 @@ export function useSqlExecution(deps: {
|
||||
resolveExecutableSql?: (snapshot?: SqlExecutionSnapshot) => Promise<string>;
|
||||
activeOutputView: Ref<"result" | "summary" | "explain" | "chart">;
|
||||
blockDangerousRedisCommands?: Ref<boolean>;
|
||||
onMissingDatabase?: () => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const queryStore = useQueryStore();
|
||||
@@ -66,6 +68,10 @@ export function useSqlExecution(deps: {
|
||||
const tab = deps.activeTab.value;
|
||||
const sql = await resolvedExecutableSql(sqlOverride);
|
||||
if (!tab || !sql.trim()) return;
|
||||
if (requiresDatabaseSelection(tab, deps.activeConnection.value)) {
|
||||
deps.onMissingDatabase?.();
|
||||
return;
|
||||
}
|
||||
// Redis: block dangerous commands when toggle is on (check each line for multi-line input)
|
||||
if (deps.activeConnection.value?.db_type === "redis" && deps.blockDangerousRedisCommands?.value !== false) {
|
||||
const commands = sql
|
||||
@@ -94,6 +100,10 @@ export function useSqlExecution(deps: {
|
||||
sql ??= await resolvedExecutableSql();
|
||||
const tab = deps.activeTab.value;
|
||||
if (!tab || !sql.trim()) return;
|
||||
if (requiresDatabaseSelection(tab, deps.activeConnection.value)) {
|
||||
deps.onMissingDatabase?.();
|
||||
return;
|
||||
}
|
||||
deps.activeOutputView.value = "result";
|
||||
const connName = connectionStore.getConfig(tab.connectionId)?.name || "";
|
||||
const start = Date.now();
|
||||
@@ -181,3 +191,10 @@ export function useSqlExecution(deps: {
|
||||
explainMode,
|
||||
};
|
||||
}
|
||||
|
||||
function requiresDatabaseSelection(tab: QueryTab, connection: ConnectionConfig | undefined): boolean {
|
||||
if (tab.mode !== "query") return false;
|
||||
if (!connection || tab.database) return false;
|
||||
if (isSingleDatabase(connection.db_type)) return false;
|
||||
return !["elasticsearch", "qdrant", "milvus", "weaviate", "chromadb", "zookeeper"].includes(connection.db_type);
|
||||
}
|
||||
Reference in new issue
Block a user