From 2a1403904f2768edb01b44dbc38890ab351cd8fd Mon Sep 17 00:00:00 2001 From: ssongliu Date: Fri, 9 Sep 2022 17:17:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/setting.go | 2 +- backend/app/dto/setting.go | 3 +- backend/app/service/setting.go | 2 + backend/init/migration/migrations/init.go | 8 + backend/router/ro_setting.go | 5 +- frontend/src/api/interface/setting.ts | 11 + frontend/src/api/modules/setting.ts | 4 + frontend/src/lang/modules/zh.ts | 20 +- frontend/src/routers/modules/config.ts | 22 -- frontend/src/routers/modules/setting.ts | 4 +- frontend/src/styles/common.scss | 10 + .../src/views/{ => host}/monitor/index.vue | 0 frontend/src/views/host/terminal/index.vue | 10 +- frontend/src/views/setting/index.vue | 98 ++------ frontend/src/views/setting/tabs/about.vue | 0 frontend/src/views/setting/tabs/backup.vue | 17 ++ frontend/src/views/setting/tabs/message.vue | 152 +++++++++++++ frontend/src/views/setting/tabs/monitor.vue | 64 ++++++ frontend/src/views/setting/tabs/panel.vue | 214 ++++++++++++++++++ frontend/src/views/setting/tabs/safe.vue | 122 ++++++++++ frontend/src/views/system-config/index.vue | 7 - 21 files changed, 654 insertions(+), 121 deletions(-) delete mode 100644 frontend/src/routers/modules/config.ts rename frontend/src/views/{ => host}/monitor/index.vue (100%) create mode 100644 frontend/src/views/setting/tabs/about.vue create mode 100644 frontend/src/views/setting/tabs/backup.vue create mode 100644 frontend/src/views/setting/tabs/message.vue create mode 100644 frontend/src/views/setting/tabs/monitor.vue create mode 100644 frontend/src/views/setting/tabs/panel.vue create mode 100644 frontend/src/views/setting/tabs/safe.vue delete mode 100644 frontend/src/views/system-config/index.vue diff --git a/backend/app/api/v1/setting.go b/backend/app/api/v1/setting.go index e862a7a05..9ba3146f9 100644 --- a/backend/app/api/v1/setting.go +++ b/backend/app/api/v1/setting.go @@ -17,7 +17,7 @@ func (b *BaseApi) GetSettingInfo(c *gin.Context) { helper.SuccessWithData(c, setting) } -func (b *BaseApi) UpdateInfo(c *gin.Context) { +func (b *BaseApi) UpdateSetting(c *gin.Context) { var req dto.SettingUpdate if err := c.ShouldBindJSON(&req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) diff --git a/backend/app/dto/setting.go b/backend/app/dto/setting.go index d00361ad9..b589e8932 100644 --- a/backend/app/dto/setting.go +++ b/backend/app/dto/setting.go @@ -2,10 +2,10 @@ package dto type SettingInfo struct { UserName string `json:"userName"` - Password string `json:"password"` Email string `json:"email"` SessionTimeout string `json:"sessionTimeout"` + LocalTime string `json:"localTime"` PanelName string `json:"panelName"` Theme string `json:"theme"` @@ -13,6 +13,7 @@ type SettingInfo struct { ServerPort string `json:"serverPort"` SecurityEntrance string `json:"securityEntrance"` + PasswordTimeOut string `json:"passwordTimeOut"` ComplexityVerification string `json:"complexityVerification"` MFAStatus string `json:"mfaStatus"` diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go index 877bbfbef..e4dacaf79 100644 --- a/backend/app/service/setting.go +++ b/backend/app/service/setting.go @@ -2,6 +2,7 @@ package service import ( "encoding/json" + "time" "github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/constant" @@ -35,6 +36,7 @@ func (u *SettingService) GetSettingInfo() (*dto.SettingInfo, error) { if err := json.Unmarshal(arr, &info); err != nil { return nil, err } + info.LocalTime = time.Now().Format("2006.01.02 15:04:05") return &info, err } diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go index 99271fd3a..9b6f6584e 100644 --- a/backend/init/migration/migrations/init.go +++ b/backend/init/migration/migrations/init.go @@ -1,6 +1,8 @@ package migrations import ( + "time" + "github.com/1Panel-dev/1Panel/app/model" "github.com/go-gormigrate/gormigrate/v2" @@ -90,6 +92,9 @@ var AddTableSetting = &gormigrate.Migration{ if err := tx.Create(&model.Setting{Key: "SessionTimeout", Value: "86400"}).Error; err != nil { return err } + if err := tx.Create(&model.Setting{Key: "LocalTime", Value: ""}).Error; err != nil { + return err + } if err := tx.Create(&model.Setting{Key: "ServerPort", Value: "4004"}).Error; err != nil { return err @@ -97,6 +102,9 @@ var AddTableSetting = &gormigrate.Migration{ if err := tx.Create(&model.Setting{Key: "SecurityEntrance", Value: "/89dc6ae8"}).Error; err != nil { return err } + if err := tx.Create(&model.Setting{Key: "PasswordTimeOut", Value: time.Now().AddDate(0, 0, 10).Format("2016.01.02 15:04:05")}).Error; err != nil { + return err + } if err := tx.Create(&model.Setting{Key: "ComplexityVerification", Value: "enable"}).Error; err != nil { return err } diff --git a/backend/router/ro_setting.go b/backend/router/ro_setting.go index 4ce0363a0..1fa013d5c 100644 --- a/backend/router/ro_setting.go +++ b/backend/router/ro_setting.go @@ -9,9 +9,10 @@ import ( type SettingRouter struct{} func (s *SettingRouter) InitSettingRouter(Router *gin.RouterGroup) { - monitorRouter := Router.Group("settings").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) + settingRouter := Router.Group("settings").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) baseApi := v1.ApiGroupApp.BaseApi { - monitorRouter.POST("/search", baseApi.GetSettingInfo) + settingRouter.POST("/search", baseApi.GetSettingInfo) + settingRouter.PUT("", baseApi.UpdateSetting) } } diff --git a/frontend/src/api/interface/setting.ts b/frontend/src/api/interface/setting.ts index 21b26ef75..a587b6c30 100644 --- a/frontend/src/api/interface/setting.ts +++ b/frontend/src/api/interface/setting.ts @@ -5,6 +5,7 @@ export namespace Setting { email: string; sessionTimeout: string; + localTime: string; panelName: string; theme: string; @@ -12,6 +13,7 @@ export namespace Setting { serverPort: string; securityEntrance: string; + passwordTimeOut: string; complexityVerification: string; mfaStatus: string; @@ -23,4 +25,13 @@ export namespace Setting { weChatVars: string; dingVars: string; } + export interface SettingUpdate { + key: string; + value: string; + } + export interface PasswordUpdate { + oldPassword: string; + newPassword: string; + retryPassword: string; + } } diff --git a/frontend/src/api/modules/setting.ts b/frontend/src/api/modules/setting.ts index 842f20ad5..94eb00f02 100644 --- a/frontend/src/api/modules/setting.ts +++ b/frontend/src/api/modules/setting.ts @@ -4,3 +4,7 @@ import { Setting } from '../interface/setting'; export const getSettingInfo = () => { return http.post(`/settings/search`); }; + +export const updateSetting = (param: Setting.SettingUpdate) => { + return http.put(`/settings`, param); +}; diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index be6b85a50..1da4327e6 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -18,6 +18,16 @@ export default { dateStart: '开始日期', dateEnd: '结束日期', }, + personal: { + about: '关于', + project_url: '项目地址', + issue: '问题反馈', + talk: '参与讨论', + star: '点亮 Star', + version: '版本', + ko_introduction: + '是一个开源的轻量级 Kubernetes 发行版,专注于帮助企业规划、部署和运营生产级别的 Kubernetes 集群。', + }, table: { name: '名称', group: '组', @@ -47,6 +57,7 @@ export default { rule: { username: '请输入用户名', password: '请输入密码', + rePassword: '密码不一致,请检查后重新输入', requiredInput: '请填写必填项', requiredSelect: '请选择必选项', commonName: '支持英文、中文、数字、.-_,长度1-30', @@ -84,7 +95,10 @@ export default { menu: { home: '概览', demo: '样例', + monitor: '监控', terminal: '终端', + operations: '操作日志', + files: '文件管理', apps: '应用商店', website: '网站', project: '项目', @@ -95,12 +109,8 @@ export default { plan: '计划任务', host: '主机', security: '安全', - systemConfig: '面板设置', + settings: '面板设置', toolbox: '工具箱', - monitor: '监控', - operations: '操作记录', - files: '文件管理', - settings: '系统设置', }, home: { welcome: '欢迎使用', diff --git a/frontend/src/routers/modules/config.ts b/frontend/src/routers/modules/config.ts deleted file mode 100644 index f057686a9..000000000 --- a/frontend/src/routers/modules/config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Layout } from '@/routers/constant'; - -const systemConfigRouter = { - sort: 8, - path: '/configs', - component: Layout, - redirect: '/configs', - meta: { - icon: 'p-config', - title: 'menu.systemConfig', - }, - children: [ - { - path: '/configs', - name: 'SystemConfig', - component: () => import('@/views/system-config/index.vue'), - meta: {}, - }, - ], -}; - -export default systemConfigRouter; diff --git a/frontend/src/routers/modules/setting.ts b/frontend/src/routers/modules/setting.ts index 9840bb773..130543229 100644 --- a/frontend/src/routers/modules/setting.ts +++ b/frontend/src/routers/modules/setting.ts @@ -1,13 +1,13 @@ import { Layout } from '@/routers/constant'; const settingRouter = { - sort: 3, + sort: 7, path: '/settings', component: Layout, redirect: '/setting', meta: { title: 'menu.settings', - icon: 'Setting', + icon: 'p-config', }, children: [ { diff --git a/frontend/src/styles/common.scss b/frontend/src/styles/common.scss index 129888504..5165170bb 100644 --- a/frontend/src/styles/common.scss +++ b/frontend/src/styles/common.scss @@ -114,3 +114,13 @@ .form-button { float: right; } + +.input-help { + font-size: 12px; + word-break: break-all; + color: #4A4B4D; + transform: scale(0.9); + transform-origin: left; + width: 110%; + display: inline-block; +} \ No newline at end of file diff --git a/frontend/src/views/monitor/index.vue b/frontend/src/views/host/monitor/index.vue similarity index 100% rename from frontend/src/views/monitor/index.vue rename to frontend/src/views/host/monitor/index.vue diff --git a/frontend/src/views/host/terminal/index.vue b/frontend/src/views/host/terminal/index.vue index 1aee53eff..0551e6d53 100644 --- a/frontend/src/views/host/terminal/index.vue +++ b/frontend/src/views/host/terminal/index.vue @@ -34,7 +34,7 @@
@@ -182,9 +182,9 @@ import i18n from '@/lang'; import { ElForm } from 'element-plus'; import { Host } from '@/api/interface/host'; import { ElMessage } from 'element-plus'; -import Terminal from '@/views/terminal/terminal/index.vue'; -import HostTab from '@/views/terminal/host/index.vue'; -import CommandTab from '@/views/terminal/command/index.vue'; +import Terminal from '@/views/host/terminal/terminal/index.vue'; +import HostTab from '@/views/host/terminal/host/index.vue'; +import CommandTab from '@/views/host/terminal/command/index.vue'; import type Node from 'element-plus/es/components/tree/src/model/node'; import { ElTree } from 'element-plus'; import screenfull from 'screenfull'; diff --git a/frontend/src/views/setting/index.vue b/frontend/src/views/setting/index.vue index d2fde4124..798d18538 100644 --- a/frontend/src/views/setting/index.vue +++ b/frontend/src/views/setting/index.vue @@ -3,100 +3,45 @@ 全部 - 用户设置 - 面板设置 - 安全设置 - 备份设置 - 监控设置 - 通知设置 + 面板 + 安全 + 备份 + 监控 + 通知 关于 - - - - -
- - - - - - - - - - - 黑金 - - - - 自动 - - - - 白金 - - - - - - 中文 - English - - - - 更新用户设置 - - -
-
- - - -
- - - - - - - - -
-
-
+ + + + + diff --git a/frontend/src/views/setting/tabs/message.vue b/frontend/src/views/setting/tabs/message.vue new file mode 100644 index 000000000..c7e4444ac --- /dev/null +++ b/frontend/src/views/setting/tabs/message.vue @@ -0,0 +1,152 @@ + + + diff --git a/frontend/src/views/setting/tabs/monitor.vue b/frontend/src/views/setting/tabs/monitor.vue new file mode 100644 index 000000000..1f4408c9b --- /dev/null +++ b/frontend/src/views/setting/tabs/monitor.vue @@ -0,0 +1,64 @@ + + + diff --git a/frontend/src/views/setting/tabs/panel.vue b/frontend/src/views/setting/tabs/panel.vue new file mode 100644 index 000000000..badbbd540 --- /dev/null +++ b/frontend/src/views/setting/tabs/panel.vue @@ -0,0 +1,214 @@ + + + diff --git a/frontend/src/views/setting/tabs/safe.vue b/frontend/src/views/setting/tabs/safe.vue new file mode 100644 index 000000000..9f8e12df0 --- /dev/null +++ b/frontend/src/views/setting/tabs/safe.vue @@ -0,0 +1,122 @@ + + + diff --git a/frontend/src/views/system-config/index.vue b/frontend/src/views/system-config/index.vue deleted file mode 100644 index cdfc73be6..000000000 --- a/frontend/src/views/system-config/index.vue +++ /dev/null @@ -1,7 +0,0 @@ - - -