mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-01 19:28:43 +08:00
🐛 fix(query-editor): 修复 SQL 片段补全与插入交互
- 插入 SQL 片段后主动关闭片段弹窗,保持右键插入行为一致 - 提升 Monaco 补全详情区最小高度,放大片段说明展示区域 - 列补全解析改为基于当前语句引用上下文,修复当前语句前半段补全丢列问题 - 为 SQL 草稿持久化补齐 window 定时器兜底,避免测试环境 clearTimeout 缺失 - 更新 SQL 片段弹窗关闭和补全说明高度相关回归测试
This commit is contained in:
@@ -30,6 +30,24 @@ let persistedDraftsHydrated = false;
|
||||
let persistTimer: number | null = null;
|
||||
let flushListenersBound = false;
|
||||
|
||||
const getWindowTimerApi = (): {
|
||||
setTimeout: typeof globalThis.setTimeout;
|
||||
clearTimeout: typeof globalThis.clearTimeout;
|
||||
} | null => {
|
||||
if (typeof window === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
const setTimeoutImpl = typeof window.setTimeout === 'function' ? window.setTimeout.bind(window) : globalThis.setTimeout;
|
||||
const clearTimeoutImpl = typeof window.clearTimeout === 'function' ? window.clearTimeout.bind(window) : globalThis.clearTimeout;
|
||||
if (typeof setTimeoutImpl !== 'function' || typeof clearTimeoutImpl !== 'function') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
setTimeout: setTimeoutImpl,
|
||||
clearTimeout: clearTimeoutImpl,
|
||||
};
|
||||
};
|
||||
|
||||
const toTabId = (value: unknown): string => String(value ?? '').trim();
|
||||
|
||||
const toTrimmedString = (value: unknown, fallback = ''): string => {
|
||||
@@ -108,8 +126,9 @@ const ensurePersistedDraftsHydrated = (): void => {
|
||||
};
|
||||
|
||||
const flushPersistedDrafts = (): void => {
|
||||
if (persistTimer !== null && typeof window !== 'undefined') {
|
||||
window.clearTimeout(persistTimer);
|
||||
const timerApi = getWindowTimerApi();
|
||||
if (persistTimer !== null && timerApi) {
|
||||
timerApi.clearTimeout(persistTimer);
|
||||
persistTimer = null;
|
||||
}
|
||||
const storage = getDraftSnapshotStorage();
|
||||
@@ -155,14 +174,15 @@ const bindFlushListeners = (): void => {
|
||||
|
||||
const schedulePersistedDraftFlush = (): void => {
|
||||
bindFlushListeners();
|
||||
if (typeof window === 'undefined') {
|
||||
const timerApi = getWindowTimerApi();
|
||||
if (!timerApi) {
|
||||
flushPersistedDrafts();
|
||||
return;
|
||||
}
|
||||
if (persistTimer !== null) {
|
||||
window.clearTimeout(persistTimer);
|
||||
timerApi.clearTimeout(persistTimer);
|
||||
}
|
||||
persistTimer = window.setTimeout(() => {
|
||||
persistTimer = timerApi.setTimeout(() => {
|
||||
flushPersistedDrafts();
|
||||
}, QUERY_TAB_DRAFT_SNAPSHOT_DEBOUNCE_MS);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user