refactor: 图标优化等

This commit is contained in:
meilin.huang
2023-02-20 18:41:45 +08:00
parent edf29976dd
commit c75fe7135a
17 changed files with 44 additions and 53 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -342,6 +342,7 @@ body,
font-size: 12px
}
// 图标垂直居中
.icon-middle {
.el-icon {
display: inline-flex;
@@ -350,4 +351,13 @@ body,
cursor: pointer;
vertical-align: middle;
}
}
.img-icon {
display: inline-flex;
justify-content: center;
align-items: center;
cursor: pointer;
vertical-align: middle;
height: 16px;
width: 16px;
}

View File

@@ -28,7 +28,12 @@
<span v-if="data.type == NodeType.DbInst">
<el-popover placement="right-start" title="数据库实例信息" trigger="hover" :width="210">
<template #reference>
<el-icon>
<img v-if="data.params.type === 'mysql'" src="@/assets/icon/mysql.png"
class="img-icon" />
<img v-if="data.params.type === 'postgres'" src="@/assets/icon/postgres.png"
class="img-icon" />
<el-icon v-else>
<InfoFilled />
</el-icon>
</template>
@@ -64,8 +69,6 @@
<el-icon v-if="data.type == NodeType.SqlMenu || data.type == NodeType.Sql">
<Files color="#f56c6c" />
</el-icon>
</template>
</tag-tree>
</el-col>

View File

