seeder-st2110-components 1.4.4 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +31 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, useState, useCallback,
|
|
1
|
+
import { memo, useState, useCallback, useMemo, useEffect, useRef } from 'react';
|
|
2
2
|
import { Tooltip, Space, Flex, Divider, App, Modal, Form, Input, Alert, message, Dropdown, Spin, InputNumber, ConfigProvider, Badge, Switch, Select, Typography, List, Empty, Button, Checkbox, Row, Col } from 'antd';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useWebSocket, useInterval } from 'ahooks';
|
|
@@ -97,7 +97,7 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
|
97
97
|
children: /*#__PURE__*/jsxs(Space, {
|
|
98
98
|
size: 4,
|
|
99
99
|
children: [/*#__PURE__*/jsx("i", {
|
|
100
|
-
className: "iconfont ".concat(iconClass, " text-xl")
|
|
100
|
+
className: "seeder-iconfont ".concat(iconClass, " text-xl")
|
|
101
101
|
}), /*#__PURE__*/jsx("span", {
|
|
102
102
|
className: "inline-block w-10 text-center",
|
|
103
103
|
children: children
|
|
@@ -108,42 +108,44 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
|
108
108
|
var UsageItem$1 = UsageItem;
|
|
109
109
|
|
|
110
110
|
const useHardwareWebSocket = socketUrl => {
|
|
111
|
-
// cpu_percent cpu使用率
|
|
112
|
-
// cpu_freq.current cpu频率
|
|
113
|
-
// mem.percent 内存使用率
|
|
114
|
-
// sensors_temperatures.coretemp[0].current cpu温度
|
|
115
|
-
// gpu_stats[0]["utilization.gpu"] gpu使用率
|
|
116
|
-
// 若机器没有显卡,gpu_stats数组为空
|
|
117
|
-
|
|
118
111
|
const [systemStatus, setSystemStatus] = useState();
|
|
119
|
-
|
|
120
|
-
// ## 获取系统资源使用情况
|
|
121
|
-
const {
|
|
122
|
-
latestMessage
|
|
123
|
-
} = useWebSocket(socketUrl);
|
|
124
112
|
const handleMessage = useCallback(message => {
|
|
125
113
|
try {
|
|
126
114
|
if (message) {
|
|
127
|
-
setSystemStatus(prev => _objectSpread2(_objectSpread2(
|
|
128
|
-
lastUpdated: Date.now() // 添加更新时间戳
|
|
129
|
-
}));
|
|
115
|
+
setSystemStatus(prev => _objectSpread2(_objectSpread2({}, prev), message));
|
|
130
116
|
}
|
|
131
117
|
} catch (error) {
|
|
132
118
|
console.error('Message processing error:', error);
|
|
133
119
|
}
|
|
134
120
|
}, []);
|
|
135
121
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
122
|
+
// ## 获取系统资源使用情况
|
|
123
|
+
useWebSocket(socketUrl, {
|
|
124
|
+
onMessage: event => {
|
|
125
|
+
// 处理实时消息
|
|
126
|
+
try {
|
|
127
|
+
const parsedMessage = JSON.parse(event.data);
|
|
128
|
+
handleMessage(parsedMessage);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error('Message parsing error:', error);
|
|
131
|
+
console.debug('Raw message:', event.data);
|
|
132
|
+
}
|
|
145
133
|
}
|
|
146
|
-
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// // 监听消息 latestMessage 只用于非实时需求
|
|
137
|
+
// useEffect(() => {
|
|
138
|
+
// if (!latestMessage?.data) return;
|
|
139
|
+
|
|
140
|
+
// try {
|
|
141
|
+
// const parsedMessage = JSON.parse(latestMessage.data);
|
|
142
|
+
// handleMessage(parsedMessage);
|
|
143
|
+
// } catch (error) {
|
|
144
|
+
// console.error('Message parsing error:', error);
|
|
145
|
+
// console.debug('Raw message:', latestMessage.data);
|
|
146
|
+
// }
|
|
147
|
+
// }, [latestMessage?.data, handleMessage]);
|
|
148
|
+
|
|
147
149
|
return {
|
|
148
150
|
ps_status: systemStatus
|
|
149
151
|
};
|
|
@@ -708,7 +710,7 @@ const useUpgrade = _ref => {
|
|
|
708
710
|
children: /*#__PURE__*/jsx("a", {
|
|
709
711
|
onClick: e => e.preventDefault(),
|
|
710
712
|
children: /*#__PURE__*/jsx("i", {
|
|
711
|
-
className: "iconfont seeder-icon-liebiao2 text-2xl text-neutral-400"
|
|
713
|
+
className: "seeder-iconfont seeder-icon-liebiao2 text-2xl text-neutral-400"
|
|
712
714
|
})
|
|
713
715
|
})
|
|
714
716
|
}), /*#__PURE__*/jsx("input", {
|
|
@@ -2034,7 +2036,7 @@ const SystemOperations = _ref => {
|
|
|
2034
2036
|
onRestart,
|
|
2035
2037
|
powerOffLabel = "Power Off",
|
|
2036
2038
|
restartLabel = "Restart",
|
|
2037
|
-
iconClassName = "iconfont seeder-icon-guanji1 text-2xl text-neutral-400",
|
|
2039
|
+
iconClassName = "seeder-iconfont seeder-icon-guanji1 text-2xl text-neutral-400",
|
|
2038
2040
|
confirmTitle = "Confirm",
|
|
2039
2041
|
cancelText = "No",
|
|
2040
2042
|
okText = "Yes",
|