refactor: code review

This commit is contained in:
meilin.huang
2023-12-26 22:31:51 +08:00
parent 7e0febef8f
commit 4ac9f02d6a
11 changed files with 142 additions and 140 deletions

View File

@@ -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 };

View File

@@ -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);

View File

@@ -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';
}; };

View File

@@ -1,6 +1,5 @@
<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">
@@ -44,7 +43,7 @@
</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> -->
@@ -81,8 +80,7 @@
<div class="mt5"> <div class="mt5">
<el-link @click="findCommand(state.activeName)" icon="refresh" :underline="false" class=""> </el-link> <el-link @click="findCommand(state.activeName)" icon="refresh" :underline="false" class=""> </el-link>
<el-divider direction="vertical" border-style="dashed" /> <el-divider direction="vertical" border-style="dashed" />
<el-link v-auth="perms.saveData" @click="onEditDoc(null)" type="primary" icon="plus" :underline="false"> <el-link v-auth="perms.saveData" @click="onEditDoc(null)" type="primary" icon="plus" :underline="false"> </el-link>
</el-link>
</div> </div>
</el-col> </el-col>
<el-col :span="22"> <el-col :span="22">
@@ -125,7 +123,6 @@
</div> </div>
</Pane> </Pane>
</Splitpanes> </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">

View File

@@ -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">

View File

@@ -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

View File

@@ -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);

View File

@@ -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:

View File

@@ -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
} }

View File

@@ -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,

View File

@@ -44,10 +44,9 @@ 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) oldConfig := a.GetConfig(config.Key)
if oldConfig.Permission != "all" && !strings.Contains(oldConfig.Permission, config.Modifier) { if oldConfig.Permission != "all" && !strings.Contains(oldConfig.Permission, config.Modifier) {
return errorx.NewBiz("您无权修改该配置") return errorx.NewBiz("您无权修改该配置")
@@ -56,7 +55,7 @@ func (a *configAppImpl) Save(ctx context.Context, config *entity.Config) error {
if err := a.UpdateById(ctx, config); err != nil { if err := a.UpdateById(ctx, config); err != nil {
return err return err
} }
}
cache.Del(SysConfigKeyPrefix + config.Key) cache.Del(SysConfigKeyPrefix + config.Key)
return nil return nil
} }