mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 16:30:25 +08:00 
			
		
		
		
	release v1.8.6
This commit is contained in:
		@@ -18,7 +18,7 @@
 | 
			
		||||
                :default-expanded-keys="props.defaultExpandedKeys"
 | 
			
		||||
            >
 | 
			
		||||
                <template #default="{ node, data }">
 | 
			
		||||
                    <span @dblclick="treeNodeDblclick(data)" :class="data.type.nodeDblclickFunc ? 'none-select' : ''">
 | 
			
		||||
                    <span :id="node.key" @dblclick="treeNodeDblclick(data)" :class="data.type.nodeDblclickFunc ? 'none-select' : ''">
 | 
			
		||||
                        <span v-if="data.type.value == TagTreeNode.TagPath">
 | 
			
		||||
                            <tag-info :tag-path="data.label" />
 | 
			
		||||
                        </span>
 | 
			
		||||
@@ -48,7 +48,7 @@
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { onMounted, reactive, ref, watch, toRefs } from 'vue';
 | 
			
		||||
import { onMounted, reactive, ref, watch, toRefs, nextTick } from 'vue';
 | 
			
		||||
import { NodeType, TagTreeNode } from './tag';
 | 
			
		||||
import TagInfo from './TagInfo.vue';
 | 
			
		||||
import { Contextmenu } from '@/components/contextmenu';
 | 
			
		||||
