mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	feat: 表格添加刷新按钮
This commit is contained in:
		@@ -19,6 +19,11 @@
 | 
				
			|||||||
                            <span class="ml3">
 | 
					                            <span class="ml3">
 | 
				
			||||||
                                <slot name="label" :data="data"> {{ data.label }}</slot>
 | 
					                                <slot name="label" :data="data"> {{ data.label }}</slot>
 | 
				
			||||||
                            </span>
 | 
					                            </span>
 | 
				
			||||||
 | 
					                          
 | 
				
			||||||
 | 
					                            <span class="ml3">
 | 
				
			||||||
 | 
					                                <slot name="option" :data="data"></slot>
 | 
				
			||||||
 | 
					                            </span>
 | 
				
			||||||
 | 
					                          
 | 
				
			||||||
                        </span>
 | 
					                        </span>
 | 
				
			||||||
                    </template>
 | 
					                    </template>
 | 
				
			||||||
                </el-tree>
 | 
					                </el-tree>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,6 +59,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        <SvgIcon name="Files"  v-if="data.type == NodeType.SqlMenu || data.type == NodeType.Sql" color="#f56c6c" />
 | 
					                        <SvgIcon name="Files"  v-if="data.type == NodeType.SqlMenu || data.type == NodeType.Sql" color="#f56c6c" />
 | 
				
			||||||
                    </template>
 | 
					                    </template>
 | 
				
			||||||
 | 
					                    <template #option="{data}">
 | 
				
			||||||
 | 
					                      <span v-if="data.type == NodeType.TableMenu">
 | 
				
			||||||
 | 
					                        <el-link @click="reloadTables(data.key)" icon="refresh" :underline="false"></el-link>
 | 
				
			||||||
 | 
					                      </span>
 | 
				
			||||||
 | 
					                    </template>
 | 
				
			||||||
                </tag-tree>
 | 
					                </tag-tree>
 | 
				
			||||||
            </el-col>
 | 
					            </el-col>
 | 
				
			||||||
            <el-col :span="20">
 | 
					            <el-col :span="20">
 | 
				
			||||||
@@ -125,6 +130,7 @@ const state = reactive({
 | 
				
			|||||||
    nowDbInst: {} as DbInst,
 | 
					    nowDbInst: {} as DbInst,
 | 
				
			||||||
    db: '', // 当前操作的数据库
 | 
					    db: '', // 当前操作的数据库
 | 
				
			||||||
    activeName: '',
 | 
					    activeName: '',
 | 
				
			||||||
 | 
					    reloadStatus: false,
 | 
				
			||||||
    tabs,
 | 
					    tabs,
 | 
				
			||||||
    dataTabsTableHeight: '600',
 | 
					    dataTabsTableHeight: '600',
 | 
				
			||||||
    editorHeight: '600',
 | 
					    editorHeight: '600',
 | 
				
			||||||
@@ -257,7 +263,8 @@ const nodeClick = async (data: any) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const getTables = async (params: any) => {
 | 
					const getTables = async (params: any) => {
 | 
				
			||||||
    const { id, db } = params;
 | 
					    const { id, db } = params;
 | 
				
			||||||
    let tables = await DbInst.getInst(id).loadTables(db);
 | 
					    let tables = await DbInst.getInst(id).loadTables(db, state.reloadStatus);
 | 
				
			||||||
 | 
					    state.reloadStatus=false
 | 
				
			||||||
    return tables.map((x: any) => {
 | 
					    return tables.map((x: any) => {
 | 
				
			||||||
        return new TagTreeNode(`${id}.${db}.${x.tableName}`, x.tableName, NodeType.Table).withIsLeaf(true).withParams({
 | 
					        return new TagTreeNode(`${id}.${db}.${x.tableName}`, x.tableName, NodeType.Table).withIsLeaf(true).withParams({
 | 
				
			||||||
            id,
 | 
					            id,
 | 
				
			||||||
@@ -406,6 +413,11 @@ const getSqlMenuNodeKey = (dbId: number, db: string) => {
 | 
				
			|||||||
    return `${dbId}.${db}.sql-menu`
 | 
					    return `${dbId}.${db}.sql-menu`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const reloadTables = (nodeKey:string) => {
 | 
				
			||||||
 | 
					  state.reloadStatus=true
 | 
				
			||||||
 | 
					  tagTreeRef.value.reloadNode(nodeKey);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const registerSqlCompletionItemProvider = () => {
 | 
					const registerSqlCompletionItemProvider = () => {
 | 
				
			||||||
    // 参考 https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example
 | 
					    // 参考 https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example
 | 
				
			||||||
    self.completionItemProvider = self.completionItemProvider || monaco.languages.registerCompletionItemProvider('sql', {
 | 
					    self.completionItemProvider = self.completionItemProvider || monaco.languages.registerCompletionItemProvider('sql', {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,13 +58,14 @@ export class DbInst {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 加载数据库表信息
 | 
					     * 加载数据库表信息
 | 
				
			||||||
     * @param dbName 数据库名
 | 
					     * @param dbName 数据库名
 | 
				
			||||||
 | 
					     * @param reload 是否重新请求接口获取数据
 | 
				
			||||||
     * @returns 表信息
 | 
					     * @returns 表信息
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async loadTables(dbName: string) {
 | 
					    async loadTables(dbName: string, reload?: boolean) {
 | 
				
			||||||
        const db = this.getDb(dbName);
 | 
					        const db = this.getDb(dbName);
 | 
				
			||||||
        // 优先从 table map中获取
 | 
					        // 优先从 table map中获取
 | 
				
			||||||
        let tables = db.tables;
 | 
					        let tables = db.tables;
 | 
				
			||||||
        if (tables) {
 | 
					        if (!reload && tables) {
 | 
				
			||||||
            return tables;
 | 
					            return tables;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        console.log(`load tables -> dbName: ${dbName}`);
 | 
					        console.log(`load tables -> dbName: ${dbName}`);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user