@@ -1,5 +1,5 @@
<template>
<div :style="{ height: height }" id="xterm" class="xterm" />
<div :style="{ height: props.height }" id="xterm" class="xterm" />
</template>
<script lang="ts" setup>
@@ -9,40 +9,31 @@ import { FitAddon } from 'xterm-addon-fit';
import { getSession } from '@/common/utils/storage.ts';
import config from '@/common/config';
import { useStore } from '@/store/index.ts';
import { nextTick, toRefs, watch, computed, reactive, onMounted, onBeforeUnmount } from 'vue';
import { nextTick, computed, reactive, onMounted, onBeforeUnmount } from 'vue';
const props = defineProps({
machineId: { type: Number },
cmd: { type: String },
height: { type: String },
height: { type: [String, Number] },
})
const state = reactive({
machineId: 0,
cmd: '',
height: '',
term: null as any,
socket: null as any,
});
const {
height,
} = toRefs(state)
const resize = 1;
const data = 2;
const ping = 3;
watch(props, (newValue: any) => {
state.machineId = newValue.machineId;
state.cmd = newValue.cmd;
state.height = newValue.height;
});
onMounted(() => {
state.machineId = props.machineId as any;
state.height = props.height as any;
state.cmd = props.cmd as any;
nextTick(() => {
initXterm();
initSocket();
});
});
onBeforeUnmount(() => {
@@ -56,11 +47,6 @@ const getThemeConfig: any = computed(() => {
return store.state.themeConfig.themeConfig;
});
nextTick(() => {
initXterm();
initSocket();
});
function initXterm() {
const term: any = new Terminal({
fontSize: getThemeConfig.value.terminalFontSize || 15,
@@ -122,7 +108,7 @@ function initXterm() {
let pingInterval: any;
function initSocket() {
state.socket = new WebSocket(
`${config.baseWsUrl}/machines/${state.machineId}/terminal?token=${getSession('token')}&cols=${state.term.cols}&rows=${state.term.rows
`${config.baseWsUrl}/machines/${props.machineId}/terminal?token=${getSession('token')}&cols=${state.term.cols}&rows=${state.term.rows
}`
);
@@ -189,4 +175,11 @@ function closeAll() {
state.term = null;
}
}
</script>
</script>
<style lang="scss">
#xterm {
.xterm-viewport {
overflow-y: hidden
}
}
</style>

View File

@@ -12,7 +12,7 @@ import { useRoute } from 'vue-router';
const route = useRoute();
const state = reactive({
machineId: 0,
height: 700,
height: 0,
});
const {

View File

@@ -7,9 +7,7 @@
<span v-if="data.type == NodeType.Mongo">
<el-popover placement="right-start" title="mongo实例信息" trigger="hover" :width="210">
<template #reference>
<el-icon>
<InfoFilled />
</el-icon>
<img src="@/assets/icon/mongo.png" class="img-icon" />
</template>
<template #default>
<el-form class="instances-pop-form" label-width="50px" :size="'small'">

View File

@@ -9,9 +9,7 @@
<span v-if="data.type == NodeType.Redis">
<el-popover placement="right-start" title="redis实例信息" trigger="hover" :width="210">
<template #reference>
<el-icon>
<InfoFilled />
</el-icon>
<img src="@/assets/icon/redis.png" class="img-icon" />
</template>
<template #default>
<el-form class="instances-pop-form" label-width="50px" :size="'small'">
@@ -129,7 +127,7 @@ import TagTree from '../component/TagTree.vue';
/**
* 树节点类型
*/
class NodeType {
class NodeType {
static Redis = 1
static Db = 2
}

View File

@@ -162,7 +162,7 @@ func doSelect(selectStmt *sqlparser.Select, execSqlReq *DbSqlExecReq) (*DbSqlExe
biz.NotNil(limit, "请完善分页信息后执行")
count, err := strconv.Atoi(sqlparser.String(limit.Rowcount))
biz.ErrIsNil(err, "分页参数有误")
biz.IsTrue(count <= maxCount, fmt.Sprintf("查询结果集数需小于系统配置的%d条", maxCount))
biz.IsTrue(count <= maxCount, "查询结果集数需小于系统配置的%d条", maxCount)
}
}

View File

@@ -79,9 +79,7 @@ func (mm *MysqlMetadata) GetColumns(tableNames ...string) []map[string]interface
// 获取表主键字段名,不存在主键标识则默认第一个字段
func (mm *MysqlMetadata) GetPrimaryKey(tablename string) string {
columns := mm.GetColumns(tablename)
if len(columns) == 0 {
panic(biz.NewBizErr(fmt.Sprintf("[%s] 表不存在", tablename)))
}
biz.IsTrue(len(columns) > 0, "[%s] 表不存在", tablename)
for _, v := range columns {
if v["columnKey"].(string) == "PRI" {
return v["columnName"].(string)

View File

@@ -118,9 +118,7 @@ func (pm *PgsqlMetadata) GetColumns(tableNames ...string) []map[string]interface
func (pm *PgsqlMetadata) GetPrimaryKey(tablename string) string {
columns := pm.GetColumns(tablename)
if len(columns) == 0 {
panic(biz.NewBizErr(fmt.Sprintf("[%s] 表不存在", tablename)))
}
biz.IsTrue(len(columns) > 0, "[%s] 表不存在", tablename)
for _, v := range columns {
if v["columnKey"].(string) == "PRI" {
return v["columnName"].(string)

View File

@@ -70,9 +70,7 @@ func (m *MachineScript) RunMachineScript(rc *req.Ctx) {
res, err := cli.Run(script)
// 记录请求参数
rc.ReqParam = fmt.Sprintf("[machine: %s, scriptId: %d, name: %s]", cli.GetMachine().GetLogDesc(), scriptId, ms.Name)
if err != nil {
panic(biz.NewBizErr(fmt.Sprintf("执行命令失败:%s", err.Error())))
}
biz.ErrIsNilAppendErr(err, "执行命令失败:%s")
rc.ResData = res
}

View File

@@ -1,7 +1,6 @@
package application
import (
"fmt"
dbapp "mayfly-go/internal/db/application"
dbentity "mayfly-go/internal/db/domain/entity"
machineapp "mayfly-go/internal/machine/application"
@@ -85,9 +84,7 @@ func (p *tagTreeAppImpl) Save(tag *entity.TagTree) {
// 校验同级标签是否有以该code为开头的标识符
p.tagTreeRepo.SelectByCondition(&entity.TagTreeQuery{Pid: tag.Pid}, &hasLikeTags)
for _, v := range hasLikeTags {
if strings.HasPrefix(tag.Code, v.Code) {
panic(biz.NewBizErr(fmt.Sprintf("同级标签下的[%s]与[%s]存在相似开头字符, 请修改该标识code", v.Code, tag.Code)))
}
biz.IsTrue(!strings.HasPrefix(tag.Code, v.Code), "同级标签下的[%s]与[%s]存在相似开头字符, 请修改该标识code", v.Code, tag.Code)
}
p.tagTreeRepo.Insert(tag)
return

View File

@@ -352,7 +352,7 @@ CREATE TABLE `t_sys_config` (
BEGIN;
INSERT INTO `t_sys_config` VALUES (1, '是否启用登录验证码', 'UseLoginCaptcha', NULL, '1', '1: 启用、0: 不启用', '2022-08-25 22:27:17', 1, 'admin', '2022-08-26 10:26:56', 1, 'admin');
INSERT INTO `t_sys_config` VALUES (2, '是否启用水印', 'UseWartermark', NULL, '1', '1: 启用、0: 不启用', '2022-08-25 23:36:35', 1, 'admin', '2022-08-26 10:02:52', 1, 'admin');
INSERT INTO `t_sys_config` VALUES (3, '数据库查询最大结果集', 'DbQueryMaxCount', '[]', '200', '允许sql查询的最大结果集数', '2023-02-11 14:29:03', 1, 'admin', '2023-02-11 14:40:56', 1, 'admin');
INSERT INTO `t_sys_config` VALUES (3, '数据库查询最大结果集', 'DbQueryMaxCount', '[]', '200', '允许sql查询的最大结果集数。注: 0=不限制', '2023-02-11 14:29:03', 1, 'admin', '2023-02-11 14:40:56', 1, 'admin');
INSERT INTO `t_sys_config` VALUES (4, '数据库是否记录查询SQL', 'DbSaveQuerySQL', '[]', '0', '1: 记录、0:不记录', '2023-02-11 16:07:14', 1, 'admin', '2023-02-11 16:44:17', 1, 'admin');
COMMIT;

View File

@@ -30,8 +30,6 @@ func GetCron() *cron.Cron {
func AddFun(spec string, cmd func()) cron.EntryID {
id, err := cronService.AddFunc(spec, cmd)
if err != nil {
panic(biz.NewBizErr("添加任务失败:" + err.Error()))
}
biz.ErrIsNilAppendErr(err, "添加任务失败: %s")
return id
}