@@ -126,7 +126,7 @@ const loadTags = async () => {
 | 
			
		||||
 * @param { Object } node
 | 
			
		||||
 * @param { Object } resolve
 | 
			
		||||
 */
 | 
			
		||||
const loadNode = async (node: any, resolve: any) => {
 | 
			
		||||
const loadNode = async (node: any, resolve: (data: any) => void, reject: () => void) => {
 | 
			
		||||
    if (typeof resolve !== 'function') {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
@@ -141,6 +141,8 @@ const loadNode = async (node: any, resolve: any) => {
 | 
			
		||||
        }
 | 
			
		||||
    } catch (e: any) {
 | 
			
		||||
        console.error(e);
 | 
			
		||||
        // 调用 reject 以保持节点状态,并允许远程加载继续。
 | 
			
		||||
        return reject();
 | 
			
		||||
    }
 | 
			
		||||
    return resolve(nodes);
 | 
			
		||||
};
 | 
			
		||||
@@ -207,6 +209,17 @@ const getNode = (nodeKey: any) => {
 | 
			
		||||
 | 
			
		||||
const setCurrentKey = (nodeKey: any) => {
 | 
			
		||||
    treeRef.value.setCurrentKey(nodeKey);
 | 
			
		||||
 | 
			
		||||
    // 通过Id获取到对应的dom元素
 | 
			
		||||
    const node = document.getElementById(nodeKey);
 | 
			
		||||
    if (node) {
 | 
			
		||||
        setTimeout(() => {
 | 
			
		||||
            nextTick(() => {
 | 
			
		||||
                // 通过scrollIntoView方法将对应的dom元素定位到可见区域 【block: 'center'】这个属性是在垂直方向居中显示
 | 
			
		||||
                node.scrollIntoView({ block: 'center' });
 | 
			
		||||
            });
 | 
			
		||||
        }, 100);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
defineExpose({
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@
 | 
			
		||||
                    v-bind="$attrs"
 | 
			
		||||
                    ref="tagTreeRef"
 | 
			
		||||
                    :data="state.tags"
 | 
			
		||||
                    :default-expanded-keys="checkedTags"
 | 
			
		||||
                    :default-expanded-keys="state.defaultExpandedKeys"
 | 
			
		||||
                    :default-checked-keys="checkedTags"
 | 
			
		||||
                    multiple
 | 
			
		||||
                    :render-after-expand="true"
 | 
			
		||||
@@ -74,10 +74,12 @@ const tagTreeRef: any = ref(null);
 | 
			
		||||
const filterTag = ref('');
 | 
			
		||||
 | 
			
		||||
const state = reactive({
 | 
			
		||||
    defaultExpandedKeys: [] as any,
 | 
			
		||||
    tags: [],
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
    state.defaultExpandedKeys = checkedTags.value;
 | 
			
		||||
    search();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -58,16 +58,61 @@
 | 
			
		||||
                    <el-row>
 | 
			
		||||
                        <el-col :span="24" v-if="state.db">
 | 
			
		||||
                            <el-descriptions :column="4" size="small" border>
 | 
			
		||||
                                <el-descriptions-item label-align="right" label="操作"
 | 
			
		||||
                                    ><el-button
 | 
			
		||||
                                <el-descriptions-item label-align="right" label="操作">
 | 
			
		||||
                                    <el-button
 | 
			
		||||
                                        :disabled="!state.db || !nowDbInst.id"
 | 
			
		||||
                                        type="primary"
 | 
			
		||||
                                        icon="Search"
 | 
			
		||||
                                        @click="addQueryTab({ id: nowDbInst.id, dbs: nowDbInst.databases }, state.db)"
 | 
			
		||||
                                        size="small"
 | 
			
		||||
                                        >新建查询</el-button
 | 
			
		||||
                                    ></el-descriptions-item
 | 
			
		||||
                                        link
 | 
			
		||||
                                        @click="
 | 
			
		||||
                                            addQueryTab(
 | 
			
		||||
                                                { id: nowDbInst.id, dbs: nowDbInst.databases, nodeKey: getSqlMenuNodeKey(nowDbInst.id, state.db) },
 | 
			
		||||
                                                state.db
 | 
			
		||||
                                            )
 | 
			
		||||
                                        "
 | 
			
		||||
                                        title="新建查询"
 | 
			
		||||
                                    >
 | 
			
		||||
                                    </el-button>
 | 
			
		||||
 | 
			
		||||
                                    <template v-if="!dbConfig.locationTreeNode">
 | 
			
		||||
                                        <el-divider direction="vertical" border-style="dashed" />
 | 
			
		||||
                                        <el-button @click="locationNowTreeNode(null)" title="定位至左侧树的指定位置" icon="Location" link></el-button>
 | 
			
		||||
                                    </template>
 | 
			
		||||
 | 
			
		||||
                                    <el-divider direction="vertical" border-style="dashed" />
 | 
			
		||||
                                    <!-- 数据库展示配置 -->
 | 
			
		||||
                                    <el-popover
 | 
			
		||||
                                        popper-style="max-height: 550px; overflow: auto; max-width: 450px"
 | 
			
		||||
                                        placement="bottom"
 | 
			
		||||
                                        width="auto"
 | 
			
		||||
                                        title="数据库展示配置"
 | 
			
		||||
                                        trigger="click"
 | 
			
		||||
                                    >
 | 
			
		||||
                                        <el-row>
 | 
			
		||||
                                            <el-checkbox
 | 
			
		||||
                                                v-model="dbConfig.showColumnComment"
 | 
			
		||||
                                                label="显示字段备注"
 | 
			
		||||
                                                :true-value="1"
 | 
			
		||||
                                                :false-value="0"
 | 
			
		||||
                                                size="small"
 | 
			
		||||
                                            />
 | 
			
		||||
                                        </el-row>
 | 
			
		||||
 | 
			
		||||
                                        <el-row>
 | 
			
		||||
                                            <el-checkbox
 | 
			
		||||
                                                v-model="dbConfig.locationTreeNode"
 | 
			
		||||
                                                label="自动定位树节点"
 | 
			
		||||
                                                :true-value="1"
 | 
			
		||||
                                                :false-value="0"
 | 
			
		||||
                                                size="small"
 | 
			
		||||
                                            />
 | 
			
		||||
                                        </el-row>
 | 
			
		||||
 | 
			
		||||
                                        <template #reference>
 | 
			
		||||
                                            <el-link type="primary" icon="setting" :underline="false"></el-link>
 | 
			
		||||
                                        </template>
 | 
			
		||||
                                    </el-popover>
 | 
			
		||||
                                </el-descriptions-item>
 | 
			
		||||
 | 
			
		||||
                                <el-descriptions-item label-align="right" label="tag">{{ nowDbInst.tagPath }}</el-descriptions-item>
 | 
			
		||||
 | 
			
		||||
@@ -103,7 +148,9 @@
 | 
			
		||||
                            <el-tab-pane class="h100" closable v-for="dt in state.tabs.values()" :label="dt.label" :name="dt.key" :key="dt.key">
 | 
			
		||||
                                <template #label>
 | 
			
		||||
                                    <el-popover :show-after="1000" placement="bottom-start" trigger="hover" :width="250">
 | 
			
		||||
                                        <template #reference> {{ dt.label }} </template>
 | 
			
		||||
                                        <template #reference>
 | 
			
		||||
                                            <span class="font12">{{ dt.label }}</span>
 | 
			
		||||
                                        </template>
 | 
			
		||||
                                        <template #default>
 | 
			
		||||
                                            <el-descriptions :column="1" size="small">
 | 
			
		||||
                                                <el-descriptions-item label="tagPath">
 | 
			
		||||
@@ -184,7 +231,7 @@ import { getDbDialect, schemaDbTypes } from './dialect/index';
 | 
			
		||||
import { sleep } from '@/common/utils/loading';
 | 
			
		||||
import { TagResourceTypeEnum } from '@/common/commonEnum';
 | 
			
		||||
import { Pane, Splitpanes } from 'splitpanes';
 | 
			
		||||
import { useEventListener } from '@vueuse/core';
 | 
			
		||||
import { useEventListener, useStorage } from '@vueuse/core';
 | 
			
		||||
import SqlExecBox from '@/views/ops/db/component/sqleditor/SqlExecBox';
 | 
			
		||||
import { useAutoOpenResource } from '@/store/autoOpenResource';
 | 
			
		||||
import { storeToRefs } from 'pinia';
 | 
			
		||||
@@ -456,6 +503,8 @@ const state = reactive({
 | 
			
		||||
 | 
			
		||||
const { nowDbInst, tableCreateDialog } = toRefs(state);
 | 
			
		||||
 | 
			
		||||
const dbConfig = useStorage('dbConfig', { showColumnComment: false, locationTreeNode: false });
 | 
			
		||||
 | 
			
		||||
const serverInfoReqParam = ref({
 | 
			
		||||
    instanceId: 0,
 | 
			
		||||
});
 | 
			
		||||
@@ -670,6 +719,18 @@ const onTabChange = () => {
 | 
			
		||||
        registerDbCompletionItemProvider(nowTab.dbId, nowTab.db, nowTab.params.dbs, nowDbInst.value.type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (dbConfig.value.locationTreeNode) {
 | 
			
		||||
        locationNowTreeNode(nowTab);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 定位至当前树节点
 | 
			
		||||
 */
 | 
			
		||||
const locationNowTreeNode = (nowTab: any = null) => {
 | 
			
		||||
    if (!nowTab) {
 | 
			
		||||
        nowTab = state.tabs.get(state.activeName);
 | 
			
		||||
    }
 | 
			
		||||
    tagTreeRef.value.setCurrentKey(nowTab?.treeNodeKey);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -854,7 +915,7 @@ const getNowDbInfo = () => {
 | 
			
		||||
            margin: 0 0 5px;
 | 
			
		||||
 | 
			
		||||
            .el-tabs__item {
 | 
			
		||||
                padding: 0 10px;
 | 
			
		||||
                padding: 0 5px;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -121,7 +121,7 @@
 | 
			
		||||
 | 
			
		||||
                    <template #empty>
 | 
			
		||||
                        <div style="text-align: center">
 | 
			
		||||
                            <el-empty class="h100" :description="props.emptyText" :image-size="100" />
 | 
			
		||||
                            <el-empty :description="props.emptyText" :image-size="100" />
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </template>
 | 
			
		||||
                </el-table-v2>
 | 
			
		||||
 
 | 
			
		||||
@@ -48,21 +48,6 @@
 | 
			
		||||
                    <el-tooltip :show-after="500" class="box-item" effect="dark" content="commit" placement="top">
 | 
			
		||||
                        <el-link @click="onCommit()" type="success" icon="CircleCheck" :underline="false"> </el-link>
 | 
			
		||||
                    </el-tooltip>
 | 
			
		||||
                    <el-divider direction="vertical" border-style="dashed" />
 | 
			
		||||
 | 
			
		||||
                    <!-- 表数据展示配置 -->
 | 
			
		||||
                    <el-popover
 | 
			
		||||
                        popper-style="max-height: 550px; overflow: auto; max-width: 450px"
 | 
			
		||||
                        placement="bottom"
 | 
			
		||||
                        width="auto"
 | 
			
		||||
                        title="展示配置"
 | 
			
		||||
                        trigger="click"
 | 
			
		||||
                    >
 | 
			
		||||
                        <el-checkbox v-model="dbConfig.showColumnComment" label="显示字段备注" :true-value="true" :false-value="false" size="small" />
 | 
			
		||||
                        <template #reference>
 | 
			
		||||
                            <el-link type="primary" icon="setting" :underline="false"></el-link>
 | 
			
		||||
                        </template>
 | 
			
		||||
                    </el-popover>
 | 
			
		||||
 | 
			
		||||
                    <el-divider direction="vertical" border-style="dashed" />
 | 
			
		||||
 | 
			
		||||
@@ -258,7 +243,7 @@ import { DbInst } from '@/views/ops/db/db';
 | 
			
		||||
import DbTableData from './DbTableData.vue';
 | 
			
		||||
import { DbDialect } from '@/views/ops/db/dialect';
 | 
			
		||||
import SvgIcon from '@/components/svgIcon/index.vue';
 | 
			
		||||
import { useEventListener, useStorage } from '@vueuse/core';
 | 
			
		||||
import { useEventListener } from '@vueuse/core';
 | 
			
		||||
import { copyToClipboard } from '@/common/utils/string';
 | 
			
		||||
import DbTableDataForm from './DbTableDataForm.vue';
 | 
			
		||||
 | 
			
		||||
@@ -288,8 +273,6 @@ const condDialogInputRef: Ref = ref(null);
 | 
			
		||||
 | 
			
		||||
const defaultPageSize = DbInst.DefaultLimit;
 | 
			
		||||
 | 
			
		||||
const dbConfig = useStorage('dbConfig', { showColumnComment: false });
 | 
			
		||||
 | 
			
		||||
const state = reactive({
 | 
			
		||||
    datas: [],
 | 
			
		||||
    sql: '', // 当前数据tab执行的sql
 | 
			
		||||
 
 | 
			
		||||
@@ -42,13 +42,13 @@ SELECT a.indexname                                                         AS "i
 | 
			
		||||
       indexdef                                                          AS "indexDef",
 | 
			
		||||
       c.attname                                                         AS "columnName",
 | 
			
		||||
       c.attnum                                                          AS "seqInIndex",
 | 
			
		||||
       case when a.indexname like '%_pkey' then 1 else 0 end             AS "isPrimaryKey"
 | 
			
		||||
       case when a.indexname like '%%_pkey' then 1 else 0 end             AS "isPrimaryKey"
 | 
			
		||||
FROM pg_indexes a
 | 
			
		||||
         join pg_class b on a.indexname = b.relname
 | 
			
		||||
         join pg_attribute c on b.oid = c.attrelid
 | 
			
		||||
WHERE a.schemaname = (select current_schema())
 | 
			
		||||
  AND a.tablename = '%s'
 | 
			
		||||
  AND a.indexname not like '%_pkey'
 | 
			
		||||
  AND a.indexname not like '%%_pkey'
 | 
			
		||||
---------------------------------------
 | 
			
		||||
--PGSQL_COLUMN_MA 表列信息
 | 
			
		||||
SELECT a.table_name                                                                            AS "tableName",
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user