diff --git a/backend/app/dto/database.go b/backend/app/dto/database.go index 4cf540e46..e3611bac5 100644 --- a/backend/app/dto/database.go +++ b/backend/app/dto/database.go @@ -128,10 +128,9 @@ type UploadRecover struct { // redis type RedisConfUpdate struct { - Timeout string `json:"timeout"` - Maxclients string `json:"maxclients"` - Requirepass string `json:"requirepass"` - Maxmemory string `json:"maxmemory"` + Timeout string `json:"timeout"` + Maxclients string `json:"maxclients"` + Maxmemory string `json:"maxmemory"` } type RedisConfPersistenceUpdate struct { Type string `json:"type" validate:"required,oneof=aof rbd"` diff --git a/backend/router/ro_database.go b/backend/router/ro_database.go index 656025a95..5d97add06 100644 --- a/backend/router/ro_database.go +++ b/backend/router/ro_database.go @@ -40,7 +40,7 @@ func (s *DatabaseRouter) InitDatabaseRouter(Router *gin.RouterGroup) { cmdRouter.POST("/redis/password", baseApi.ChangeRedisPassword) cmdRouter.POST("/redis/backup", baseApi.RedisBackup) cmdRouter.POST("/redis/recover", baseApi.RedisRecover) - cmdRouter.POST("/redis/backuplist/search", baseApi.RedisBackupList) + cmdRouter.POST("/redis/backup/search", baseApi.RedisBackupList) cmdRouter.POST("/redis/conf/update", baseApi.UpdateRedisConf) cmdRouter.POST("/redis/conffile/update", baseApi.UpdateRedisConfByFile) cmdRouter.POST("/redis/persistence/update", baseApi.UpdateRedisPersistenceConf) diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index ed9b5f743..86550d58c 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -120,7 +120,6 @@ export namespace Database { export interface RedisConfUpdate { timeout: string; maxclients: string; - requirepass: string; maxmemory: string; } export interface RedisConfPersistenceUpdate { diff --git a/frontend/src/api/modules/database.ts b/frontend/src/api/modules/database.ts index 3066e77e3..bd88782d6 100644 --- a/frontend/src/api/modules/database.ts +++ b/frontend/src/api/modules/database.ts @@ -83,5 +83,5 @@ export const recoverRedis = (param: Database.RedisRecover) => { return http.post(`/databases/redis/recover`, param); }; export const redisBackupRedisRecords = (param: ReqPage) => { - return http.post>(`/databases/redis/backup/records`, param); + return http.post>(`/databases/redis/backup/search`, param); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 0c803aff5..a940dc673 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -132,6 +132,9 @@ export default { changePassword: 'Change Password', logout: 'Logout', }, + service: { + serviceNotStarted: 'The {0} service is not currently started', + }, status: { running: 'running', stopped: 'stopped', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 340b95898..7d402d7c9 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -134,6 +134,9 @@ export default { changePassword: '修改密码', logout: '退出登录', }, + service: { + serviceNotStarted: '当前未启动 {0} 服务', + }, status: { running: '已启动', success: '成功', diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index 5fb77f70a..ba6c3b1bc 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -11,11 +11,7 @@ - {{ $t('database.mysqlBadStatus') }} - - 【 {{ $t('database.setting') }} 】 - - {{ $t('database.adjust') }} + {{ $t('commons.service.serviceNotStarted', ['Mysql']) }}
diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue index 8a26442f6..ea798bf8f 100644 --- a/frontend/src/views/database/mysql/setting/index.vue +++ b/frontend/src/views/database/mysql/setting/index.vue @@ -78,7 +78,7 @@ import Status from '@/views/database/mysql/setting/status/index.vue'; import Variables from '@/views/database/mysql/setting/variables/index.vue'; import SlowLog from '@/views/database/mysql/setting/slow-log/index.vue'; import ConfirmDialog from '@/components/confirm-dialog/index.vue'; -import { onUnmounted, reactive, ref } from 'vue'; +import { reactive, ref } from 'vue'; import { Codemirror } from 'vue-codemirror'; import { javascript } from '@codemirror/lang-javascript'; import { oneDark } from '@codemirror/theme-one-dark'; @@ -239,10 +239,6 @@ const loadMysqlConf = async (path: string) => { mysqlConf.value = res.data; }; -onUnmounted(() => { - console.log('adasd'); -}); - defineExpose({ acceptParams, onClose, diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue index cb288f6e4..a8457bc64 100644 --- a/frontend/src/views/database/redis/index.vue +++ b/frontend/src/views/database/redis/index.vue @@ -10,24 +10,22 @@ @is-exist="checkExist" v-model:loading="loading" > - - - Redis-Commander - - - - - {{ $t('database.mysqlBadStatus') }} - - 【 {{ $t('database.setting') }} 】 - - {{ $t('database.adjust') }} + {{ $t('commons.service.serviceNotStarted', ['Redis']) }} +
- + + Redis-Commander + + + {{ $t('database.changePassword') }} + +
+ + import Submenu from '@/views/database/index.vue'; import Setting from '@/views/database/redis/setting/index.vue'; +import Password from '@/views/database/redis/password/index.vue'; import Terminal from '@/views/database/redis/terminal/index.vue'; import AppStatus from '@/components/app-status/index.vue'; import { ref } from 'vue'; @@ -66,14 +65,17 @@ const settingRef = ref(); const isOnSetting = ref(false); const redisIsExist = ref(false); const redisStatus = ref(); +const redisName = ref(); const redisCommandPort = ref(); const commandVisiable = ref(false); +const isRefresh = ref(); + const onSetting = async () => { isOnSetting.value = true; - terminalRef.value.onClose(); - settingRef.value!.acceptParams({ status: redisStatus.value }); + terminalRef.value.onClose(false); + settingRef.value!.acceptParams({ status: redisStatus.value, redisName: redisName.value }); }; const goRouter = async (path: string) => { @@ -95,8 +97,14 @@ const loadDashboardPort = async () => { redisCommandPort.value = res.data; }; +const passwordRef = ref(); +const onChangePassword = async () => { + passwordRef.value!.acceptParams(); +}; + const checkExist = (data: App.CheckInstalled) => { redisIsExist.value = data.isExist; + redisName.value = data.name; redisStatus.value = data.status; loading.value = false; if (redisStatus.value === 'Running') { @@ -105,8 +113,18 @@ const checkExist = (data: App.CheckInstalled) => { } }; +const initTerminal = async () => { + if (redisStatus.value === 'Running') { + terminalRef.value.acceptParams(); + } +}; +const closeTerminal = async (isKeepShow: boolean) => { + isRefresh.value = !isRefresh.value; + terminalRef.value!.onClose(isKeepShow); +}; + const onBefore = () => { - terminalRef.value!.onClose(); + closeTerminal(true); loading.value = true; }; diff --git a/frontend/src/views/database/redis/password/index.vue b/frontend/src/views/database/redis/password/index.vue new file mode 100644 index 000000000..e7a438c04 --- /dev/null +++ b/frontend/src/views/database/redis/password/index.vue @@ -0,0 +1,89 @@ + + + diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue index cd805d731..f9f7689f3 100644 --- a/frontend/src/views/database/redis/setting/index.vue +++ b/frontend/src/views/database/redis/setting/index.vue @@ -3,89 +3,80 @@ - - - {{ $t('database.baseConf') }} - {{ $t('database.allConf') }} - - - -
- - - - - - {{ $t('database.portHelper') }} - - - - - - {{ $t('database.requirepassHelper') }} - -
- - - {{ $t('database.timeoutHelper') }} - - - - - - - {{ $t('database.maxmemoryHelper') }} - - - - {{ $t('commons.button.save') }} - - -
-
-
-
-
- - - {{ $t('commons.button.save') }} - -
+ + + + {{ $t('commons.button.save') }} + + + +
+ + + + {{ $t('database.timeoutHelper') }} + + + + + + + {{ $t('database.maxmemoryHelper') }} + + + + {{ $t('commons.button.save') }} + + + +
+
+
+ + + + +
+ + + + + + + +
+
+
+ @@ -93,9 +84,9 @@
- - - + + +
@@ -110,20 +101,18 @@ import { LoadFile } from '@/api/modules/files'; import ConfirmDialog from '@/components/confirm-dialog/index.vue'; import Status from '@/views/database/redis/setting/status/index.vue'; import Persistence from '@/views/database/redis/setting/persistence/index.vue'; -import { changeRedisPassword, loadRedisConf, updateRedisConf, updateRedisConfByFile } from '@/api/modules/database'; +import { loadRedisConf, updateRedisConf, updateRedisConfByFile } from '@/api/modules/database'; import i18n from '@/lang'; import { Rules } from '@/global/form-rules'; import { ChangePort } from '@/api/modules/app'; const extensions = [javascript(), oneDark]; -const confShowType = ref('base'); const loading = ref(false); const form = reactive({ name: '', port: 6379, - requirepass: '', timeout: 0, maxclients: 0, maxmemory: 0, @@ -140,63 +129,56 @@ const statusRef = ref(); const persistenceRef = ref(); const redisStatus = ref(); +const redisName = ref(); const formRef = ref(); const redisConf = ref(); const confirmDialogRef = ref(); -const confirmDialogRef2 = ref(); const settingShow = ref(false); interface DialogProps { + redisName: string; status: string; } const acceptParams = (prop: DialogProps): void => { redisStatus.value = prop.status; + redisName.value = prop.redisName; settingShow.value = true; - loadform(); - statusRef.value!.acceptParams({ status: prop.status }); - persistenceRef.value!.acceptParams({ status: prop.status }); + loadConfFile(); + if (redisStatus.value === 'Running') { + statusRef.value!.acceptParams({ status: prop.status }); + persistenceRef.value!.acceptParams({ status: prop.status }); + } }; const onClose = (): void => { settingShow.value = false; }; -const onSavePort = async () => { +const portRef = ref(); +const confirmPortRef = ref(); +const onSavePort = async (formEl: FormInstance | undefined) => { + if (!formEl) return; + const result = await formEl.validateField('port', callback); + if (!result) { + return; + } let params = { header: i18n.global.t('database.confChange'), - operationInfo: i18n.global.t('database.restartNowHelper1'), + operationInfo: i18n.global.t('database.restartNowHelper'), submitInputInfo: i18n.global.t('database.restartNow'), }; - confirmDialogRef2.value!.acceptParams(params); + confirmPortRef.value!.acceptParams(params); + return; }; - -const confirmDialogRef3 = ref(); -const onSavePassword = async () => { - let params = { - header: i18n.global.t('database.confChange'), - operationInfo: i18n.global.t('database.restartNowHelper1'), - submitInputInfo: i18n.global.t('database.restartNow'), - }; - confirmDialogRef3.value!.acceptParams(params); -}; -const onChangePassword = async () => { - loading.value = true; - let param = { - id: 0, - value: form.requirepass, - }; - changeRedisPassword(param) - .then(() => { - loading.value = false; - ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); - }) - .finally(() => { - loading.value = false; - }); -}; - +function callback(error: any) { + if (error) { + return error.message; + } else { + return; + } +} const onChangePort = async (formEl: FormInstance | undefined) => { if (!formEl) return; const result = await formEl.validateField('port', callback); @@ -218,33 +200,30 @@ const onChangePort = async (formEl: FormInstance | undefined) => { loading.value = false; }); }; -function callback(error: any) { - if (error) { - return error.message; - } else { - return; - } -} -const onChangeMode = async () => { - if (confShowType.value === 'all') { - loadredisConf(); - } else { - loadform(); - } -}; +// const onChangePassword = async () => { +// loading.value = true; +// let param = { +// id: 0, +// value: form.requirepass, +// }; +// changeRedisPassword(param) +// .then(() => { +// loading.value = false; +// ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); +// }) +// .finally(() => { +// loading.value = false; +// }); +// }; -const onSave = async (formEl: FormInstance | undefined) => { - if (confShowType.value === 'all') { - onSaveFile(); - } +const submtiForm = async (formEl: FormInstance | undefined) => { if (!formEl) return; formEl.validate(async (valid) => { if (!valid) return; let param = { timeout: form.timeout + '', maxclients: form.maxclients + '', - requirepass: form.requirepass, maxmemory: form.maxmemory + '', }; loading.value = true; @@ -268,8 +247,7 @@ const onSaveFile = async () => { }; confirmDialogRef.value!.acceptParams(params); }; - -const onSubmitSave = async () => { +const submtiFile = async () => { let param = { file: redisConf.value, restartNow: true, @@ -293,7 +271,6 @@ const loadform = async () => { form.name = res.data?.name; form.timeout = Number(res.data?.timeout); form.maxclients = Number(res.data?.maxclients); - form.requirepass = res.data?.requirepass; form.maxmemory = Number(res.data?.maxmemory); form.port = Number(res.data?.port); }) @@ -302,8 +279,8 @@ const loadform = async () => { }); }; -const loadredisConf = async () => { - let path = `/opt/1Panel/data/apps/redis/${form.name}/conf/redis.conf`; +const loadConfFile = async () => { + let path = `/opt/1Panel/data/apps/redis/${redisName.value}/conf/redis.conf`; const res = await LoadFile({ path: path }); redisConf.value = res.data; }; diff --git a/frontend/src/views/database/redis/terminal/index.vue b/frontend/src/views/database/redis/terminal/index.vue index 655efd828..b29a37e34 100644 --- a/frontend/src/views/database/redis/terminal/index.vue +++ b/frontend/src/views/database/redis/terminal/index.vue @@ -29,13 +29,15 @@ const acceptParams = async (): Promise => { initTerm(); window.addEventListener('resize', changeTerminalSize); }; -const onClose = async () => { +const onClose = async (isKeepShow: boolean) => { window.removeEventListener('resize', changeTerminalSize); if (isWsOpen()) { terminalSocket && terminalSocket.close(); + } + if (!isKeepShow) { term.dispose(); } - terminalShow.value = false; + terminalShow.value = isKeepShow; }; const onWSReceive = (message: any) => {