From 52a8fce89498efed8d9955bd8c8a52f94136111c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=99=AF=E9=98=B3?= <1656488874@qq.com> Date: Thu, 2 Jan 2020 10:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96UI=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/node.go | 30 +++++++++++++++++-- .../components/InfoView/SpiderInfoView.vue | 6 ++-- frontend/src/views/schedule/ScheduleList.vue | 2 +- frontend/src/views/spider/SpiderList.vue | 11 +++---- frontend/src/views/task/TaskList.vue | 4 +-- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/backend/services/node.go b/backend/services/node.go index d14ce4ae..47d6185a 100644 --- a/backend/services/node.go +++ b/backend/services/node.go @@ -102,7 +102,7 @@ func UpdateNodeStatus() { model.ResetNodeStatusToOffline(list) } -// 处理接到信息 +// 处理节点信息 func handleNodeInfo(key string, data *Data) { // 添加同步锁 v, err := database.RedisClient.Lock(key) @@ -168,8 +168,32 @@ func UpdateNodeData() { return } + // 构造节点数据 + data := Data{ + Key: key, + Mac: mac, + Ip: ip, + Master: model.IsMaster(), + UpdateTs: time.Now(), + UpdateTsUnix: time.Now().Unix(), + } + + // 注册节点到Redis + dataBytes, err := json.Marshal(&data) + if err != nil { + log.Errorf(err.Error()) + debug.PrintStack() + return + } + + if err := database.RedisClient.HSet("nodes", key, utils.BytesToString(dataBytes)); err != nil { + log.Errorf(err.Error()) + return + } + + // 注释掉,无需这样处理。 直接覆盖key对应的节点信息即可 by xyz 2020.01.01 //先获取所有Redis的nodekey - list, _ := database.RedisClient.HKeys("nodes") + /*list, _ := database.RedisClient.HKeys("nodes") if i := utils.Contains(list, key); i == false { // 构造节点数据 @@ -193,7 +217,7 @@ func UpdateNodeData() { log.Errorf(err.Error()) return } - } + }*/ } diff --git a/frontend/src/components/InfoView/SpiderInfoView.vue b/frontend/src/components/InfoView/SpiderInfoView.vue index a13b4c7a..df3864e1 100644 --- a/frontend/src/components/InfoView/SpiderInfoView.vue +++ b/frontend/src/components/InfoView/SpiderInfoView.vue @@ -61,15 +61,15 @@ :file-list="fileList" style="display:inline-block;margin-right:10px" > - + {{$t('Upload')}} - {{$t('Run')}} - {{$t('Save')}} diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue index 23d9fa97..0d1ff0b5 100644 --- a/frontend/src/views/schedule/ScheduleList.vue +++ b/frontend/src/views/schedule/ScheduleList.vue @@ -143,7 +143,7 @@ - + diff --git a/frontend/src/views/spider/SpiderList.vue b/frontend/src/views/spider/SpiderList.vue index 80c3fa0b..18620944 100644 --- a/frontend/src/views/spider/SpiderList.vue +++ b/frontend/src/views/spider/SpiderList.vue @@ -34,6 +34,7 @@ :visible.sync="addDialogVisible" :before-close="onAddDialogClose"> + @@ -55,8 +56,7 @@ :headers="{Authorization:token}" :on-success="onUploadSuccess" :file-list="fileList"> - + {{$t('Upload')}} @@ -75,9 +75,10 @@

- {{$t('Add')}} + {{$t('Add')}}
+ @@ -101,7 +102,7 @@
- {{$t('Add')}} + {{$t('Add')}}
@@ -146,7 +147,7 @@ {{$t('Import Spiders')}}
- + @@ -125,7 +125,7 @@ :width="col.width"> - +