From b1a6b37ee0073b12c145a46dab61dd025cb51996 Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 23 Aug 2025 22:44:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=A1=A8=E7=BB=93=E6=9E=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/system/Host.php | 13 ++++ app/admin/model/SystemHost.php | 9 +++ .../base/admin/controller/system/HostBase.php | 24 ++++++ extend/base/admin/model/SystemHostBase.php | 28 +++++++ extend/base/admin/view/system/host/_common.js | 10 +++ extend/base/admin/view/system/host/add.html | 77 +++++++++++++++++++ extend/base/admin/view/system/host/add.js | 3 + extend/base/admin/view/system/host/edit.html | 77 +++++++++++++++++++ extend/base/admin/view/system/host/edit.js | 3 + extend/base/admin/view/system/host/index.html | 13 ++++ extend/base/admin/view/system/host/index.js | 10 +++ .../base/common/service/HostServiceBase.php | 30 ++++---- 12 files changed, 282 insertions(+), 15 deletions(-) create mode 100644 app/admin/controller/system/Host.php create mode 100644 app/admin/model/SystemHost.php create mode 100644 extend/base/admin/controller/system/HostBase.php create mode 100644 extend/base/admin/model/SystemHostBase.php create mode 100644 extend/base/admin/view/system/host/_common.js create mode 100644 extend/base/admin/view/system/host/add.html create mode 100644 extend/base/admin/view/system/host/add.js create mode 100644 extend/base/admin/view/system/host/edit.html create mode 100644 extend/base/admin/view/system/host/edit.js create mode 100644 extend/base/admin/view/system/host/index.html create mode 100644 extend/base/admin/view/system/host/index.js diff --git a/app/admin/controller/system/Host.php b/app/admin/controller/system/Host.php new file mode 100644 index 0000000..33fcf47 --- /dev/null +++ b/app/admin/controller/system/Host.php @@ -0,0 +1,13 @@ +model = new \app\admin\model\SystemHost(); + + $this->assign('select_list_status', $this->model::SELECT_LIST_STATUS, true); + } +} diff --git a/extend/base/admin/model/SystemHostBase.php b/extend/base/admin/model/SystemHostBase.php new file mode 100644 index 0000000..4cc7a36 --- /dev/null +++ b/extend/base/admin/model/SystemHostBase.php @@ -0,0 +1,28 @@ + '离线', '1' => '在线']; +} diff --git a/extend/base/admin/view/system/host/_common.js b/extend/base/admin/view/system/host/_common.js new file mode 100644 index 0000000..ad6eb5d --- /dev/null +++ b/extend/base/admin/view/system/host/_common.js @@ -0,0 +1,10 @@ +var init = { + tableElem: '#currentTable', + tableRenderId: 'currentTableRenderId', + indexUrl: 'system.host/index', + addUrl: 'system.host/add' + location.search, + editUrl: 'system.host/edit', + deleteUrl: 'system.host/delete', + exportUrl: 'system.host/export', + modifyUrl: 'system.host/modify', +}; \ No newline at end of file diff --git a/extend/base/admin/view/system/host/add.html b/extend/base/admin/view/system/host/add.html new file mode 100644 index 0000000..3264b44 --- /dev/null +++ b/extend/base/admin/view/system/host/add.html @@ -0,0 +1,77 @@ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {foreach $select_list_status as $k=>$v} + + {/foreach} +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ {notempty name='$Request.param.backTagId'} +
返回
+ {/notempty} + + +
+ +
+
\ No newline at end of file diff --git a/extend/base/admin/view/system/host/add.js b/extend/base/admin/view/system/host/add.js new file mode 100644 index 0000000..4a445e0 --- /dev/null +++ b/extend/base/admin/view/system/host/add.js @@ -0,0 +1,3 @@ +$(function(){ + ua.listen(); +}) \ No newline at end of file diff --git a/extend/base/admin/view/system/host/edit.html b/extend/base/admin/view/system/host/edit.html new file mode 100644 index 0000000..1d59661 --- /dev/null +++ b/extend/base/admin/view/system/host/edit.html @@ -0,0 +1,77 @@ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {foreach $select_list_status as $k=>$v} + + {/foreach} +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ {notempty name='$Request.param.backTagId'} +
返回
+ {/notempty} + + +
+ +
+
\ No newline at end of file diff --git a/extend/base/admin/view/system/host/edit.js b/extend/base/admin/view/system/host/edit.js new file mode 100644 index 0000000..4a445e0 --- /dev/null +++ b/extend/base/admin/view/system/host/edit.js @@ -0,0 +1,3 @@ +$(function(){ + ua.listen(); +}) \ No newline at end of file diff --git a/extend/base/admin/view/system/host/index.html b/extend/base/admin/view/system/host/index.html new file mode 100644 index 0000000..083bdc6 --- /dev/null +++ b/extend/base/admin/view/system/host/index.html @@ -0,0 +1,13 @@ +
+
+ +
+
+
\ No newline at end of file diff --git a/extend/base/admin/view/system/host/index.js b/extend/base/admin/view/system/host/index.js new file mode 100644 index 0000000..21b3c53 --- /dev/null +++ b/extend/base/admin/view/system/host/index.js @@ -0,0 +1,10 @@ +$(function(){ + ua.table.render({ + init: init, + cols: [[ + {type: 'checkbox'}, {field: 'id', title: 'ID'}, {field: 'node_id', title: '节点ID'}, {field: 'ip_address', title: 'IP地址'}, {field: 'status', search: 'select', selectList: ua.getDataBrage('select_list_status'), title: '状态', templet: ua.table.switch}, {field: 'last_heartbeat_at', title: '最后心跳时间'}, {field: 'os_info', title: '系统信息'}, {field: 'php_version', title: 'PHP版本'}, {field: 'cpu_load', title: 'CPU负载'}, {field: 'memory_usage', title: '内存占用'}, {field: 'disk_free', title: '磁盘可用空间'}, {field: 'disk_total', title: '磁盘总空间'}, {field: 'create_time', title: '首次运行时间'}, {width: 250, title: '操作', templet: ua.table.tool , fixed:'right'}, + ]], + }); + + ua.listen(); +}) \ No newline at end of file diff --git a/extend/base/common/service/HostServiceBase.php b/extend/base/common/service/HostServiceBase.php index 9bf4fd9..9215705 100644 --- a/extend/base/common/service/HostServiceBase.php +++ b/extend/base/common/service/HostServiceBase.php @@ -1,4 +1,3 @@ - round($l, 2), $load)) : null; + $cpuLoad = is_array($load) ? implode(',', array_map(fn ($l) => round($l, 2), $load)) : null; } return [ - 'status' => 1, - 'last_heartbeat_at' => date('Y-m-d H:i:s'), - 'ip_address' => gethostbyname(gethostname()), - 'cpu_load' => $cpuLoad, - 'memory_usage' => memory_get_usage(), // false: 获取脚本自身内存占用 - 'disk_free' => disk_free_space(App::getRootPath()), - 'disk_total' => disk_total_space(App::getRootPath()), + 'status' => 1, + 'last_heartbeat_at' => date('Y-m-d H:i:s'), + 'ip_address' => gethostbyname(gethostname()), + 'cpu_load' => $cpuLoad, + 'memory_usage' => memory_get_usage(), // false: 获取脚本自身内存占用 + 'disk_free' => disk_free_space(App::getRootPath()), + 'disk_total' => disk_total_space(App::getRootPath()), ]; } /** - * 收集主机的静态信息 (仅在首次注册时调用) + * 收集主机的静态信息 (仅在首次注册时调用). * @return array */ public static function collectStaticInfo(): array { return [ - 'os_info' => php_uname(), - 'php_version' => PHP_VERSION, + 'os_info' => php_uname(), + 'php_version' => PHP_VERSION, ]; } }