From 1e5b1868ab4c6bd0705813d998209f9f280bb7ee Mon Sep 17 00:00:00 2001 From: "meilin.huang" <954537473@qq.com> Date: Mon, 28 Aug 2023 17:25:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20redis=E6=93=8D=E4=BD=9C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- mayfly_go_web/src/common/config.ts | 2 +- .../views/login/component/AccountLogin.vue | 10 +- .../src/views/ops/component/TagTree.vue | 7 +- .../src/views/ops/redis/DataOperation.vue | 459 ++++++++++++------ .../src/views/ops/redis/FormatViewer.vue | 23 +- .../src/views/ops/redis/KeyDetail.vue | 39 +- .../src/views/ops/redis/KeyHeader.vue | 105 +++- .../src/views/ops/redis/KeyValueString.vue | 44 +- .../src/views/ops/redis/ViewerJson.vue | 16 +- mayfly_go_web/src/views/ops/redis/api.ts | 1 + mayfly_go_web/src/views/ops/redis/utils.ts | 116 +++++ .../src/views/system/config/ConfigEdit.vue | 1 - server/internal/redis/api/key.go | 165 +++---- server/internal/redis/api/vo/redis.go | 4 +- server/internal/redis/router/redis.go | 4 +- server/mayfly-go.sql | 5 +- server/pkg/config/app.go | 2 +- 18 files changed, 673 insertions(+), 332 deletions(-) create mode 100644 mayfly_go_web/src/views/ops/redis/utils.ts diff --git a/README.md b/README.md index 35c918af..d488afef 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ web 版 **linux(终端[终端回放] 文件 脚本 进程)、数据库(mysql p ### 演示环境 -http://mayflygo.1yue.net +http://go.mayfly.run 账号/密码:test/test123. ### 系统核心功能截图 diff --git a/mayfly_go_web/src/common/config.ts b/mayfly_go_web/src/common/config.ts index de294290..4fae4829 100644 --- a/mayfly_go_web/src/common/config.ts +++ b/mayfly_go_web/src/common/config.ts @@ -11,7 +11,7 @@ const config = { baseWsUrl: `${(window as any).globalConfig.BaseWsUrl || `${location.protocol == 'https:' ? 'wss:' : 'ws:'}//${getBaseApiUrl()}`}/api`, // 系统版本 - version: 'v1.5.0', + version: 'v1.5.1', }; export default config; diff --git a/mayfly_go_web/src/views/login/component/AccountLogin.vue b/mayfly_go_web/src/views/login/component/AccountLogin.vue index 9c9f2e96..3c955fa6 100644 --- a/mayfly_go_web/src/views/login/component/AccountLogin.vue +++ b/mayfly_go_web/src/views/login/component/AccountLogin.vue @@ -38,7 +38,7 @@ - + 提示:登录失败超过{{ accountLoginSecurity.loginFailCount }}次后将被限制{{ accountLoginSecurity.loginFailMin }}分钟内不可再次登录 @@ -136,7 +136,7 @@ import { getSession, setSession, setUserInfo2Session, setUseWatermark2Session } import { formatAxis } from '@/common/utils/format'; import openApi from '@/common/openApi'; import { RsaEncrypt } from '@/common/rsa'; -import {getAccountLoginSecurity, getLdapEnabled, useWartermark} from '@/common/sysconfig'; +import { getAccountLoginSecurity, getLdapEnabled, useWartermark } from '@/common/sysconfig'; import { letterAvatar } from '@/common/utils/string'; import { useUserInfo } from '@/store/userInfo'; import QrcodeVue from 'qrcode.vue'; @@ -242,7 +242,7 @@ onMounted(async () => { const ldap = await getLdapEnabled(); state.ldapEnabled = ldap; - state.loginForm.ldapLogin = ldap + state.loginForm.ldapLogin = ldap; }); // 移除公钥, 方便后续重新获取 sessionStorage.removeItem('RsaPublicKey'); @@ -298,9 +298,9 @@ const onSignIn = async () => { const loginReq = { ...state.loginForm }; loginReq.password = await RsaEncrypt(originPwd); if (state.loginForm.ldapLogin) { - loginRes = await openApi.ldapLogin(loginReq); + loginRes = await openApi.ldapLogin(loginReq); } else { - loginRes = await openApi.login(loginReq); + loginRes = await openApi.login(loginReq); } } catch (e: any) { state.loading.signIn = false; diff --git a/mayfly_go_web/src/views/ops/component/TagTree.vue b/mayfly_go_web/src/views/ops/component/TagTree.vue index ea8c3bd1..33eaf1f6 100644 --- a/mayfly_go_web/src/views/ops/component/TagTree.vue +++ b/mayfly_go_web/src/views/ops/component/TagTree.vue @@ -84,12 +84,17 @@ const { filterText } = toRefs(state); onMounted(async () => { if (!props.height) { - state.height = window.innerHeight - 147 + 'px'; + setHeight(); + window.onresize = () => setHeight(); } else { state.height = props.height; } }); +const setHeight = () => { + state.height = window.innerHeight - 147 + 'px'; +}; + watch(filterText, (val) => { treeRef.value?.filter(val); }); diff --git a/mayfly_go_web/src/views/ops/redis/DataOperation.vue b/mayfly_go_web/src/views/ops/redis/DataOperation.vue index 0a7fd97b..90aa3cb4 100644 --- a/mayfly_go_web/src/views/ops/redis/DataOperation.vue +++ b/mayfly_go_web/src/views/ops/redis/DataOperation.vue @@ -29,74 +29,134 @@ - -
- - - - - - - - - - - scan - - flush - -
- keys: {{ state.dbsize }} -
-
-
- - - - - - - - - - - - + +
+ + + + + + + + + + + + + + + 加载更多 + + 新增key + + flush + + + keys: {{ state.dbsize }} + + + + + + +
+
+ + +
+ + + + +
- - - - - + - + @@ -109,7 +169,7 @@ @@ -118,11 +178,12 @@ diff --git a/mayfly_go_web/src/views/ops/redis/FormatViewer.vue b/mayfly_go_web/src/views/ops/redis/FormatViewer.vue index 3b4ffd13..edb2dc9d 100644 --- a/mayfly_go_web/src/views/ops/redis/FormatViewer.vue +++ b/mayfly_go_web/src/views/ops/redis/FormatViewer.vue @@ -21,6 +21,10 @@ const props = defineProps({ content: { type: String, }, + height: { + type: String, + default: '0px', + }, }); const components = shallowReactive({ @@ -53,14 +57,24 @@ const viewerComponent = computed(() => { watch( () => props.content, (val: any) => { - state.content = val; + setContent(val); } ); onMounted(() => { - state.content = props.content as any; + setContent(props.content as any); }); +const setContent = (content: string) => { + state.content = content; + try { + JSON.parse(content); + state.selectedView = 'Json'; + } catch (e) { + state.selectedView = 'Text'; + } +}; + const getContent = () => { return viewerRef.value.getContent(); }; @@ -90,12 +104,13 @@ defineExpose({ getContent }); } // 默认文本框样式 + .format-viewer-container .el-textarea textarea { font-size: 14px; - height: calc(100vh - 536px); + height: calc(100vh - 536px + v-bind(height)); } .format-viewer-container .monaco-editor-content { - height: calc(100vh - 550px) !important; + height: calc(100vh - 550px + v-bind(height)) !important; } diff --git a/mayfly_go_web/src/views/ops/redis/KeyDetail.vue b/mayfly_go_web/src/views/ops/redis/KeyDetail.vue index b6c62933..d1af0ac8 100644 --- a/mayfly_go_web/src/views/ops/redis/KeyDetail.vue +++ b/mayfly_go_web/src/views/ops/redis/KeyDetail.vue @@ -6,8 +6,9 @@ ref="keyHeader" :redis-id="redisId" :db="db" - :key-info="keyInfo" + :key-info="state.keyInfo" @refresh-content="refreshContent" + @del-key="delKey" @change-key="changeKey" class="key-header-info" > @@ -19,7 +20,7 @@
diff --git a/mayfly_go_web/src/views/ops/redis/ViewerJson.vue b/mayfly_go_web/src/views/ops/redis/ViewerJson.vue index 506d8da5..ee86a84e 100644 --- a/mayfly_go_web/src/views/ops/redis/ViewerJson.vue +++ b/mayfly_go_web/src/views/ops/redis/ViewerJson.vue @@ -4,7 +4,7 @@