fix(web): Fix sql format error (#1319)

This commit is contained in:
Hzh_97
2024-03-21 17:41:25 +08:00
committed by GitHub
parent 86a7b6c6f3
commit 04322de4f3
49 changed files with 69256 additions and 236 deletions

View File

@@ -1,3 +1,5 @@
import { format } from 'sql-formatter';
/** Theme */
export const STORAGE_THEME_KEY = '__db_gpt_theme_key';
/** Language */
@@ -7,5 +9,14 @@ export const STORAGE_INIT_MESSAGE_KET = '__db_gpt_im_key';
/** Flow nodes */
export const FLOW_NODES_KEY = '__db_gpt_static_flow_nodes_key';
export function formatSql(sql: string, lang?: string) {
if (!sql) return '';
try {
return format(sql, { language: lang });
} catch (e) {
return sql;
}
}
export * from './storage';
export * from './constants';