fix: 前端树形按钮变更为右击显示,后端修复协程panic导致进程退出

This commit is contained in:
meilin.huang
2021-12-02 10:35:48 +08:00
parent d762d346e0
commit fb0fc274b4
10 changed files with 230 additions and 166 deletions

View File

@@ -96,7 +96,6 @@
import { toRefs, reactive, computed, defineComponent, ref } from 'vue';
import { dbApi } from './api';
import 'codemirror/theme/ambiance.css';
import 'codemirror/addon/hint/show-hint.css';
// import base style
import 'codemirror/lib/codemirror.css';
@@ -210,7 +209,13 @@ export default defineComponent({
// 没有选中的文本,则为全部文本
let sql = getSql();
notNull(sql, '内容不能为空');
runSqlStr(sql);
};
/**
* 执行sql str
*/
const runSqlStr = async (sql: string) => {
state.execRes.tableColumn = [];
state.execRes.data = [];
state.execRes.emptyResText = '查询中...';
@@ -336,7 +341,7 @@ export default defineComponent({
// 赋值第一个表信息
if (state.tableMetadata.length > 0) {
state.tableName = state.tableMetadata[0]['tableName'];
changeTable(state.tableName);
changeTable(state.tableName, false);
}
});
@@ -367,14 +372,22 @@ export default defineComponent({
};
// 选择表事件
const changeTable = async (tableName: string) => {
const changeTable = (tableName: string, execSelectSql: boolean = true) => {
if (tableName == '') {
return;
}
state.columnMetadata = await dbApi.columnMetadata.request({
id: state.dbId,
tableName: tableName,
});
dbApi.columnMetadata
.request({
id: state.dbId,
tableName: tableName,
})
.then((res) => {
state.columnMetadata = res;
});
if (execSelectSql) {
runSqlStr(`SELECT * FROM ${tableName} ORDER BY create_time DESC LIMIT 25`);
}
};
/**