Skip to content

Commit

Permalink
fix(sql): default db for init sql cell & bilingual
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk authored and october-rain committed Oct 14, 2024
1 parent ddc8124 commit c32e2ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/libro-l10n/src/lang/bundle.l10n.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"隐藏全部 Output": "Hide all Output",
"全部隐藏": "Hide all",
"全部显示": "Show all",
"暂无内置数据库": "No built-in database for now",
"Restart and Run up to Selected Cell": "Restart and Run up to Selected Cell",
"Restart and Clear Outputs of All Cells": "Restart and Clear Outputs of All Cells",
"Restart and Run All Cells": "Restart and Run All Cells",
Expand Down
1 change: 1 addition & 0 deletions packages/libro-l10n/src/lang/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"a标签另起一页": "a标签另起一页",
"选择或输入聊天标识": "选择或输入聊天标识",
"暂无内置模型": "暂无内置模型",
"暂无内置数据库": "暂无内置数据库",
"插入并运行": "插入并运行",
"插入代码": "插入代码",
"复制代码": "复制代码",
Expand Down
18 changes: 14 additions & 4 deletions packages/libro-sql-cell/src/libro-sql-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,20 @@ export const LibroSqlCell = React.forwardRef<HTMLDivElement>(
};

useEffect(() => {
instance.getDatabaseConfig();
if (instance.model.dbId) {
setSelectedDb(instance.model.dbId);
}
instance
.getDatabaseConfig()
.then(() => {
if (instance.model.dbId) {
setSelectedDb(instance.model.dbId);
} else {
instance.handleDbChange(instance.databases[0].id);
setSelectedDb(instance.databases[0].id);
}
return;
})
.catch(() => {
//
});
}, [instance]);

const handleChange = (value: string) => {
Expand Down

0 comments on commit c32e2ae

Please sign in to comment.