From 411e2d1e5d1f3db497f714a794018045328e9a65 Mon Sep 17 00:00:00 2001 From: baiqi Date: Fri, 28 Jul 2023 16:34:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE-=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2&=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.vue | 25 +- frontend/src/api/modules/setting/config.ts | 35 ++ frontend/src/api/requrls/setting/config.ts | 5 + frontend/src/assets/style/arco-reset.less | 7 +- frontend/src/assets/style/var.less | 5 + .../bussiness/ms-form-item-sub/index.vue | 30 ++ .../src/components/pure/ms-card/index.vue | 22 +- .../components/pure/ms-description/index.vue | 24 +- .../src/components/pure/ms-drawer/index.vue | 64 ++- .../components/pure/ms-drawer/locale/en-US.ts | 4 + .../components/pure/ms-drawer/locale/zh-CN.ts | 4 + frontend/src/locale/en-US/index.ts | 1 + frontend/src/locale/zh-CN/index.ts | 1 + frontend/src/models/setting/config.ts | 38 ++ frontend/src/router/routes/modules/setting.ts | 10 + frontend/src/utils/index.ts | 13 + .../system/config/components/baseConfig.vue | 491 ++++++++++++++++++ .../src/views/setting/system/config/index.vue | 36 ++ .../setting/system/config/locale/en-US.ts | 6 + .../setting/system/config/locale/zh-CN.ts | 48 ++ .../components/scriptDetailDrawer.vue | 2 +- .../components/jobTemplateDrawer.vue | 2 +- .../setting/system/resourcePool/index.vue | 123 +++-- 23 files changed, 902 insertions(+), 94 deletions(-) create mode 100644 frontend/src/api/modules/setting/config.ts create mode 100644 frontend/src/api/requrls/setting/config.ts create mode 100644 frontend/src/components/bussiness/ms-form-item-sub/index.vue create mode 100644 frontend/src/components/pure/ms-drawer/locale/en-US.ts create mode 100644 frontend/src/components/pure/ms-drawer/locale/zh-CN.ts create mode 100644 frontend/src/models/setting/config.ts create mode 100644 frontend/src/views/setting/system/config/components/baseConfig.vue create mode 100644 frontend/src/views/setting/system/config/index.vue create mode 100644 frontend/src/views/setting/system/config/locale/en-US.ts create mode 100644 frontend/src/views/setting/system/config/locale/zh-CN.ts diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 01e71a01ae..79b63e2838 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -6,11 +6,13 @@ diff --git a/frontend/src/api/modules/setting/config.ts b/frontend/src/api/modules/setting/config.ts new file mode 100644 index 0000000000..a2c438d294 --- /dev/null +++ b/frontend/src/api/modules/setting/config.ts @@ -0,0 +1,35 @@ +import MSR from '@/api/http/index'; +import { + TestEmailUrl, + SaveBaseInfoUrl, + SaveEmailInfoUrl, + GetBaseInfoUrl, + GetEmailInfoUrl, +} from '@/api/requrls/setting/config'; + +import type { SaveInfoParams, TestEmailParams, EmailConfig, BaseConfig } from '@/models/setting/config'; + +// 测试邮箱连接 +export function testEmail(data: TestEmailParams) { + return MSR.post({ url: TestEmailUrl, data }); +} + +// 保存基础信息 +export function saveBaseInfo(data: SaveInfoParams) { + return MSR.post({ url: SaveBaseInfoUrl, data }); +} + +// 获取基础信息 +export function getBaseInfo() { + return MSR.get({ url: GetBaseInfoUrl }); +} + +// 保存邮箱信息 +export function saveEmailInfo(data: SaveInfoParams) { + return MSR.post({ url: SaveEmailInfoUrl, data }); +} + +// 获取邮箱信息 +export function getEmailInfo() { + return MSR.get({ url: GetEmailInfoUrl }); +} diff --git a/frontend/src/api/requrls/setting/config.ts b/frontend/src/api/requrls/setting/config.ts new file mode 100644 index 0000000000..e3fbd8cf75 --- /dev/null +++ b/frontend/src/api/requrls/setting/config.ts @@ -0,0 +1,5 @@ +export const TestEmailUrl = '/system/parameter/test/email'; +export const SaveBaseInfoUrl = '/system/parameter/save/base-info'; +export const SaveEmailInfoUrl = '/system/parameter/edit/email-info'; +export const GetEmailInfoUrl = '/system/parameter/get/email-info'; +export const GetBaseInfoUrl = '/system/parameter/get/base-info'; diff --git a/frontend/src/assets/style/arco-reset.less b/frontend/src/assets/style/arco-reset.less index 8dd963884f..9ef7c93323 100644 --- a/frontend/src/assets/style/arco-reset.less +++ b/frontend/src/assets/style/arco-reset.less @@ -142,6 +142,12 @@ .btn-outline-primary-active(); .btn-outline-primary-disabled(); } +.arco-btn-outline--secondary { + .btn-outline-sec-default(); + .btn-outline-sec-hover(); + .btn-outline-sec-active(); + .btn-outline-sec-disabled(); +} /** 输入框,选择器,文本域 **/ .arco-input-wrapper, @@ -452,7 +458,6 @@ /** 滚动条 **/ .arco-scrollbar-track-direction-horizontal { - margin-bottom: 4px; height: 6px; .arco-scrollbar-thumb-bar { @apply m-0; diff --git a/frontend/src/assets/style/var.less b/frontend/src/assets/style/var.less index 3420f083ff..c5448b2e9c 100644 --- a/frontend/src/assets/style/var.less +++ b/frontend/src/assets/style/var.less @@ -38,6 +38,11 @@ background-color: var(--color-text-n9) !important; } } +.btn-outline-sec-default() { + border-color: var(--color-text-brand) !important; + color: var(--color-text-1) !important; + background-color: white !important; +} .btn-outline-sec-active() { &:not(:disabled):active { border-color: var(--color-text-brand) !important; diff --git a/frontend/src/components/bussiness/ms-form-item-sub/index.vue b/frontend/src/components/bussiness/ms-form-item-sub/index.vue new file mode 100644 index 0000000000..8aa2a92ef6 --- /dev/null +++ b/frontend/src/components/bussiness/ms-form-item-sub/index.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/frontend/src/components/pure/ms-card/index.vue b/frontend/src/components/pure/ms-card/index.vue index 7529a02306..faf8f5eaf6 100644 --- a/frontend/src/components/pure/ms-card/index.vue +++ b/frontend/src/components/pure/ms-card/index.vue @@ -18,12 +18,14 @@ - +
+ +
@@ -92,6 +121,11 @@ border-bottom: 1px solid var(--color-text-n8); } } + .ms-drawer { + .arco-scrollbar-track-direction-vertical { + right: -12px; + } + } .ms-drawer-no-mask { left: auto; .arco-drawer { diff --git a/frontend/src/components/pure/ms-drawer/locale/en-US.ts b/frontend/src/components/pure/ms-drawer/locale/en-US.ts new file mode 100644 index 0000000000..fb71ee1f37 --- /dev/null +++ b/frontend/src/components/pure/ms-drawer/locale/en-US.ts @@ -0,0 +1,4 @@ +export default { + 'ms.drawer.cancel': 'Cancel', + 'ms.drawer.ok': 'Confirm', +}; diff --git a/frontend/src/components/pure/ms-drawer/locale/zh-CN.ts b/frontend/src/components/pure/ms-drawer/locale/zh-CN.ts new file mode 100644 index 0000000000..10d992fecb --- /dev/null +++ b/frontend/src/components/pure/ms-drawer/locale/zh-CN.ts @@ -0,0 +1,4 @@ +export default { + 'ms.drawer.cancel': '取消', + 'ms.drawer.ok': '确认', +}; diff --git a/frontend/src/locale/en-US/index.ts b/frontend/src/locale/en-US/index.ts index 24d8bd39fe..1ee5c2e177 100644 --- a/frontend/src/locale/en-US/index.ts +++ b/frontend/src/locale/en-US/index.ts @@ -36,6 +36,7 @@ export default { 'menu.settings.system.resourcePool': 'Resource Pool', 'menu.settings.system.resourcePoolDetail': 'Add resource pool', 'menu.settings.system.resourcePoolEdit': 'Edit resource pool', + 'menu.settings.system.parameter': 'System parameter', 'navbar.action.locale': 'Switch to English', ...sys, ...localeSettings, diff --git a/frontend/src/locale/zh-CN/index.ts b/frontend/src/locale/zh-CN/index.ts index 07f063bf12..280db4668d 100644 --- a/frontend/src/locale/zh-CN/index.ts +++ b/frontend/src/locale/zh-CN/index.ts @@ -36,6 +36,7 @@ export default { 'menu.settings.system.resourcePool': '资源池', 'menu.settings.system.resourcePoolDetail': '添加资源池', 'menu.settings.system.resourcePoolEdit': '编辑资源池', + 'menu.settings.system.parameter': '系统参数', 'navbar.action.locale': '切换为中文', ...sys, ...localeSettings, diff --git a/frontend/src/models/setting/config.ts b/frontend/src/models/setting/config.ts new file mode 100644 index 0000000000..9aae0a1632 --- /dev/null +++ b/frontend/src/models/setting/config.ts @@ -0,0 +1,38 @@ +// 基础信息配置 +export interface BaseConfig { + url: string; + prometheusHost: string; +} + +// 邮箱信息配置 +export interface EmailConfig { + host: string; // 主机 + port: string; // 端口 + account: string; // 账户 + from: string; // 发件人 + password: string; // 密码 + ssl: string; + tsl: string; + recipient: string; // 收件人 +} + +interface ParamItem { + paramKey: string; // 参数的 key + paramValue: string; // 参数的值 + type: string; // 参数类型,一般是 string +} + +// 保存基础信息、邮箱信息接口入参 +export type SaveInfoParams = ParamItem[]; + +// 测试邮箱连接接口入参 +export interface TestEmailParams { + 'smtp.host': string; + 'smtp.port': string; + 'smtp.account': string; + 'smtp.password': string; + 'smtp.from': string; + 'smtp.ssl': string; + 'smtp.tsl': string; + 'smtp.recipient': string; +} diff --git a/frontend/src/router/routes/modules/setting.ts b/frontend/src/router/routes/modules/setting.ts index 20a9841c85..3c295e7949 100644 --- a/frontend/src/router/routes/modules/setting.ts +++ b/frontend/src/router/routes/modules/setting.ts @@ -89,6 +89,16 @@ const Setting: AppRouteRecordRaw = { isTopMenu: true, }, }, + { + path: 'parameter', + name: 'settingSystemParameter', + component: () => import('@/views/setting/system/config/index.vue'), + meta: { + locale: 'menu.settings.system.parameter', + roles: ['*'], + isTopMenu: true, + }, + }, ], }, { diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 08ac9249d5..11e6925d76 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -120,3 +120,16 @@ export function formatFileSize(fileSize: number): string { return `${formattedSize} ${unit}`; } + +/** + * 字符串脱敏 + * @param str 需要脱敏的字符串 + * @returns 脱敏后的字符串 + */ +export function desensitize(str: string): string { + if (!str || typeof str !== 'string') { + return ''; + } + + return str.replace(/./g, '*'); +} diff --git a/frontend/src/views/setting/system/config/components/baseConfig.vue b/frontend/src/views/setting/system/config/components/baseConfig.vue new file mode 100644 index 0000000000..b3a37b2510 --- /dev/null +++ b/frontend/src/views/setting/system/config/components/baseConfig.vue @@ -0,0 +1,491 @@ + + + + + diff --git a/frontend/src/views/setting/system/config/index.vue b/frontend/src/views/setting/system/config/index.vue new file mode 100644 index 0000000000..28c218dedc --- /dev/null +++ b/frontend/src/views/setting/system/config/index.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/frontend/src/views/setting/system/config/locale/en-US.ts b/frontend/src/views/setting/system/config/locale/en-US.ts new file mode 100644 index 0000000000..645086c31f --- /dev/null +++ b/frontend/src/views/setting/system/config/locale/en-US.ts @@ -0,0 +1,6 @@ +export default { + 'system.config.parameterConfig': 'System Parameters Configuration', + 'system.config.baseConfig': 'Basic Settings', + 'system.config.pageConfig': 'Interface settings', + 'system.config.authConfig': 'Authentication Settings', +}; diff --git a/frontend/src/views/setting/system/config/locale/zh-CN.ts b/frontend/src/views/setting/system/config/locale/zh-CN.ts new file mode 100644 index 0000000000..78fdeabb3a --- /dev/null +++ b/frontend/src/views/setting/system/config/locale/zh-CN.ts @@ -0,0 +1,48 @@ +export default { + 'system.config.parameterConfig': '系统参数配置', + 'system.config.baseConfig': '基础设置', + 'system.config.pageConfig': '界面设置', + 'system.config.authConfig': '认证设置', + 'system.config.baseInfo': '基本信息', + 'system.config.update': '更新', + 'system.config.pageUrl': '当前站点 URL', + 'system.config.prometheus': 'Prometheus', + 'system.config.emailConfig': '邮件设置', + 'system.config.email.host': 'SMTP 主机', + 'system.config.email.port': 'SMTP 端口', + 'system.config.email.account': 'SMTP 账户', + 'system.config.email.password': 'SMTP 密码', + 'system.config.email.from': '指定发件人', + 'system.config.email.recipient': '测试收件人', + 'system.config.email.ssl': 'SSL', + 'system.config.email.tsl': 'TSL', + 'system.config.email.open': '开启', + 'system.config.email.close': '关闭', + 'system.config.email.test': '测试连接', + 'system.config.baseInfo.updateTitle': '更新基本信息', + 'system.config.baseInfo.update': '更新', + 'system.config.baseInfo.updateSuccess': '更新成功', + 'system.config.baseInfo.pageUrlSub': '例如:{url}', + 'system.config.baseInfo.pageUrlRequired': '站点 URL 不能为空', + 'system.config.baseInfo.pageUrlPlaceholder': '请输入当前站点 URL', + 'system.config.baseInfo.prometheusSub': '例如:{prometheus}', + 'system.config.baseInfo.prometheusRequired': 'prometheus 不能为空', + 'system.config.baseInfo.prometheusPlaceholder': ' 请输入 prometheus', + 'system.config.email.updateTitle': '更新邮件设置', + 'system.config.email.update': '更新', + 'system.config.email.hostRequired': 'SMTP 主机不能为空', + 'system.config.email.hostPlaceholder': '请输入SMTP 主机地址', + 'system.config.email.portRequired': 'SMTP 端口不能为空', + 'system.config.email.portPlaceholder': '请输入SMTP 端口', + 'system.config.email.accountRequired': 'SMTP 账户不能为空', + 'system.config.email.accountPlaceholder': '请输入SMTP 账户', + 'system.config.email.passwordRequired': 'SMTP 密码不能为空', + 'system.config.email.passwordPlaceholder': '请输入SMTP 密码', + 'system.config.email.fromPlaceholder': '请输入指定发件人邮箱', + 'system.config.email.recipientPlaceholder': '请输入测试收件人邮箱', + 'system.config.email.sslTip': '若 SMTP 端口是 465,需要启用 SSL', + 'system.config.email.tslTip': '若 SMTP 端口是 587,需要启用 TSL', + 'system.config.email.emailErrTip': '邮箱格式错误,请重新输入', + 'system.config.email.updateSuccess': '更新成功', + 'system.config.email.testSuccess': '邮箱连接成功', +}; diff --git a/frontend/src/views/setting/system/pluginManager/components/scriptDetailDrawer.vue b/frontend/src/views/setting/system/pluginManager/components/scriptDetailDrawer.vue index 3dde1107ce..464f2ff2b2 100644 --- a/frontend/src/views/setting/system/pluginManager/components/scriptDetailDrawer.vue +++ b/frontend/src/views/setting/system/pluginManager/components/scriptDetailDrawer.vue @@ -1,7 +1,7 @@