mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
refactor: code review
This commit is contained in:
@@ -25,6 +25,7 @@ const useCustomFetch = createFetch({
|
|||||||
headers.set('Authorization', token);
|
headers.set('Authorization', token);
|
||||||
headers.set('ClientId', getClientId());
|
headers.set('ClientId', getClientId());
|
||||||
}
|
}
|
||||||
|
headers.set('Content-Type', 'application/json');
|
||||||
options.headers = headers;
|
options.headers = headers;
|
||||||
|
|
||||||
return { options };
|
return { options };
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ body,
|
|||||||
|
|
||||||
.layout-main {
|
.layout-main {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 8px 10px;
|
padding: 10px 10px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: var(--bg-main-color);
|
background-color: var(--bg-main-color);
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ const onRemoveTab = (targetId: number) => {
|
|||||||
const resizeTableHeight = (e: any) => {
|
const resizeTableHeight = (e: any) => {
|
||||||
const vh = window.innerHeight;
|
const vh = window.innerHeight;
|
||||||
state.editorSize = e[0].size;
|
state.editorSize = e[0].size;
|
||||||
const plitpaneHeight = vh - 223;
|
const plitpaneHeight = vh - 233;
|
||||||
const editorHeight = plitpaneHeight * (state.editorSize / 100);
|
const editorHeight = plitpaneHeight * (state.editorSize / 100);
|
||||||
state.tableDataHeight = plitpaneHeight - editorHeight - 40 + 'px';
|
state.tableDataHeight = plitpaneHeight - editorHeight - 40 + 'px';
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,131 +1,128 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="flex-all-center">
|
||||||
<el-row>
|
<Splitpanes class="default-theme">
|
||||||
<Splitpanes class="default-theme">
|
<Pane size="20" max-size="30">
|
||||||
<Pane size="20" max-size="30">
|
<tag-tree :resource-type="TagResourceTypeEnum.Mongo.value" :tag-path-node-type="NodeTypeTagPath">
|
||||||
<tag-tree :resource-type="TagResourceTypeEnum.Mongo.value" :tag-path-node-type="NodeTypeTagPath">
|
<template #prefix="{ data }">
|
||||||
<template #prefix="{ data }">
|
<span v-if="data.type.value == MongoNodeType.Mongo">
|
||||||
<span v-if="data.type.value == MongoNodeType.Mongo">
|
<el-popover :show-after="500" placement="right-start" title="mongo实例信息" trigger="hover" :width="250">
|
||||||
<el-popover :show-after="500" placement="right-start" title="mongo实例信息" trigger="hover" :width="250">
|
<template #reference>
|
||||||
<template #reference>
|
<SvgIcon name="iconfont icon-op-mongo" :size="18" />
|
||||||
<SvgIcon name="iconfont icon-op-mongo" :size="18" />
|
</template>
|
||||||
</template>
|
<template #default>
|
||||||
<template #default>
|
<el-descriptions :column="1" size="small">
|
||||||
<el-descriptions :column="1" size="small">
|
<el-descriptions-item label="名称">
|
||||||
<el-descriptions-item label="名称">
|
{{ data.params.name }}
|
||||||
{{ data.params.name }}
|
</el-descriptions-item>
|
||||||
</el-descriptions-item>
|
<el-descriptions-item label="链接">
|
||||||
<el-descriptions-item label="链接">
|
{{ data.params.uri }}
|
||||||
{{ data.params.uri }}
|
</el-descriptions-item>
|
||||||
</el-descriptions-item>
|
</el-descriptions>
|
||||||
</el-descriptions>
|
</template>
|
||||||
</template>
|
</el-popover>
|
||||||
</el-popover>
|
</span>
|
||||||
</span>
|
|
||||||
|
|
||||||
<SvgIcon v-if="data.type.value == MongoNodeType.Dbs" name="Coin" color="#67c23a" />
|
<SvgIcon v-if="data.type.value == MongoNodeType.Dbs" name="Coin" color="#67c23a" />
|
||||||
|
|
||||||
<SvgIcon
|
<SvgIcon
|
||||||
v-if="data.type.value == MongoNodeType.Coll || data.type.value == MongoNodeType.CollMenu"
|
v-if="data.type.value == MongoNodeType.Coll || data.type.value == MongoNodeType.CollMenu"
|
||||||
name="Document"
|
name="Document"
|
||||||
class="color-primary"
|
class="color-primary"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #label="{ data }">
|
<template #label="{ data }">
|
||||||
<span v-if="data.type.value == MongoNodeType.Dbs">
|
<span v-if="data.type.value == MongoNodeType.Dbs">
|
||||||
{{ data.params.database }}
|
{{ data.params.database }}
|
||||||
<span style="color: #8492a6; font-size: 13px"> [{{ formatByteSize(data.params.size) }}] </span>
|
<span style="color: #8492a6; font-size: 13px"> [{{ formatByteSize(data.params.size) }}] </span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span v-else>{{ data.label }}</span>
|
<span v-else>{{ data.label }}</span>
|
||||||
</template>
|
</template>
|
||||||
</tag-tree>
|
</tag-tree>
|
||||||
</Pane>
|
</Pane>
|
||||||
|
|
||||||
<Pane>
|
<Pane>
|
||||||
<div class="mongo-data-tab card pd5">
|
<div class="mongo-data-tab card pd5 w100">
|
||||||
<el-row v-if="nowColl">
|
<el-row v-if="nowColl">
|
||||||
<el-descriptions class="w100" :column="10" size="small" border>
|
<el-descriptions class="w100" :column="10" size="small" border>
|
||||||
<!-- <el-descriptions-item label-align="right" label="tag">xxx</el-descriptions-item> -->
|
<!-- <el-descriptions-item label-align="right" label="tag">xxx</el-descriptions-item> -->
|
||||||
|
|
||||||
<el-descriptions-item label="ns" label-align="right">
|
<el-descriptions-item label="ns" label-align="right">
|
||||||
{{ nowColl.stats?.ns }}
|
{{ nowColl.stats?.ns }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="count" label-align="right">
|
<el-descriptions-item label="count" label-align="right">
|
||||||
{{ nowColl.stats?.count }}
|
{{ nowColl.stats?.count }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="avgObjSize" label-align="right">
|
<el-descriptions-item label="avgObjSize" label-align="right">
|
||||||
{{ formatByteSize(nowColl.stats?.avgObjSize) }}
|
{{ formatByteSize(nowColl.stats?.avgObjSize) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="size" label-align="right">
|
<el-descriptions-item label="size" label-align="right">
|
||||||
{{ formatByteSize(nowColl.stats?.size) }}
|
{{ formatByteSize(nowColl.stats?.size) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="totalSize" label-align="right">
|
<el-descriptions-item label="totalSize" label-align="right">
|
||||||
{{ formatByteSize(nowColl.stats?.totalSize) }}
|
{{ formatByteSize(nowColl.stats?.totalSize) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="storageSize" label-align="right">
|
<el-descriptions-item label="storageSize" label-align="right">
|
||||||
{{ formatByteSize(nowColl.stats?.storageSize) }}
|
{{ formatByteSize(nowColl.stats?.storageSize) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="freeStorageSize" label-align="right">
|
<el-descriptions-item label="freeStorageSize" label-align="right">
|
||||||
{{ formatByteSize(nowColl.stats?.freeStorageSize) }}
|
{{ formatByteSize(nowColl.stats?.freeStorageSize) }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row type="flex">
|
<el-row type="flex">
|
||||||
<el-tabs @tab-remove="removeDataTab" class="w100 ml5" v-model="state.activeName">
|
<el-tabs @tab-remove="removeDataTab" class="w100 ml5" v-model="state.activeName">
|
||||||
<el-tab-pane closable v-for="dt in state.dataTabs" :key="dt.key" :label="dt.label" :name="dt.key">
|
<el-tab-pane closable v-for="dt in state.dataTabs" :key="dt.key" :label="dt.label" :name="dt.key">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="2">
|
||||||
|
<div class="mt5">
|
||||||
|
<el-link @click="findCommand(state.activeName)" icon="refresh" :underline="false" class=""> </el-link>
|
||||||
|
<el-divider direction="vertical" border-style="dashed" />
|
||||||
|
<el-link v-auth="perms.saveData" @click="onEditDoc(null)" type="primary" icon="plus" :underline="false"> </el-link>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="22">
|
||||||
|
<el-input
|
||||||
|
ref="findParamInputRef"
|
||||||
|
v-model="dt.findParamStr"
|
||||||
|
placeholder="点击输入相应查询条件"
|
||||||
|
@focus="showFindDialog(dt.key)"
|
||||||
|
>
|
||||||
|
<template #prepend>查询参数</template>
|
||||||
|
</el-input>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-scrollbar class="mongo-data-tab-data">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="2">
|
<el-col :span="6" v-for="item in dt.datas" :key="item">
|
||||||
<div class="mt5">
|
<el-card :body-style="{ padding: '0px', position: 'relative' }">
|
||||||
<el-link @click="findCommand(state.activeName)" icon="refresh" :underline="false" class=""> </el-link>
|
<el-input type="textarea" v-model="item.value" :rows="10" />
|
||||||
<el-divider direction="vertical" border-style="dashed" />
|
<div style="padding: 3px; float: right" class="mr5 mongo-doc-btns">
|
||||||
<el-link v-auth="perms.saveData" @click="onEditDoc(null)" type="primary" icon="plus" :underline="false">
|
<div>
|
||||||
</el-link>
|
<el-link @click="onEditDoc(item)" :underline="false" type="success" icon="MagicStick"></el-link>
|
||||||
</div>
|
|
||||||
</el-col>
|
<el-divider direction="vertical" border-style="dashed" />
|
||||||
<el-col :span="22">
|
|
||||||
<el-input
|
<el-popconfirm @confirm="onDeleteDoc(item.value)" title="确定删除该文档?" width="160">
|
||||||
ref="findParamInputRef"
|
<template #reference>
|
||||||
v-model="dt.findParamStr"
|
<el-link v-auth="perms.delData" :underline="false" type="danger" icon="DocumentDelete">
|
||||||
placeholder="点击输入相应查询条件"
|
</el-link>
|
||||||
@focus="showFindDialog(dt.key)"
|
</template>
|
||||||
>
|
</el-popconfirm>
|
||||||
<template #prepend>查询参数</template>
|
</div>
|
||||||
</el-input>
|
</div>
|
||||||
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-scrollbar class="mongo-data-tab-data">
|
</el-scrollbar>
|
||||||
<el-row>
|
</el-tab-pane>
|
||||||
<el-col :span="6" v-for="item in dt.datas" :key="item">
|
</el-tabs>
|
||||||
<el-card :body-style="{ padding: '0px', position: 'relative' }">
|
</el-row>
|
||||||
<el-input type="textarea" v-model="item.value" :rows="10" />
|
</div>
|
||||||
<div style="padding: 3px; float: right" class="mr5 mongo-doc-btns">
|
</Pane>
|
||||||
<div>
|
</Splitpanes>
|
||||||
<el-link @click="onEditDoc(item)" :underline="false" type="success" icon="MagicStick"></el-link>
|
|
||||||
|
|
||||||
<el-divider direction="vertical" border-style="dashed" />
|
|
||||||
|
|
||||||
<el-popconfirm @confirm="onDeleteDoc(item.value)" title="确定删除该文档?" width="160">
|
|
||||||
<template #reference>
|
|
||||||
<el-link v-auth="perms.delData" :underline="false" type="danger" icon="DocumentDelete">
|
|
||||||
</el-link>
|
|
||||||
</template>
|
|
||||||
</el-popconfirm>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-scrollbar>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</Pane>
|
|
||||||
</Splitpanes>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-dialog width="600px" title="find参数" v-model="findDialog.visible">
|
<el-dialog width="600px" title="find参数" v-model="findDialog.visible">
|
||||||
<el-form label-width="auto">
|
<el-form label-width="auto">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="redis-data-op">
|
<div class="redis-data-op flex-all-center">
|
||||||
<Splitpanes class="default-theme">
|
<Splitpanes class="default-theme">
|
||||||
<Pane size="20" max-size="30">
|
<Pane size="20" max-size="30">
|
||||||
<tag-tree :resource-type="TagResourceTypeEnum.Redis.value" :tag-path-node-type="NodeTypeTagPath">
|
<tag-tree :resource-type="TagResourceTypeEnum.Redis.value" :tag-path-node-type="NodeTypeTagPath">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<el-tree
|
<el-tree
|
||||||
ref="resourceTreeRef"
|
ref="resourceTreeRef"
|
||||||
class="none-select"
|
class="none-select"
|
||||||
:indent="38"
|
:indent="24"
|
||||||
node-key="id"
|
node-key="id"
|
||||||
:props="props"
|
:props="props"
|
||||||
:data="data"
|
:data="data"
|
||||||
@@ -422,4 +422,3 @@ const info = async (data: any) => {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@/components/contextmenu
|
|
||||||
|
|||||||
@@ -56,10 +56,7 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['update:visible', 'cancel', 'val-change']);
|
const emit = defineEmits(['update:visible', 'cancel', 'val-change']);
|
||||||
|
|
||||||
const perms = {
|
const perms = {
|
||||||
addAccount: 'account:add',
|
|
||||||
delAccount: 'account:del',
|
|
||||||
saveAccountRole: 'account:saveRoles',
|
saveAccountRole: 'account:saveRoles',
|
||||||
changeAccountStatus: 'account:changeStatus',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchItems = [SearchItem.input('name', '姓名'), SearchItem.input('username', '用户名')];
|
const searchItems = [SearchItem.input('name', '姓名'), SearchItem.input('username', '用户名')];
|
||||||
@@ -72,7 +69,7 @@ const columns = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// 该用户拥有的的操作列按钮权限
|
// 该用户拥有的的操作列按钮权限
|
||||||
const actionBtns = hasPerms([perms.addAccount, perms.saveAccountRole, perms.changeAccountStatus]);
|
const actionBtns = hasPerms([perms.saveAccountRole]);
|
||||||
const actionColumn = TableColumn.new('action', '操作').isSlot().fixedRight().setMinWidth(80).noShowOverflowTooltip().alignCenter();
|
const actionColumn = TableColumn.new('action', '操作').isSlot().fixedRight().setMinWidth(80).noShowOverflowTooltip().alignCenter();
|
||||||
|
|
||||||
const pageTableRef: Ref<any> = ref(null);
|
const pageTableRef: Ref<any> = ref(null);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const (
|
|||||||
func (dbType DbType) MetaDbName() string {
|
func (dbType DbType) MetaDbName() string {
|
||||||
switch dbType {
|
switch dbType {
|
||||||
case DbTypeMysql:
|
case DbTypeMysql:
|
||||||
return "information_schema"
|
return "mysql"
|
||||||
case DbTypePostgres:
|
case DbTypePostgres:
|
||||||
return "postgres"
|
return "postgres"
|
||||||
case DM:
|
case DM:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func getMysqlDB(d *DbInfo) (*sql.DB, error) {
|
|||||||
// ---------------------------------- mysql元数据 -----------------------------------
|
// ---------------------------------- mysql元数据 -----------------------------------
|
||||||
const (
|
const (
|
||||||
MYSQL_META_FILE = "metasql/mysql_meta.sql"
|
MYSQL_META_FILE = "metasql/mysql_meta.sql"
|
||||||
|
MYSQL_DBS = "MYSQL_DBS"
|
||||||
MYSQL_TABLE_INFO_KEY = "MYSQL_TABLE_INFO"
|
MYSQL_TABLE_INFO_KEY = "MYSQL_TABLE_INFO"
|
||||||
MYSQL_INDEX_INFO_KEY = "MYSQL_INDEX_INFO"
|
MYSQL_INDEX_INFO_KEY = "MYSQL_INDEX_INFO"
|
||||||
MYSQL_COLUMN_MA_KEY = "MYSQL_COLUMN_MA"
|
MYSQL_COLUMN_MA_KEY = "MYSQL_COLUMN_MA"
|
||||||
@@ -55,7 +56,7 @@ func (md *MysqlDialect) GetDbServer() (*DbServer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (md *MysqlDialect) GetDbNames() ([]string, error) {
|
func (md *MysqlDialect) GetDbNames() ([]string, error) {
|
||||||
_, res, err := md.dc.Query("SELECT SCHEMA_NAME AS dbname FROM SCHEMATA")
|
_, res, err := md.dc.Query(GetLocalSql(MYSQL_META_FILE, MYSQL_DBS))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
--MYSQL_DBS 数据库名信息
|
||||||
|
SELECT
|
||||||
|
SCHEMA_NAME AS dbname
|
||||||
|
FROM
|
||||||
|
information_schema.SCHEMATA
|
||||||
|
WHERE
|
||||||
|
SCHEMA_NAME NOT IN ('mysql', 'information_schema', 'performance_schema')
|
||||||
|
---------------------------------------
|
||||||
--MYSQL_TABLE_INFO 表详细信息
|
--MYSQL_TABLE_INFO 表详细信息
|
||||||
SELECT
|
SELECT
|
||||||
table_name tableName,
|
table_name tableName,
|
||||||
|
|||||||
@@ -44,19 +44,18 @@ func (a *configAppImpl) GetPageList(condition *entity.Config, pageParam *model.P
|
|||||||
|
|
||||||
func (a *configAppImpl) Save(ctx context.Context, config *entity.Config) error {
|
func (a *configAppImpl) Save(ctx context.Context, config *entity.Config) error {
|
||||||
if config.Id == 0 {
|
if config.Id == 0 {
|
||||||
if err := a.Insert(ctx, config); err != nil {
|
return a.Insert(ctx, config)
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
oldConfig := a.GetConfig(config.Key)
|
|
||||||
if oldConfig.Permission != "all" && !strings.Contains(oldConfig.Permission, config.Modifier) {
|
|
||||||
return errorx.NewBiz("您无权修改该配置")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := a.UpdateById(ctx, config); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldConfig := a.GetConfig(config.Key)
|
||||||
|
if oldConfig.Permission != "all" && !strings.Contains(oldConfig.Permission, config.Modifier) {
|
||||||
|
return errorx.NewBiz("您无权修改该配置")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := a.UpdateById(ctx, config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
cache.Del(SysConfigKeyPrefix + config.Key)
|
cache.Del(SysConfigKeyPrefix + config.Key)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user