From f2edfcf72c8fd826dd0e63e8a71a363cfb97dfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=90=89=E6=98=93?= Date: Wed, 4 Dec 2024 20:51:07 +0800 Subject: [PATCH] Feat env (#80) * style: remove radio reset style * ci: ts ignore * feat: optimize env management --- app/controller/envManagement.js | 9 +- app/model/env_management.js | 2 + app/service/envManagement.js | 15 +- app/web/components/dtCodemirror/index.tsx | 1 + app/web/layouts/header/header.tsx | 3 + app/web/layouts/sider/index.tsx | 2 + app/web/main.tsx | 1 + app/web/pages/configCenter/index.tsx | 1 + app/web/pages/configDetail/index.tsx | 3 + .../components/envModal/index.tsx | 34 +- app/web/pages/envManagement/index.tsx | 52 +- app/web/pages/envManagement/style.scss | 3 +- app/web/pages/proxyServer/index.tsx | 1 + app/web/pages/switchHosts/editHosts/index.tsx | 2 + app/web/pages/toolbox/index.tsx | 1 + app/web/scss/reset.scss | 8 - docs/docsify/imgs/add_env.png | Bin 23148 -> 29970 bytes docs/docsify/imgs/env_management.png | Bin 19873 -> 56266 bytes package.json | 6 +- sql/doraemon.sql | 2 + yarn.lock | 489 +++++++++--------- 21 files changed, 367 insertions(+), 268 deletions(-) diff --git a/app/controller/envManagement.js b/app/controller/envManagement.js index fb02683..1c31b11 100644 --- a/app/controller/envManagement.js +++ b/app/controller/envManagement.js @@ -12,12 +12,14 @@ class EnvManagementController extends Controller { // 新增环境 async addEnv() { const { ctx, app } = this; - const { envName, hostIp, url, remark, tagIds } = ctx.request.body; + const { envName, hostIp, uicUsername, uicPasswd, url, remark, tagIds } = ctx.request.body; if (_.isNil(envName)) throw new Error('缺少必要参数 envName'); if (_.isNil(url)) throw new Error('缺少必要参数 url'); const result = await ctx.service.envManagement.addEnv({ envName, hostIp, + uicUsername, + uicPasswd, url, remark, tags: tagIds.join(','), @@ -32,11 +34,14 @@ class EnvManagementController extends Controller { // 编辑环境 async editEnv() { const { ctx, app } = this; - const { id, envName, hostIp, url, remark, tagIds } = ctx.request.body; + const { id, envName, hostIp, uicUsername, uicPasswd, url, remark, tagIds } = + ctx.request.body; if (_.isNil(id)) throw new Error('缺少必要参数id'); await ctx.service.envManagement.editEnv({ id, envName, + uicUsername, + uicPasswd, hostIp, url, remark, diff --git a/app/model/env_management.js b/app/model/env_management.js index f97bb24..cb23cf6 100644 --- a/app/model/env_management.js +++ b/app/model/env_management.js @@ -6,6 +6,8 @@ module.exports = (app) => { id: { type: INTEGER, primaryKey: true, autoIncrement: true }, envName: { type: STRING(255), field: 'env_name' }, hostIp: { type: STRING(20), field: 'host_ip' }, + uicUsername: { type: STRING(255), field: 'uic_username' }, + uicPasswd: { type: STRING(255), field: 'uic_passwd' }, url: { type: STRING(2048), field: 'url' }, remark: STRING(255), tags: { type: STRING(60), field: 'tag_ids' }, diff --git a/app/service/envManagement.js b/app/service/envManagement.js index cf0a6e8..b38804d 100644 --- a/app/service/envManagement.js +++ b/app/service/envManagement.js @@ -6,7 +6,16 @@ class EnvManagementService extends Service { const { ctx } = this; const { tags = '', search = '' } = params; const envResult = await ctx.model.EnvManagement.findAll({ - attributes: ['id', 'envName', 'hostIp', 'url', 'remark', 'tags'], + attributes: [ + 'id', + 'envName', + 'hostIp', + 'uicUsername', + 'uicPasswd', + 'url', + 'remark', + 'tags', + ], where: { status: 1, $or: [ @@ -43,10 +52,12 @@ class EnvManagementService extends Service { } editEnv(env) { const { ctx } = this; - const { id, envName, hostIp, url, remark, tags } = env; + const { id, envName, hostIp, uicUsername, uicPasswd, url, remark, tags } = env; const newEnv = {}; if (!_.isNil(envName)) newEnv.envName = envName; if (!_.isNil(hostIp)) newEnv.hostIp = hostIp; + if (!_.isNil(uicUsername)) newEnv.uicUsername = uicUsername; + if (!_.isNil(uicPasswd)) newEnv.uicPasswd = uicPasswd; if (!_.isNil(url)) newEnv.url = url; if (!_.isNil(remark)) newEnv.remark = remark; if (!_.isNil(tags)) newEnv.tags = tags; diff --git a/app/web/components/dtCodemirror/index.tsx b/app/web/components/dtCodemirror/index.tsx index ec148e9..d7967b0 100644 --- a/app/web/components/dtCodemirror/index.tsx +++ b/app/web/components/dtCodemirror/index.tsx @@ -91,6 +91,7 @@ function DtCodemirror(props: any) { }, []); return (
+ {/* @ts-ignore */} + { rules={[{ required: true, message: '请输入主机IP' }]} hasFeedback > - + + + + + + + -