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。

1.0 KB
Raw Blame
/**
 * Persistence and retrieval for SQL file execution dialog options.
 */

export const SQL_FILE_CLOSE_ON_SUCCESS_STORAGE_KEY = "dbx-sql-file-close-on-success";

/**
 * Returns whether the SQL file execution dialog should close on successful completion.
 * Defaults to true if unconfigured.
 */
export function readSqlFileCloseOnSuccess(storage: Storage | undefined = typeof localStorage === "undefined" ? undefined : localStorage): boolean {
  try {
    const stored = storage?.getItem(SQL_FILE_CLOSE_ON_SUCCESS_STORAGE_KEY);
    return stored === null || stored === undefined ? true : stored === "true";
  } catch {
    return true;
  }
}

/**
 * Persists the close-on-success preference for SQL file execution.
 */
export function writeSqlFileCloseOnSuccess(enabled: boolean, storage: Storage | undefined = typeof localStorage === "undefined" ? undefined : localStorage): void {
  try {
    storage?.setItem(SQL_FILE_CLOSE_ON_SUCCESS_STORAGE_KEY, enabled ? "true" : "false");
  } catch {
    // Ignore storage quota or access errors.
  }
}