seeder-st2110-components 1.3.5 → 1.3.7
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 +259 -758
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +255 -756
- package/dist/index.js.map +1 -1
- package/package.json +1 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,112 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect,
|
|
2
|
-
import {
|
|
3
|
-
import { Tooltip, Space, Flex, Divider, App, Modal, Form, Input, Alert, message, Dropdown, Spin, Popover, Button, Popconfirm, Typography, Empty, ConfigProvider, Tree, InputNumber, Badge, Switch, Select, List, Checkbox, Row, Col } from 'antd';
|
|
1
|
+
import { memo, useState, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
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';
|
|
4
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
4
|
+
import { useWebSocket, useInterval } from 'ahooks';
|
|
5
|
+
import { LoadingOutlined, ExclamationCircleFilled, PlusOutlined } from '@ant-design/icons';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|
|
8
|
+
function _defineProperty(e, r, t) {
|
|
9
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
10
|
+
value: t,
|
|
11
|
+
enumerable: !0,
|
|
12
|
+
configurable: !0,
|
|
13
|
+
writable: !0
|
|
14
|
+
}) : e[r] = t, e;
|
|
15
|
+
}
|
|
16
|
+
function ownKeys(e, r) {
|
|
17
|
+
var t = Object.keys(e);
|
|
18
|
+
if (Object.getOwnPropertySymbols) {
|
|
19
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
20
|
+
r && (o = o.filter(function (r) {
|
|
21
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
22
|
+
})), t.push.apply(t, o);
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}
|
|
26
|
+
function _objectSpread2(e) {
|
|
27
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
28
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
29
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
30
|
+
_defineProperty(e, r, t[r]);
|
|
31
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
32
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return e;
|
|
36
|
+
}
|
|
37
|
+
function _objectWithoutProperties(e, t) {
|
|
38
|
+
if (null == e) return {};
|
|
39
|
+
var o,
|
|
40
|
+
r,
|
|
41
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
42
|
+
if (Object.getOwnPropertySymbols) {
|
|
43
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
44
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
45
|
+
}
|
|
46
|
+
return i;
|
|
47
|
+
}
|
|
48
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
49
|
+
if (null == r) return {};
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
52
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
53
|
+
t[n] = r[n];
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
function _toPrimitive(t, r) {
|
|
58
|
+
if ("object" != typeof t || !t) return t;
|
|
59
|
+
var e = t[Symbol.toPrimitive];
|
|
60
|
+
if (void 0 !== e) {
|
|
61
|
+
var i = e.call(t, r || "default");
|
|
62
|
+
if ("object" != typeof i) return i;
|
|
63
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
64
|
+
}
|
|
65
|
+
return ("string" === r ? String : Number)(t);
|
|
66
|
+
}
|
|
67
|
+
function _toPropertyKey(t) {
|
|
68
|
+
var i = _toPrimitive(t, "string");
|
|
69
|
+
return "symbol" == typeof i ? i : i + "";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const formatBytes = function (bytes) {
|
|
73
|
+
let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
74
|
+
if (bytes === 0 || !bytes || bytes < 0) return '0 Bytes';
|
|
75
|
+
const k = 1024;
|
|
76
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
77
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
78
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
79
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
80
|
+
};
|
|
81
|
+
const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
82
|
+
let {
|
|
83
|
+
title,
|
|
84
|
+
iconClass,
|
|
85
|
+
children,
|
|
86
|
+
memTotal
|
|
87
|
+
} = _ref;
|
|
88
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
89
|
+
title: /*#__PURE__*/jsxs(Fragment, {
|
|
90
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
91
|
+
children: title
|
|
92
|
+
}), title === 'Memory Usage' && memTotal !== undefined && /*#__PURE__*/jsxs("div", {
|
|
93
|
+
children: ["Total Memory: ", formatBytes(memTotal)]
|
|
94
|
+
})]
|
|
95
|
+
}),
|
|
96
|
+
destroyOnHidden: false,
|
|
97
|
+
children: /*#__PURE__*/jsxs(Space, {
|
|
98
|
+
size: 4,
|
|
99
|
+
children: [/*#__PURE__*/jsx("i", {
|
|
100
|
+
className: "iconfont ".concat(iconClass, " text-xl")
|
|
101
|
+
}), /*#__PURE__*/jsx("span", {
|
|
102
|
+
className: "inline-block w-10 text-center",
|
|
103
|
+
children: children
|
|
104
|
+
})]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
var UsageItem$1 = UsageItem;
|
|
109
|
+
|
|
8
110
|
const useHardwareWebSocket = socketUrl => {
|
|
9
111
|
// cpu_percent cpu使用率
|
|
10
112
|
// cpu_freq.current cpu频率
|
|
@@ -22,9 +124,7 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
22
124
|
const handleMessage = useCallback(message => {
|
|
23
125
|
try {
|
|
24
126
|
if (message) {
|
|
25
|
-
setSystemStatus(prev => ({
|
|
26
|
-
...prev,
|
|
27
|
-
...message,
|
|
127
|
+
setSystemStatus(prev => _objectSpread2(_objectSpread2(_objectSpread2({}, prev), message), {}, {
|
|
28
128
|
lastUpdated: Date.now() // 添加更新时间戳
|
|
29
129
|
}));
|
|
30
130
|
}
|
|
@@ -35,7 +135,7 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
35
135
|
|
|
36
136
|
// 监听消息 如果latestMessage变化,说明有新消息
|
|
37
137
|
useEffect(() => {
|
|
38
|
-
if (!latestMessage
|
|
138
|
+
if (!(latestMessage !== null && latestMessage !== void 0 && latestMessage.data)) return;
|
|
39
139
|
try {
|
|
40
140
|
const parsedMessage = JSON.parse(latestMessage.data);
|
|
41
141
|
handleMessage(parsedMessage);
|
|
@@ -43,54 +143,19 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
43
143
|
console.error('Message parsing error:', error);
|
|
44
144
|
console.debug('Raw message:', latestMessage.data);
|
|
45
145
|
}
|
|
46
|
-
}, [latestMessage
|
|
146
|
+
}, [latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.data, handleMessage]);
|
|
47
147
|
return {
|
|
48
148
|
ps_status: systemStatus
|
|
49
149
|
};
|
|
50
150
|
};
|
|
51
151
|
var useHardwareWebSocket$1 = useHardwareWebSocket;
|
|
52
152
|
|
|
53
|
-
const formatBytes = function (bytes) {
|
|
54
|
-
let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
55
|
-
if (bytes === 0 || !bytes || bytes < 0) return '0 Bytes';
|
|
56
|
-
const k = 1024;
|
|
57
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
58
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
59
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
60
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
61
|
-
};
|
|
62
|
-
const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
63
|
-
let {
|
|
64
|
-
title,
|
|
65
|
-
iconClass,
|
|
66
|
-
children,
|
|
67
|
-
memTotal
|
|
68
|
-
} = _ref;
|
|
69
|
-
return /*#__PURE__*/jsx(Tooltip, {
|
|
70
|
-
title: /*#__PURE__*/jsxs(Fragment, {
|
|
71
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
72
|
-
children: title
|
|
73
|
-
}), title === 'Memory Usage' && memTotal !== undefined && /*#__PURE__*/jsxs("div", {
|
|
74
|
-
children: ["Total Memory: ", formatBytes(memTotal)]
|
|
75
|
-
})]
|
|
76
|
-
}),
|
|
77
|
-
destroyOnHidden: false,
|
|
78
|
-
children: /*#__PURE__*/jsxs(Space, {
|
|
79
|
-
size: 4,
|
|
80
|
-
children: [/*#__PURE__*/jsx("i", {
|
|
81
|
-
className: `iconfont ${iconClass} text-xl`
|
|
82
|
-
}), /*#__PURE__*/jsx("span", {
|
|
83
|
-
className: "inline-block w-10 text-center",
|
|
84
|
-
children: children
|
|
85
|
-
})]
|
|
86
|
-
})
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
var UsageItem$1 = UsageItem;
|
|
90
|
-
|
|
91
153
|
const getMaxNicTemp = function (sensors) {
|
|
92
154
|
let priorityFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ["i350bb", "r8169_0_8300:00"];
|
|
93
|
-
const temps = priorityFields.flatMap(field =>
|
|
155
|
+
const temps = priorityFields.flatMap(field => {
|
|
156
|
+
var _sensors$field;
|
|
157
|
+
return (sensors === null || sensors === void 0 || (_sensors$field = sensors[field]) === null || _sensors$field === void 0 ? void 0 : _sensors$field.map(item => item.current)) || [];
|
|
158
|
+
}).filter(temp => typeof temp === 'number');
|
|
94
159
|
return temps.length ? Math.max(...temps) : null;
|
|
95
160
|
};
|
|
96
161
|
|
|
@@ -100,6 +165,7 @@ const getMaxSensorTemp = sensorData => {
|
|
|
100
165
|
return temps.length ? Math.max(...temps) : null;
|
|
101
166
|
};
|
|
102
167
|
const getDetail = function () {
|
|
168
|
+
var _sensors_temperatures, _sensors_temperatures2, _mem$total, _mem$percent, _getMaxNicTemp, _gpu_stats$0$utilizat, _gpu_stats$, _gpu_stats$0$temperat, _gpu_stats$2;
|
|
103
169
|
let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
104
170
|
const {
|
|
105
171
|
cpu_percent,
|
|
@@ -108,15 +174,15 @@ const getDetail = function () {
|
|
|
108
174
|
gpu_stats
|
|
109
175
|
} = status;
|
|
110
176
|
return {
|
|
111
|
-
cpu_usage: cpu_percent
|
|
112
|
-
cpu_temp: sensors_temperatures
|
|
113
|
-
mem_total: mem
|
|
114
|
-
mem_usage: mem
|
|
115
|
-
mem_temp: getMaxSensorTemp(sensors_temperatures
|
|
116
|
-
nic_temp: getMaxNicTemp(sensors_temperatures)
|
|
117
|
-
hd_temp: getMaxSensorTemp(sensors_temperatures
|
|
118
|
-
gpu_usage: gpu_stats
|
|
119
|
-
gpu_temp: gpu_stats
|
|
177
|
+
cpu_usage: cpu_percent !== null && cpu_percent !== void 0 ? cpu_percent : null,
|
|
178
|
+
cpu_temp: (_sensors_temperatures = sensors_temperatures === null || sensors_temperatures === void 0 || (_sensors_temperatures2 = sensors_temperatures.coretemp) === null || _sensors_temperatures2 === void 0 || (_sensors_temperatures2 = _sensors_temperatures2[0]) === null || _sensors_temperatures2 === void 0 ? void 0 : _sensors_temperatures2.current) !== null && _sensors_temperatures !== void 0 ? _sensors_temperatures : null,
|
|
179
|
+
mem_total: (_mem$total = mem === null || mem === void 0 ? void 0 : mem.total) !== null && _mem$total !== void 0 ? _mem$total : null,
|
|
180
|
+
mem_usage: (_mem$percent = mem === null || mem === void 0 ? void 0 : mem.percent) !== null && _mem$percent !== void 0 ? _mem$percent : null,
|
|
181
|
+
mem_temp: getMaxSensorTemp(sensors_temperatures === null || sensors_temperatures === void 0 ? void 0 : sensors_temperatures.spd5118),
|
|
182
|
+
nic_temp: (_getMaxNicTemp = getMaxNicTemp(sensors_temperatures)) !== null && _getMaxNicTemp !== void 0 ? _getMaxNicTemp : null,
|
|
183
|
+
hd_temp: getMaxSensorTemp(sensors_temperatures === null || sensors_temperatures === void 0 ? void 0 : sensors_temperatures.nvme),
|
|
184
|
+
gpu_usage: (_gpu_stats$0$utilizat = gpu_stats === null || gpu_stats === void 0 || (_gpu_stats$ = gpu_stats[0]) === null || _gpu_stats$ === void 0 ? void 0 : _gpu_stats$["utilization.gpu"]) !== null && _gpu_stats$0$utilizat !== void 0 ? _gpu_stats$0$utilizat : null,
|
|
185
|
+
gpu_temp: (_gpu_stats$0$temperat = gpu_stats === null || gpu_stats === void 0 || (_gpu_stats$2 = gpu_stats[0]) === null || _gpu_stats$2 === void 0 ? void 0 : _gpu_stats$2["temperature.gpu"]) !== null && _gpu_stats$0$temperat !== void 0 ? _gpu_stats$0$temperat : null
|
|
120
186
|
};
|
|
121
187
|
};
|
|
122
188
|
|
|
@@ -126,7 +192,7 @@ const createMetricItem = (title, iconClass, value, unit) => {
|
|
|
126
192
|
return {
|
|
127
193
|
title,
|
|
128
194
|
iconClass,
|
|
129
|
-
valueString:
|
|
195
|
+
valueString: "".concat(numValue).concat(unit),
|
|
130
196
|
value: numValue
|
|
131
197
|
};
|
|
132
198
|
};
|
|
@@ -139,10 +205,9 @@ const getItems = details => {
|
|
|
139
205
|
items.push(createMetricItem('CPU Temperature', 'icon-CPUwendu', details.cpu_temp, '℃'));
|
|
140
206
|
}
|
|
141
207
|
if (details.mem_usage !== null && details.mem_usage !== undefined) {
|
|
142
|
-
items.push({
|
|
143
|
-
...createMetricItem('Memory Usage', 'icon-shiyongshuai', details.mem_usage, '%'),
|
|
208
|
+
items.push(_objectSpread2(_objectSpread2({}, createMetricItem('Memory Usage', 'icon-shiyongshuai', details.mem_usage, '%')), {}, {
|
|
144
209
|
memTotal: details.mem_total
|
|
145
|
-
});
|
|
210
|
+
}));
|
|
146
211
|
}
|
|
147
212
|
if (details.mem_temp !== null && details.mem_temp !== undefined) {
|
|
148
213
|
items.push(createMetricItem('Memory Temperature', 'icon-wendu', details.mem_temp, '℃'));
|
|
@@ -161,7 +226,10 @@ const getItems = details => {
|
|
|
161
226
|
}
|
|
162
227
|
return items;
|
|
163
228
|
};
|
|
164
|
-
const useHardwareUsage =
|
|
229
|
+
const useHardwareUsage = socketUrl => {
|
|
230
|
+
const {
|
|
231
|
+
ps_status
|
|
232
|
+
} = useHardwareWebSocket$1(socketUrl);
|
|
165
233
|
return useMemo(() => {
|
|
166
234
|
if (!ps_status || typeof ps_status !== 'object') return null;
|
|
167
235
|
const statusItems = getItems(getDetail(ps_status));
|
|
@@ -212,7 +280,7 @@ const AuthorizationModal = _ref => {
|
|
|
212
280
|
onOk(trimmedCode);
|
|
213
281
|
};
|
|
214
282
|
const statusAlert = isActivated ? /*#__PURE__*/jsx(Alert, {
|
|
215
|
-
message:
|
|
283
|
+
message: "".concat(statusMessage, ", will expire on ").concat(expiresTime),
|
|
216
284
|
type: "success",
|
|
217
285
|
showIcon: true
|
|
218
286
|
}) : /*#__PURE__*/jsx(Alert, {
|
|
@@ -301,7 +369,7 @@ const useAuth = options => {
|
|
|
301
369
|
try {
|
|
302
370
|
setLoading(true);
|
|
303
371
|
const result = await fetchAuthInfo();
|
|
304
|
-
if (result
|
|
372
|
+
if (result !== null && result !== void 0 && result.commands) {
|
|
305
373
|
const commands = result.commands;
|
|
306
374
|
setAuthData(commands);
|
|
307
375
|
setIsRegistered(commands.accredit_status);
|
|
@@ -327,10 +395,10 @@ const useAuth = options => {
|
|
|
327
395
|
license_data: code
|
|
328
396
|
}
|
|
329
397
|
});
|
|
330
|
-
if (result
|
|
398
|
+
if (result !== null && result !== void 0 && result.commands) {
|
|
331
399
|
const commands = result.commands;
|
|
332
400
|
// type accredit_message
|
|
333
|
-
if (commands
|
|
401
|
+
if (commands !== null && commands !== void 0 && commands.accredit_status) {
|
|
334
402
|
setIsRegistered(true);
|
|
335
403
|
setAuthData(commands);
|
|
336
404
|
closeModal();
|
|
@@ -457,7 +525,7 @@ const useUpgrade = _ref => {
|
|
|
457
525
|
if (onMenuClick) {
|
|
458
526
|
onMenuClick(key);
|
|
459
527
|
} else {
|
|
460
|
-
console.warn(
|
|
528
|
+
console.warn("Unknown menu key: ".concat(key, " and no onMenuClick provided"));
|
|
461
529
|
}
|
|
462
530
|
}
|
|
463
531
|
};
|
|
@@ -470,7 +538,7 @@ const useUpgrade = _ref => {
|
|
|
470
538
|
try {
|
|
471
539
|
const res = await downloadFiles();
|
|
472
540
|
if (res.status !== 200) {
|
|
473
|
-
throw new Error(
|
|
541
|
+
throw new Error("Unexpected status code: ".concat(res.status));
|
|
474
542
|
}
|
|
475
543
|
|
|
476
544
|
// 默认值,兼容接口响应头没有定义文件名
|
|
@@ -480,7 +548,7 @@ const useUpgrade = _ref => {
|
|
|
480
548
|
// 获取接口响应的content-disposition字段值,以便获取到文件名
|
|
481
549
|
if (contentDisposition) {
|
|
482
550
|
const filenameMatch = contentDisposition.match(/filename\s*=\s*"?([^";]+)"?/i);
|
|
483
|
-
if (filenameMatch
|
|
551
|
+
if (filenameMatch !== null && filenameMatch !== void 0 && filenameMatch[1]) {
|
|
484
552
|
fileName = decodeURIComponent(filenameMatch[1]); // 处理编码后的文件名(如 %20 转空格)
|
|
485
553
|
}
|
|
486
554
|
}
|
|
@@ -509,7 +577,7 @@ const useUpgrade = _ref => {
|
|
|
509
577
|
}
|
|
510
578
|
};
|
|
511
579
|
const onUpload = () => {
|
|
512
|
-
if (inputRef
|
|
580
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
513
581
|
inputRef.current.click();
|
|
514
582
|
}
|
|
515
583
|
};
|
|
@@ -520,7 +588,8 @@ const useUpgrade = _ref => {
|
|
|
520
588
|
return;
|
|
521
589
|
}
|
|
522
590
|
try {
|
|
523
|
-
|
|
591
|
+
var _event$target$files;
|
|
592
|
+
const file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
|
|
524
593
|
if (!file) return;
|
|
525
594
|
showLoader();
|
|
526
595
|
setCurrentStatus('Uploading...');
|
|
@@ -568,7 +637,7 @@ const useUpgrade = _ref => {
|
|
|
568
637
|
const response = await upgradeStatus({
|
|
569
638
|
cancelToken: statusCancelToken.current.token
|
|
570
639
|
});
|
|
571
|
-
if (response
|
|
640
|
+
if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
|
|
572
641
|
const {
|
|
573
642
|
code,
|
|
574
643
|
message: statusMessage
|
|
@@ -656,7 +725,7 @@ const useUpgrade = _ref => {
|
|
|
656
725
|
},
|
|
657
726
|
spin: true
|
|
658
727
|
}),
|
|
659
|
-
tip: currentStatus === "Uploading..." ?
|
|
728
|
+
tip: currentStatus === "Uploading..." ? "".concat(currentStatus, " ").concat(uploadProgress, "%") : currentStatus,
|
|
660
729
|
size: "large",
|
|
661
730
|
fullscreen: true
|
|
662
731
|
})]
|
|
@@ -681,7 +750,7 @@ const useSystemOperations = function () {
|
|
|
681
750
|
try {
|
|
682
751
|
AntdModal.confirm({
|
|
683
752
|
icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
|
|
684
|
-
title:
|
|
753
|
+
title: "".concat(confirmTitle, " ").concat(action, "?"),
|
|
685
754
|
cancelText,
|
|
686
755
|
okText,
|
|
687
756
|
onOk: () => {
|
|
@@ -698,7 +767,7 @@ const useSystemOperations = function () {
|
|
|
698
767
|
}
|
|
699
768
|
});
|
|
700
769
|
} catch (error) {
|
|
701
|
-
console.error(
|
|
770
|
+
console.error("".concat(action.toUpperCase(), " ERROR: "), error);
|
|
702
771
|
}
|
|
703
772
|
}, [AntdModal, confirmTitle, cancelText, okText, onPowerOff, onRestart]);
|
|
704
773
|
const getMenuItems = useCallback(() => [{
|
|
@@ -721,566 +790,20 @@ const useSystemOperations = function () {
|
|
|
721
790
|
};
|
|
722
791
|
var useSystemOperations$1 = useSystemOperations;
|
|
723
792
|
|
|
724
|
-
const
|
|
725
|
-
let {
|
|
726
|
-
onClose,
|
|
727
|
-
onConfirm
|
|
728
|
-
} = _ref;
|
|
729
|
-
const [value, setValue] = useState('');
|
|
730
|
-
const handleConfirm = useCallback(() => {
|
|
731
|
-
onConfirm(value, () => setValue(''));
|
|
732
|
-
}, [confirm, value]);
|
|
733
|
-
const handleKeyDown = useCallback(e => {
|
|
734
|
-
if (e.key === 'Enter') {
|
|
735
|
-
handleConfirm();
|
|
736
|
-
}
|
|
737
|
-
}, [handleConfirm]);
|
|
738
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
739
|
-
children: [/*#__PURE__*/jsx(Form.Item, {
|
|
740
|
-
label: "Folder Name",
|
|
741
|
-
style: {
|
|
742
|
-
marginBottom: 8
|
|
743
|
-
},
|
|
744
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
745
|
-
ref: ref,
|
|
746
|
-
value: value,
|
|
747
|
-
onChange: e => setValue(e.target.value),
|
|
748
|
-
onKeyDown: handleKeyDown,
|
|
749
|
-
size: "small",
|
|
750
|
-
style: {
|
|
751
|
-
width: 120
|
|
752
|
-
},
|
|
753
|
-
autoFocus: true
|
|
754
|
-
})
|
|
755
|
-
}), /*#__PURE__*/jsxs(Flex, {
|
|
756
|
-
justify: "flex-end",
|
|
757
|
-
gap: "small",
|
|
758
|
-
children: [/*#__PURE__*/jsx(Button, {
|
|
759
|
-
type: "default",
|
|
760
|
-
size: "small",
|
|
761
|
-
onClick: onClose,
|
|
762
|
-
children: "Close"
|
|
763
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
764
|
-
type: "primary",
|
|
765
|
-
size: "small",
|
|
766
|
-
onClick: handleConfirm,
|
|
767
|
-
children: "OK"
|
|
768
|
-
})]
|
|
769
|
-
})]
|
|
770
|
-
});
|
|
771
|
-
});
|
|
772
|
-
const EditablePopover = _ref2 => {
|
|
773
|
-
let {
|
|
774
|
-
children,
|
|
775
|
-
add
|
|
776
|
-
} = _ref2;
|
|
777
|
-
const inputRef = useRef(null);
|
|
778
|
-
const [open, setOpen] = useState(false);
|
|
779
|
-
useEffect(() => {
|
|
780
|
-
if (open && inputRef.current) {
|
|
781
|
-
const timer = setTimeout(() => {
|
|
782
|
-
inputRef.current?.focus();
|
|
783
|
-
}, 100);
|
|
784
|
-
return () => clearTimeout(timer);
|
|
785
|
-
}
|
|
786
|
-
}, [open]);
|
|
787
|
-
|
|
788
|
-
// 使用 open 属性控制浮层显示
|
|
789
|
-
const hide = useCallback(() => {
|
|
790
|
-
setOpen(false);
|
|
791
|
-
}, []);
|
|
792
|
-
const handleConfirm = useCallback((newTitle, callback) => {
|
|
793
|
-
add(newTitle);
|
|
794
|
-
callback?.();
|
|
795
|
-
hide();
|
|
796
|
-
}, [add, hide]);
|
|
797
|
-
const handleOpenChange = useCallback(newOpen => {
|
|
798
|
-
setOpen(newOpen);
|
|
799
|
-
}, []);
|
|
800
|
-
return /*#__PURE__*/jsx(Popover, {
|
|
801
|
-
content: /*#__PURE__*/jsx(PopoverContent, {
|
|
802
|
-
ref: inputRef,
|
|
803
|
-
onClose: hide,
|
|
804
|
-
onConfirm: handleConfirm
|
|
805
|
-
}),
|
|
806
|
-
trigger: "click",
|
|
807
|
-
open: open,
|
|
808
|
-
onOpenChange: handleOpenChange,
|
|
809
|
-
destroyOnHidden: true,
|
|
810
|
-
children: children
|
|
811
|
-
});
|
|
812
|
-
};
|
|
813
|
-
var EditablePopover$1 = /*#__PURE__*/memo(EditablePopover);
|
|
814
|
-
|
|
815
|
-
const EditableContext = /*#__PURE__*/createContext(null);
|
|
816
|
-
const TreeTitle = _ref => {
|
|
817
|
-
let {
|
|
818
|
-
...props
|
|
819
|
-
} = _ref;
|
|
820
|
-
const [form] = Form.useForm();
|
|
821
|
-
return /*#__PURE__*/jsx(Form, {
|
|
822
|
-
form: form,
|
|
823
|
-
component: false,
|
|
824
|
-
children: /*#__PURE__*/jsx(EditableContext.Provider, {
|
|
825
|
-
value: form,
|
|
826
|
-
children: /*#__PURE__*/jsx(TreeTitleNode, {
|
|
827
|
-
...props
|
|
828
|
-
})
|
|
829
|
-
})
|
|
830
|
-
});
|
|
831
|
-
};
|
|
832
|
-
const TreeTitleNode = _ref2 => {
|
|
833
|
-
let {
|
|
834
|
-
title,
|
|
835
|
-
nodeData,
|
|
836
|
-
handleSave,
|
|
837
|
-
handleDel,
|
|
838
|
-
handleAdd
|
|
839
|
-
} = _ref2;
|
|
840
|
-
const [editing, setEditing] = useState(false);
|
|
841
|
-
const inputRef = useRef(null);
|
|
842
|
-
const form = useContext(EditableContext);
|
|
843
|
-
useEffect(() => {
|
|
844
|
-
if (editing) {
|
|
845
|
-
inputRef.current?.focus();
|
|
846
|
-
}
|
|
847
|
-
}, [editing]);
|
|
848
|
-
const toggleEdit = useCallback(() => {
|
|
849
|
-
setEditing(prev => !prev);
|
|
850
|
-
form.setFieldsValue({
|
|
851
|
-
[nodeData.title]: nodeData.title
|
|
852
|
-
});
|
|
853
|
-
}, [form, nodeData.title]);
|
|
854
|
-
const save = useCallback(async () => {
|
|
855
|
-
try {
|
|
856
|
-
const values = await form.validateFields();
|
|
857
|
-
toggleEdit();
|
|
858
|
-
handleSave({
|
|
859
|
-
...nodeData,
|
|
860
|
-
title: values[nodeData.title]
|
|
861
|
-
});
|
|
862
|
-
} catch (errInfo) {
|
|
863
|
-
console.error('Save failed:', errInfo);
|
|
864
|
-
}
|
|
865
|
-
}, [form, toggleEdit, handleSave, nodeData]);
|
|
866
|
-
|
|
867
|
-
// 新建文件夹
|
|
868
|
-
// 修改文件/文件夹
|
|
869
|
-
// 删除文件/文件夹
|
|
870
|
-
const renderIconNode = useCallback(() => {
|
|
871
|
-
return /*#__PURE__*/jsxs("span", {
|
|
872
|
-
className: "flex",
|
|
873
|
-
onClick: e => e.stopPropagation(),
|
|
874
|
-
children: [/*#__PURE__*/jsx(EditablePopover$1, {
|
|
875
|
-
add: newTitle => handleAdd(nodeData, newTitle),
|
|
876
|
-
children: /*#__PURE__*/jsx("div", {
|
|
877
|
-
className: "px-1",
|
|
878
|
-
title: "create",
|
|
879
|
-
children: /*#__PURE__*/jsx("i", {
|
|
880
|
-
className: "iconfont icon-jia"
|
|
881
|
-
})
|
|
882
|
-
})
|
|
883
|
-
}), !nodeData.isRoot && /*#__PURE__*/jsxs(Fragment, {
|
|
884
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
885
|
-
className: "px-1",
|
|
886
|
-
onClick: toggleEdit,
|
|
887
|
-
title: "edit",
|
|
888
|
-
children: /*#__PURE__*/jsx("i", {
|
|
889
|
-
className: "iconfont icon-bianji"
|
|
890
|
-
})
|
|
891
|
-
}), /*#__PURE__*/jsx(Popconfirm, {
|
|
892
|
-
title: "Confirm deletion?",
|
|
893
|
-
onConfirm: () => handleDel(nodeData),
|
|
894
|
-
okText: "Yes",
|
|
895
|
-
cancelText: "No",
|
|
896
|
-
children: /*#__PURE__*/jsx("div", {
|
|
897
|
-
className: "px-1",
|
|
898
|
-
title: "delete",
|
|
899
|
-
children: /*#__PURE__*/jsx("i", {
|
|
900
|
-
className: "iconfont icon-jian"
|
|
901
|
-
})
|
|
902
|
-
})
|
|
903
|
-
})]
|
|
904
|
-
})]
|
|
905
|
-
});
|
|
906
|
-
}, [handleAdd, nodeData, title, toggleEdit, handleDel]);
|
|
907
|
-
const renderChildNode = useCallback(() => {
|
|
908
|
-
return editing ? /*#__PURE__*/jsx(Form.Item, {
|
|
909
|
-
style: {
|
|
910
|
-
margin: 0,
|
|
911
|
-
width: "100%"
|
|
912
|
-
},
|
|
913
|
-
name: nodeData.title,
|
|
914
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
915
|
-
ref: inputRef,
|
|
916
|
-
onPressEnter: save,
|
|
917
|
-
onBlur: save,
|
|
918
|
-
autoComplete: "off",
|
|
919
|
-
size: "small"
|
|
920
|
-
})
|
|
921
|
-
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
922
|
-
children: [/*#__PURE__*/jsx(Typography.Text, {
|
|
923
|
-
ellipsis: true,
|
|
924
|
-
style: {
|
|
925
|
-
width: "75%"
|
|
926
|
-
},
|
|
927
|
-
children: title
|
|
928
|
-
}), renderIconNode()]
|
|
929
|
-
});
|
|
930
|
-
}, [editing, nodeData.title, save, title, renderIconNode]);
|
|
931
|
-
return /*#__PURE__*/jsx("div", {
|
|
932
|
-
className: "tree-title",
|
|
933
|
-
children: renderChildNode()
|
|
934
|
-
});
|
|
935
|
-
};
|
|
936
|
-
var TreeTitle$1 = /*#__PURE__*/memo(TreeTitle);
|
|
937
|
-
|
|
938
|
-
const buildDirectoryTree = function (data) {
|
|
939
|
-
let basePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
|
|
940
|
-
let parentRoute = arguments.length > 2 ? arguments[2] : undefined;
|
|
941
|
-
if (!Array.isArray(data)) return [];
|
|
942
|
-
return data.reduce((acc, item, index) => {
|
|
943
|
-
// 跳过文件类型,只处理目录
|
|
944
|
-
if (item.type === 'file') return acc;
|
|
945
|
-
const title = parentRoute ? item.name : item.sd_index ?? item.name;
|
|
946
|
-
const key = `${basePath}-${index}`;
|
|
947
|
-
const currentPath = parentRoute ? `${parentRoute}/${title}` : item.path;
|
|
948
|
-
const treeNode = {
|
|
949
|
-
title,
|
|
950
|
-
// 文件/文件夹名称
|
|
951
|
-
key,
|
|
952
|
-
icon: _ref => {
|
|
953
|
-
let {
|
|
954
|
-
expanded
|
|
955
|
-
} = _ref;
|
|
956
|
-
return expanded ? /*#__PURE__*/jsx(FolderOpenOutlined, {}) : /*#__PURE__*/jsx(FolderOutlined, {});
|
|
957
|
-
},
|
|
958
|
-
children: [],
|
|
959
|
-
isLeaf: false,
|
|
960
|
-
isRoot: Boolean(item.sd_index),
|
|
961
|
-
path: currentPath,
|
|
962
|
-
contents: (item.contents || []).filter(content => content.type === 'file'),
|
|
963
|
-
rawData: item // 保留原始数据
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
// 递归处理子目录
|
|
967
|
-
if (Array.isArray(item.contents) && item.contents.length > 0) {
|
|
968
|
-
treeNode.children = buildDirectoryTree(item.contents.filter(content => content.type !== 'file'), key, currentPath);
|
|
969
|
-
}
|
|
970
|
-
acc.push(treeNode);
|
|
971
|
-
return acc;
|
|
972
|
-
}, []);
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
/**
|
|
976
|
-
* 查找树中指定key的节点
|
|
977
|
-
* @param {Array} treeData - 树数据
|
|
978
|
-
* @param {string} targetKey - 要查找的key
|
|
979
|
-
* @returns {Array} 包含匹配节点的数组
|
|
980
|
-
*/
|
|
981
|
-
const findTreeNode = (treeData, targetKey) => {
|
|
982
|
-
if (!Array.isArray(treeData) || typeof targetKey !== 'string') return [];
|
|
983
|
-
const result = [];
|
|
984
|
-
const stack = [...treeData];
|
|
985
|
-
while (stack.length) {
|
|
986
|
-
const node = stack.pop();
|
|
987
|
-
if (node.key === targetKey) {
|
|
988
|
-
result.push(node);
|
|
989
|
-
// 如果只需要第一个匹配项,可以在这里break
|
|
990
|
-
}
|
|
991
|
-
if (Array.isArray(node.children)) {
|
|
992
|
-
stack.push(...node.children);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
return result;
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
* 获取树中所有节点的keys
|
|
1000
|
-
* @param {Array} treeData - 树数据
|
|
1001
|
-
* @returns {Array} 包含所有节点keys的数组
|
|
1002
|
-
*/
|
|
1003
|
-
const getAllNodeKeys = treeData => {
|
|
1004
|
-
if (!Array.isArray(treeData)) return [];
|
|
1005
|
-
const keys = [];
|
|
1006
|
-
const stack = [...treeData];
|
|
1007
|
-
while (stack.length) {
|
|
1008
|
-
const node = stack.pop();
|
|
1009
|
-
if (node.key != null) {
|
|
1010
|
-
keys.push(node.key);
|
|
1011
|
-
}
|
|
1012
|
-
if (Array.isArray(node.children)) {
|
|
1013
|
-
stack.push(...node.children);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
return keys;
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
const useDirectoryTree = _ref => {
|
|
1020
|
-
let {
|
|
1021
|
-
getFolderData,
|
|
1022
|
-
createFolder,
|
|
1023
|
-
removeFolderFile,
|
|
1024
|
-
renameFolderFile,
|
|
1025
|
-
height = 760,
|
|
1026
|
-
theme = {
|
|
1027
|
-
components: {
|
|
1028
|
-
Tree: {
|
|
1029
|
-
titleHeight: 30
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
} = _ref;
|
|
1034
|
-
const [treeState, setTreeState] = useState({
|
|
1035
|
-
data: [],
|
|
1036
|
-
selectedKeys: [],
|
|
1037
|
-
expandedKeys: [],
|
|
1038
|
-
currentPath: "",
|
|
1039
|
-
contents: [],
|
|
1040
|
-
loading: false
|
|
1041
|
-
});
|
|
1042
|
-
const [originTreeData, setOriginTreeData] = useState([]);
|
|
1043
|
-
const updateTreeState = partialState => {
|
|
1044
|
-
setTreeState(prev => ({
|
|
1045
|
-
...prev,
|
|
1046
|
-
...partialState
|
|
1047
|
-
}));
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
|
-
// 错误处理
|
|
1051
|
-
const handleError = (error, operation) => {
|
|
1052
|
-
console.error(`${operation} ERROR`, error);
|
|
1053
|
-
// 可以添加通知等统一错误处理
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
// 路径处理工具
|
|
1057
|
-
const pathUtils = {
|
|
1058
|
-
getNewPath: (node, newTitle) => {
|
|
1059
|
-
const arr = node.path.split('/');
|
|
1060
|
-
arr[arr.length - 1] = newTitle;
|
|
1061
|
-
return arr.join('/');
|
|
1062
|
-
},
|
|
1063
|
-
isSamePath: (path1, path2) => {
|
|
1064
|
-
return path1 === path2;
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// 节点查找工具
|
|
1069
|
-
const nodeUtils = {
|
|
1070
|
-
findNode: (treeData, key) => {
|
|
1071
|
-
return findTreeNode(treeData, key);
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
|
|
1075
|
-
// 获取文件夹数据 文件夹名称为空时返回根目录数据
|
|
1076
|
-
const fetchFolderData = useCallback(async function () {
|
|
1077
|
-
let initialization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1078
|
-
try {
|
|
1079
|
-
const data = await getFolderData({
|
|
1080
|
-
folder: ""
|
|
1081
|
-
});
|
|
1082
|
-
if (!data?.directoryTree) {
|
|
1083
|
-
return null;
|
|
1084
|
-
}
|
|
1085
|
-
setOriginTreeData(data.directoryTree);
|
|
1086
|
-
|
|
1087
|
-
// 递归生成treenodes
|
|
1088
|
-
const treeNodes = buildDirectoryTree(data.directoryTree);
|
|
1089
|
-
if (!treeNodes.length) {
|
|
1090
|
-
return null;
|
|
1091
|
-
}
|
|
1092
|
-
const firstChild = treeNodes[0];
|
|
1093
|
-
const newState = {
|
|
1094
|
-
data: treeNodes,
|
|
1095
|
-
...(initialization && {
|
|
1096
|
-
selectedKeys: [firstChild?.key],
|
|
1097
|
-
expandedKeys: getAllNodeKeys(treeNodes),
|
|
1098
|
-
currentPath: firstChild?.path,
|
|
1099
|
-
contents: firstChild?.contents || []
|
|
1100
|
-
})
|
|
1101
|
-
};
|
|
1102
|
-
updateTreeState(newState);
|
|
1103
|
-
return treeNodes;
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
handleError(error, 'GET FOLDER DATA');
|
|
1106
|
-
}
|
|
1107
|
-
}, []);
|
|
1108
|
-
|
|
1109
|
-
// 初始化数据
|
|
1110
|
-
useEffect(() => {
|
|
1111
|
-
fetchFolderData(true);
|
|
1112
|
-
}, [fetchFolderData]);
|
|
1113
|
-
|
|
1114
|
-
// 创建文件夹
|
|
1115
|
-
const handleCreate = useCallback(async (node, newTitle) => {
|
|
1116
|
-
if (!newTitle?.trim()) return false;
|
|
1117
|
-
try {
|
|
1118
|
-
const path = `${node.path}/${newTitle}`;
|
|
1119
|
-
await createFolder({
|
|
1120
|
-
path
|
|
1121
|
-
});
|
|
1122
|
-
const newTreeData = await fetchFolderData();
|
|
1123
|
-
|
|
1124
|
-
// 找到新增节点的父节点
|
|
1125
|
-
const parentNode = nodeUtils.findNode(newTreeData, node.key);
|
|
1126
|
-
if (parentNode?.[0]?.children) {
|
|
1127
|
-
const expectedPath = `${node.path}/${newTitle}`;
|
|
1128
|
-
// 通过 path 找到新增节点,得到新增节点的key
|
|
1129
|
-
const addedNode = parentNode[0].children.find(ch => pathUtils.isSamePath(ch.path, expectedPath));
|
|
1130
|
-
if (addedNode) {
|
|
1131
|
-
updateTreeState({
|
|
1132
|
-
expandedKeys: [...treeState.expandedKeys, addedNode.key, parentNode[0].key]
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
} catch (error) {
|
|
1137
|
-
handleError(error, 'CREATE FOLDER');
|
|
1138
|
-
}
|
|
1139
|
-
}, [fetchFolderData, treeState.expandedKeys]);
|
|
1140
|
-
|
|
1141
|
-
// 删除文件/文件夹
|
|
1142
|
-
const handleRemove = useCallback(async node => {
|
|
1143
|
-
if (!node.path) return;
|
|
1144
|
-
try {
|
|
1145
|
-
await removeFolderFile({
|
|
1146
|
-
paths: [{
|
|
1147
|
-
path: node.path
|
|
1148
|
-
}]
|
|
1149
|
-
});
|
|
1150
|
-
// 如果删除的是当前选中节点,则重新初始化
|
|
1151
|
-
const shouldReinitialize = treeState.selectedKeys[0] === node.key;
|
|
1152
|
-
await fetchFolderData(shouldReinitialize);
|
|
1153
|
-
} catch (error) {
|
|
1154
|
-
handleError(error, 'REMOVE FOLDER/FILE');
|
|
1155
|
-
}
|
|
1156
|
-
}, [fetchFolderData, treeState.selectedKeys]);
|
|
1157
|
-
|
|
1158
|
-
// 修改文件/文件夹
|
|
1159
|
-
const handleRename = useCallback(async node => {
|
|
1160
|
-
const newPath = pathUtils.getNewPath(node, node.title);
|
|
1161
|
-
if (pathUtils.isSamePath(node.path, newPath)) return false;
|
|
1162
|
-
try {
|
|
1163
|
-
await renameFolderFile({
|
|
1164
|
-
old_path: node.path,
|
|
1165
|
-
new_path: newPath
|
|
1166
|
-
});
|
|
1167
|
-
await fetchFolderData();
|
|
1168
|
-
} catch (error) {
|
|
1169
|
-
handleError(error, 'RENAME FOLDER/FILE');
|
|
1170
|
-
}
|
|
1171
|
-
}, [fetchFolderData]);
|
|
1172
|
-
|
|
1173
|
-
// 选择节点
|
|
1174
|
-
const onSelect = useCallback(async (keys, info) => {
|
|
1175
|
-
if (!keys.length || keys[0] === treeState.selectedKeys[0] && pathUtils.isSamePath(info.node.path, treeState.currentPath)) return;
|
|
1176
|
-
updateTreeState({
|
|
1177
|
-
selectedKeys: keys,
|
|
1178
|
-
currentPath: info.node.path,
|
|
1179
|
-
loading: true
|
|
1180
|
-
});
|
|
1181
|
-
try {
|
|
1182
|
-
// 模拟延迟加载
|
|
1183
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
1184
|
-
await new Promise(resolve => setTimeout(resolve, 300));
|
|
1185
|
-
updateTreeState({
|
|
1186
|
-
contents: info.node.contents,
|
|
1187
|
-
loading: false
|
|
1188
|
-
});
|
|
1189
|
-
} catch (error) {
|
|
1190
|
-
handleError(error, 'SELECT NODE');
|
|
1191
|
-
updateTreeState({
|
|
1192
|
-
loading: false
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
}, [treeState.selectedKeys, treeState.currentPath]);
|
|
1196
|
-
|
|
1197
|
-
// 展开节点
|
|
1198
|
-
const onExpand = useCallback(keys => {
|
|
1199
|
-
updateTreeState({
|
|
1200
|
-
expandedKeys: keys
|
|
1201
|
-
});
|
|
1202
|
-
}, []);
|
|
1203
|
-
|
|
1204
|
-
// 上传右侧文件或删除右侧文件 成功后的回调函数
|
|
1205
|
-
const updateFileContents = useCallback(async () => {
|
|
1206
|
-
// 找到当前选中的节点,更新当前节点的 contents
|
|
1207
|
-
const newTreeData = await fetchFolderData();
|
|
1208
|
-
const selectedNode = nodeUtils.findNode(newTreeData, treeState.selectedKeys[0]);
|
|
1209
|
-
if (selectedNode?.[0]) {
|
|
1210
|
-
updateTreeState({
|
|
1211
|
-
contents: selectedNode[0].contents
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
}, [fetchFolderData, treeState.selectedKeys]);
|
|
1215
|
-
|
|
1216
|
-
// 删除文件
|
|
1217
|
-
const removeFile = useCallback(async url => {
|
|
1218
|
-
try {
|
|
1219
|
-
await removeFolderFile({
|
|
1220
|
-
path: url
|
|
1221
|
-
});
|
|
1222
|
-
await updateFileContents();
|
|
1223
|
-
} catch (error) {
|
|
1224
|
-
handleError(error, 'REMOVE FILE');
|
|
1225
|
-
}
|
|
1226
|
-
}, [updateFileContents]);
|
|
1227
|
-
const MemoizedTree = useMemo(() => {
|
|
1228
|
-
if (!treeState.data?.length) {
|
|
1229
|
-
return /*#__PURE__*/jsx(Empty, {
|
|
1230
|
-
image: Empty.PRESENTED_IMAGE_SIMPLE
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
return /*#__PURE__*/jsx("div", {
|
|
1234
|
-
style: {
|
|
1235
|
-
paddingTop: 16
|
|
1236
|
-
},
|
|
1237
|
-
children: /*#__PURE__*/jsx(ConfigProvider, {
|
|
1238
|
-
theme: theme,
|
|
1239
|
-
children: /*#__PURE__*/jsx(Tree, {
|
|
1240
|
-
blockNode: true,
|
|
1241
|
-
showIcon: true,
|
|
1242
|
-
selectedKeys: treeState.selectedKeys,
|
|
1243
|
-
expandedKeys: treeState.expandedKeys,
|
|
1244
|
-
onSelect: onSelect,
|
|
1245
|
-
onExpand: onExpand,
|
|
1246
|
-
treeData: treeState.data,
|
|
1247
|
-
titleRender: nodeData => /*#__PURE__*/jsx(TreeTitle$1, {
|
|
1248
|
-
title: nodeData.title,
|
|
1249
|
-
nodeData: nodeData,
|
|
1250
|
-
handleSave: handleRename,
|
|
1251
|
-
handleDel: handleRemove,
|
|
1252
|
-
handleAdd: handleCreate
|
|
1253
|
-
}),
|
|
1254
|
-
height: height
|
|
1255
|
-
})
|
|
1256
|
-
})
|
|
1257
|
-
}, "folder-directory");
|
|
1258
|
-
}, [treeState.data, treeState.selectedKeys, treeState.expandedKeys]);
|
|
1259
|
-
return {
|
|
1260
|
-
directoryTree: MemoizedTree,
|
|
1261
|
-
contents: treeState.contents,
|
|
1262
|
-
currentPath: treeState.currentPath,
|
|
1263
|
-
loading: treeState.loading,
|
|
1264
|
-
originTreeData,
|
|
1265
|
-
updateFileContents,
|
|
1266
|
-
removeFile
|
|
1267
|
-
};
|
|
1268
|
-
};
|
|
1269
|
-
var useDirectoryTree$1 = useDirectoryTree;
|
|
1270
|
-
|
|
793
|
+
const _excluded = ["menuItems", "onMenuClick", "downloadFiles", "upgradeExecute", "upgradeStatus", "acceptFileTypes", "uploadCompleteDelay", "statusPollingInterval", "children"];
|
|
1271
794
|
const UpgradeManager = _ref => {
|
|
1272
795
|
let {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
796
|
+
menuItems = [],
|
|
797
|
+
onMenuClick,
|
|
798
|
+
downloadFiles,
|
|
799
|
+
upgradeExecute,
|
|
800
|
+
upgradeStatus,
|
|
801
|
+
acceptFileTypes = "application/octet-stream",
|
|
802
|
+
uploadCompleteDelay = 3000,
|
|
803
|
+
statusPollingInterval = 1000,
|
|
804
|
+
children
|
|
805
|
+
} = _ref,
|
|
806
|
+
dropdownProps = _objectWithoutProperties(_ref, _excluded);
|
|
1284
807
|
const [upgradeElement] = useUpgrade$1({
|
|
1285
808
|
menuItems,
|
|
1286
809
|
onMenuClick,
|
|
@@ -1296,11 +819,9 @@ const UpgradeManager = _ref => {
|
|
|
1296
819
|
const dropdownElement = upgradeElement.props.children[0];
|
|
1297
820
|
const otherElements = upgradeElement.props.children.slice(1);
|
|
1298
821
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
1299
|
-
children: [/*#__PURE__*/jsx(Dropdown, {
|
|
1300
|
-
...dropdownProps,
|
|
1301
|
-
...dropdownElement.props,
|
|
822
|
+
children: [/*#__PURE__*/jsx(Dropdown, _objectSpread2(_objectSpread2(_objectSpread2({}, dropdownProps), dropdownElement.props), {}, {
|
|
1302
823
|
children: children
|
|
1303
|
-
}), otherElements]
|
|
824
|
+
})), otherElements]
|
|
1304
825
|
});
|
|
1305
826
|
}
|
|
1306
827
|
|
|
@@ -2538,7 +2059,7 @@ const SystemOperations = _ref => {
|
|
|
2538
2059
|
try {
|
|
2539
2060
|
AntdModal.confirm({
|
|
2540
2061
|
icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
|
|
2541
|
-
title:
|
|
2062
|
+
title: "".concat(confirmTitle, " ").concat(action, "?"),
|
|
2542
2063
|
cancelText,
|
|
2543
2064
|
okText,
|
|
2544
2065
|
onOk: () => {
|
|
@@ -2555,7 +2076,7 @@ const SystemOperations = _ref => {
|
|
|
2555
2076
|
}
|
|
2556
2077
|
});
|
|
2557
2078
|
} catch (error) {
|
|
2558
|
-
console.error(
|
|
2079
|
+
console.error("".concat(action.toUpperCase(), " ERROR: "), error);
|
|
2559
2080
|
}
|
|
2560
2081
|
};
|
|
2561
2082
|
const handleMenuClick = _ref2 => {
|
|
@@ -2696,12 +2217,12 @@ function convertPtpStatusToArray(ptpStatus, fieldConfigs, fieldOrder) {
|
|
|
2696
2217
|
formType: 'text'
|
|
2697
2218
|
};
|
|
2698
2219
|
const value = ptpStatus[key];
|
|
2699
|
-
return {
|
|
2220
|
+
return _objectSpread2(_objectSpread2({
|
|
2700
2221
|
key,
|
|
2701
|
-
value
|
|
2702
|
-
|
|
2222
|
+
value
|
|
2223
|
+
}, config), {}, {
|
|
2703
2224
|
rawData: ptpStatus
|
|
2704
|
-
};
|
|
2225
|
+
});
|
|
2705
2226
|
});
|
|
2706
2227
|
}
|
|
2707
2228
|
const PtpModal = _ref => {
|
|
@@ -2723,7 +2244,7 @@ const PtpModal = _ref => {
|
|
|
2723
2244
|
useEffect(() => {
|
|
2724
2245
|
if (open) {
|
|
2725
2246
|
getPtpInfo().then(data => {
|
|
2726
|
-
if (data
|
|
2247
|
+
if (data !== null && data !== void 0 && data[0]) {
|
|
2727
2248
|
setPtpStatus(data[0]);
|
|
2728
2249
|
form.setFieldsValue(data[0]);
|
|
2729
2250
|
}
|
|
@@ -2736,8 +2257,7 @@ const PtpModal = _ref => {
|
|
|
2736
2257
|
}, [ptpStatus]);
|
|
2737
2258
|
const handleValueChange = changedValues => {
|
|
2738
2259
|
if ('t1_domain_number' in changedValues) {
|
|
2739
|
-
setPtpStatus(prev => ({
|
|
2740
|
-
...prev,
|
|
2260
|
+
setPtpStatus(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
2741
2261
|
t1_domain_number: changedValues.t1_domain_number
|
|
2742
2262
|
}));
|
|
2743
2263
|
}
|
|
@@ -2757,6 +2277,7 @@ const PtpModal = _ref => {
|
|
|
2757
2277
|
}
|
|
2758
2278
|
};
|
|
2759
2279
|
const renderFormItem = item => {
|
|
2280
|
+
var _item$statusMap, _item$min, _item$max;
|
|
2760
2281
|
switch (item.formType) {
|
|
2761
2282
|
case 'select':
|
|
2762
2283
|
return /*#__PURE__*/jsx(Select, {
|
|
@@ -2767,7 +2288,7 @@ const PtpModal = _ref => {
|
|
|
2767
2288
|
return /*#__PURE__*/jsx(Switch, {});
|
|
2768
2289
|
case 'badge':
|
|
2769
2290
|
const normalizedValue = typeof item.value === 'boolean' ? item.value ? 1 : 0 : item.value;
|
|
2770
|
-
const status = item.statusMap
|
|
2291
|
+
const status = ((_item$statusMap = item.statusMap) === null || _item$statusMap === void 0 ? void 0 : _item$statusMap[normalizedValue]) || {
|
|
2771
2292
|
text: 'Unknown',
|
|
2772
2293
|
color: 'gray'
|
|
2773
2294
|
};
|
|
@@ -2789,8 +2310,8 @@ const PtpModal = _ref => {
|
|
|
2789
2310
|
disabled: item.readOnly,
|
|
2790
2311
|
controls: false,
|
|
2791
2312
|
keyboard: false,
|
|
2792
|
-
min: item.min
|
|
2793
|
-
max: item.max
|
|
2313
|
+
min: (_item$min = item.min) !== null && _item$min !== void 0 ? _item$min : Number.MIN_SAFE_INTEGER,
|
|
2314
|
+
max: (_item$max = item.max) !== null && _item$max !== void 0 ? _item$max : Number.MAX_SAFE_INTEGER
|
|
2794
2315
|
});
|
|
2795
2316
|
default:
|
|
2796
2317
|
return /*#__PURE__*/jsx(Input, {
|
|
@@ -2801,19 +2322,18 @@ const PtpModal = _ref => {
|
|
|
2801
2322
|
if (!open || !ptpStatus) return null;
|
|
2802
2323
|
|
|
2803
2324
|
// 合并默认模态框属性和传入的属性
|
|
2804
|
-
const mergedModalProps = {
|
|
2325
|
+
const mergedModalProps = _objectSpread2({
|
|
2805
2326
|
title: "PTP",
|
|
2806
2327
|
width: 650,
|
|
2807
2328
|
open,
|
|
2808
2329
|
okText: "Apply",
|
|
2809
2330
|
cancelText: "Close",
|
|
2810
2331
|
onCancel: onClose,
|
|
2811
|
-
onOk: handleSubmit
|
|
2812
|
-
|
|
2813
|
-
};
|
|
2332
|
+
onOk: handleSubmit
|
|
2333
|
+
}, modalProps);
|
|
2814
2334
|
|
|
2815
2335
|
// 合并默认表单属性和传入的属性
|
|
2816
|
-
const mergedFormProps = {
|
|
2336
|
+
const mergedFormProps = _objectSpread2({
|
|
2817
2337
|
form: form,
|
|
2818
2338
|
name: "ptpForm",
|
|
2819
2339
|
labelCol: {
|
|
@@ -2823,25 +2343,23 @@ const PtpModal = _ref => {
|
|
|
2823
2343
|
span: 16
|
|
2824
2344
|
},
|
|
2825
2345
|
autoComplete: "off",
|
|
2826
|
-
onValuesChange: handleValueChange
|
|
2827
|
-
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
...mergedModalProps,
|
|
2831
|
-
children: /*#__PURE__*/jsx(Form, {
|
|
2832
|
-
...mergedFormProps,
|
|
2346
|
+
onValuesChange: handleValueChange
|
|
2347
|
+
}, formProps);
|
|
2348
|
+
return /*#__PURE__*/jsx(Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
|
|
2349
|
+
children: /*#__PURE__*/jsx(Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
|
|
2833
2350
|
children: ptpStatusArray.map(item => /*#__PURE__*/jsx(Form.Item, {
|
|
2834
2351
|
label: item.label,
|
|
2835
2352
|
name: item.key,
|
|
2836
2353
|
initialValue: item.value,
|
|
2837
2354
|
children: renderFormItem(item)
|
|
2838
2355
|
}, item.key))
|
|
2839
|
-
})
|
|
2840
|
-
});
|
|
2356
|
+
}))
|
|
2357
|
+
}));
|
|
2841
2358
|
};
|
|
2842
2359
|
var PtpModal$1 = /*#__PURE__*/memo(PtpModal);
|
|
2843
2360
|
|
|
2844
2361
|
const NetworkFieldGroup = _ref => {
|
|
2362
|
+
var _fieldConfig$netmask$, _fieldConfig$netmask;
|
|
2845
2363
|
let {
|
|
2846
2364
|
prefix,
|
|
2847
2365
|
interfaces,
|
|
@@ -2862,14 +2380,12 @@ const NetworkFieldGroup = _ref => {
|
|
|
2862
2380
|
enabled: true
|
|
2863
2381
|
}
|
|
2864
2382
|
};
|
|
2865
|
-
const mergedFieldConfig = {
|
|
2866
|
-
...defaultFieldConfig,
|
|
2867
|
-
...fieldConfig,
|
|
2383
|
+
const mergedFieldConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultFieldConfig), fieldConfig), {}, {
|
|
2868
2384
|
netmask: {
|
|
2869
2385
|
label: "Netmask",
|
|
2870
|
-
enabled: fieldConfig.netmask
|
|
2386
|
+
enabled: (_fieldConfig$netmask$ = (_fieldConfig$netmask = fieldConfig.netmask) === null || _fieldConfig$netmask === void 0 ? void 0 : _fieldConfig$netmask.enabled) !== null && _fieldConfig$netmask$ !== void 0 ? _fieldConfig$netmask$ : defaultFieldConfig.netmask.enabled // 合并 enabled
|
|
2871
2387
|
}
|
|
2872
|
-
};
|
|
2388
|
+
});
|
|
2873
2389
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
2874
2390
|
children: [/*#__PURE__*/jsx(Typography.Title, {
|
|
2875
2391
|
level: 5,
|
|
@@ -2940,24 +2456,20 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
2940
2456
|
hasInitialized: false
|
|
2941
2457
|
});
|
|
2942
2458
|
const preparedFieldConfig = useMemo(() => {
|
|
2943
|
-
const config = {
|
|
2944
|
-
...fieldConfig
|
|
2945
|
-
};
|
|
2459
|
+
const config = _objectSpread2({}, fieldConfig);
|
|
2946
2460
|
|
|
2947
2461
|
// 确保LAN和QSFP的配置存在
|
|
2948
2462
|
config.LAN = config.LAN || {};
|
|
2949
2463
|
config.QSFP = config.QSFP || {};
|
|
2950
2464
|
if (sections.includes('LAN')) {
|
|
2951
|
-
config.LAN.netmask = {
|
|
2952
|
-
...(config.LAN.netmask || {}),
|
|
2465
|
+
config.LAN.netmask = _objectSpread2(_objectSpread2({}, config.LAN.netmask || {}), {}, {
|
|
2953
2466
|
enabled: showNetmask.LAN
|
|
2954
|
-
};
|
|
2467
|
+
});
|
|
2955
2468
|
}
|
|
2956
2469
|
if (sections.includes('QSFP')) {
|
|
2957
|
-
config.QSFP.netmask = {
|
|
2958
|
-
...(config.QSFP.netmask || {}),
|
|
2470
|
+
config.QSFP.netmask = _objectSpread2(_objectSpread2({}, config.QSFP.netmask || {}), {}, {
|
|
2959
2471
|
enabled: showNetmask.QSFP
|
|
2960
|
-
};
|
|
2472
|
+
});
|
|
2961
2473
|
}
|
|
2962
2474
|
return config;
|
|
2963
2475
|
}, [fieldConfig, showNetmask, sections]);
|
|
@@ -3025,28 +2537,23 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3025
2537
|
const initialValues = useMemo(() => {
|
|
3026
2538
|
const values = {};
|
|
3027
2539
|
if (sections.includes('LAN') && lanConfigs.length > 0) {
|
|
3028
|
-
values.LAN = lanConfigs.map(config => ({
|
|
2540
|
+
values.LAN = lanConfigs.map(config => _objectSpread2({
|
|
3029
2541
|
connection_id: config.connection_id,
|
|
3030
2542
|
display_name: config.display_name,
|
|
3031
|
-
ip_address: config.ip_address
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
}));
|
|
2543
|
+
ip_address: config.ip_address
|
|
2544
|
+
}, showNetmask.LAN ? {
|
|
2545
|
+
netmask: config.netmask
|
|
2546
|
+
} : {}));
|
|
3036
2547
|
}
|
|
3037
2548
|
if (sections.includes('QSFP') && st2110Interfaces.length > 0) {
|
|
3038
|
-
values.QSFP = st2110Interfaces.map(iface => ({
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
id: iface.id
|
|
3042
|
-
}),
|
|
2549
|
+
values.QSFP = st2110Interfaces.map(iface => _objectSpread2(_objectSpread2({}, iface.id !== undefined && {
|
|
2550
|
+
id: iface.id
|
|
2551
|
+
}), {}, {
|
|
3043
2552
|
display_name: iface.display_name,
|
|
3044
|
-
ip_address: iface.ip_address || iface.ip
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
} : {})
|
|
3049
|
-
}));
|
|
2553
|
+
ip_address: iface.ip_address || iface.ip
|
|
2554
|
+
}, showNetmask.QSFP ? {
|
|
2555
|
+
netmask: iface.netmask
|
|
2556
|
+
} : {}));
|
|
3050
2557
|
}
|
|
3051
2558
|
return values;
|
|
3052
2559
|
}, [lanConfigs, st2110Interfaces, sections, showNetmask]);
|
|
@@ -3108,32 +2615,32 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3108
2615
|
|
|
3109
2616
|
// 更新LAN配置
|
|
3110
2617
|
if (sections.includes('LAN') && values.LAN) {
|
|
3111
|
-
const lanData = values.LAN.map((item, index) =>
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
2618
|
+
const lanData = values.LAN.map((item, index) => {
|
|
2619
|
+
var _lanConfigs$index;
|
|
2620
|
+
return _objectSpread2({
|
|
2621
|
+
connection_id: (_lanConfigs$index = lanConfigs[index]) === null || _lanConfigs$index === void 0 ? void 0 : _lanConfigs$index.connection_id,
|
|
2622
|
+
ip_address: item.ip_address
|
|
2623
|
+
}, showNetmask.LAN ? {
|
|
3115
2624
|
netmask: item.netmask
|
|
3116
|
-
} : {})
|
|
3117
|
-
})
|
|
2625
|
+
} : {});
|
|
2626
|
+
});
|
|
3118
2627
|
updatePromises.push(updateLanConfig(lanData));
|
|
3119
2628
|
}
|
|
3120
2629
|
|
|
3121
2630
|
// 更新QSFP配置
|
|
3122
2631
|
if (sections.includes('QSFP') && values.QSFP) {
|
|
3123
|
-
const interfacesData = values.QSFP.map((item, index) =>
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
id: st2110Interfaces
|
|
3127
|
-
}),
|
|
3128
|
-
...(st2110Interfaces?.[index]?.ip !== undefined ? {
|
|
2632
|
+
const interfacesData = values.QSFP.map((item, index) => {
|
|
2633
|
+
var _st2110Interfaces$ind, _st2110Interfaces$ind2, _st2110Interfaces$ind3;
|
|
2634
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind = st2110Interfaces[index]) === null || _st2110Interfaces$ind === void 0 ? void 0 : _st2110Interfaces$ind.id) !== undefined && {
|
|
2635
|
+
id: st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind2 = st2110Interfaces[index]) === null || _st2110Interfaces$ind2 === void 0 ? void 0 : _st2110Interfaces$ind2.id
|
|
2636
|
+
}), (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind3 = st2110Interfaces[index]) === null || _st2110Interfaces$ind3 === void 0 ? void 0 : _st2110Interfaces$ind3.ip) !== undefined ? {
|
|
3129
2637
|
ip: item.ip_address
|
|
3130
2638
|
} : {
|
|
3131
2639
|
ip_address: item.ip_address
|
|
3132
|
-
}),
|
|
3133
|
-
...(showNetmask.QSFP ? {
|
|
2640
|
+
}), showNetmask.QSFP ? {
|
|
3134
2641
|
netmask: item.netmask
|
|
3135
|
-
} : {})
|
|
3136
|
-
})
|
|
2642
|
+
} : {});
|
|
2643
|
+
});
|
|
3137
2644
|
const st2110Data = st2110Interfaces.some(iface => 'id' in iface) ? {
|
|
3138
2645
|
st2110_interfaces: interfacesData
|
|
3139
2646
|
} : {
|
|
@@ -3159,7 +2666,7 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3159
2666
|
}, [form, sections, lanConfigs, st2110Interfaces, updateLanConfig, updateSysConfig, handleSuccess, message]);
|
|
3160
2667
|
|
|
3161
2668
|
// 合并默认模态框属性和传入的属性
|
|
3162
|
-
const mergedModalProps = {
|
|
2669
|
+
const mergedModalProps = _objectSpread2({
|
|
3163
2670
|
title: "Network Settings",
|
|
3164
2671
|
width: 650,
|
|
3165
2672
|
open,
|
|
@@ -3169,21 +2676,19 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3169
2676
|
okText: "Apply",
|
|
3170
2677
|
cancelText: "Close",
|
|
3171
2678
|
centered: true,
|
|
3172
|
-
styles: {
|
|
2679
|
+
styles: _objectSpread2({
|
|
3173
2680
|
body: {
|
|
3174
2681
|
padding: "16px 24px 8px 24px"
|
|
3175
|
-
}
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
...modalProps
|
|
3183
|
-
};
|
|
2682
|
+
}
|
|
2683
|
+
}, restartRemark !== null && {
|
|
2684
|
+
footer: {
|
|
2685
|
+
paddingBottom: 28
|
|
2686
|
+
}
|
|
2687
|
+
})
|
|
2688
|
+
}, modalProps);
|
|
3184
2689
|
|
|
3185
2690
|
// 合并默认表单属性和传入的属性
|
|
3186
|
-
const mergedFormProps = {
|
|
2691
|
+
const mergedFormProps = _objectSpread2({
|
|
3187
2692
|
form: form,
|
|
3188
2693
|
labelCol: {
|
|
3189
2694
|
span: 6
|
|
@@ -3191,13 +2696,10 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3191
2696
|
wrapperCol: {
|
|
3192
2697
|
span: 18
|
|
3193
2698
|
},
|
|
3194
|
-
autoComplete: "off"
|
|
3195
|
-
|
|
3196
|
-
}
|
|
3197
|
-
|
|
3198
|
-
...mergedModalProps,
|
|
3199
|
-
children: [/*#__PURE__*/jsxs(Form, {
|
|
3200
|
-
...mergedFormProps,
|
|
2699
|
+
autoComplete: "off"
|
|
2700
|
+
}, formProps);
|
|
2701
|
+
return /*#__PURE__*/jsxs(Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
|
|
2702
|
+
children: [/*#__PURE__*/jsxs(Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
|
|
3201
2703
|
children: [sections.includes('LAN') && lanConfigs.length > 0 && /*#__PURE__*/jsxs(Fragment, {
|
|
3202
2704
|
children: [/*#__PURE__*/jsx(NetworkFieldGroup, {
|
|
3203
2705
|
prefix: "LAN",
|
|
@@ -3209,8 +2711,8 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
3209
2711
|
interfaces: st2110Interfaces,
|
|
3210
2712
|
fieldConfig: preparedFieldConfig.QSFP
|
|
3211
2713
|
})]
|
|
3212
|
-
}), restartRemark]
|
|
3213
|
-
});
|
|
2714
|
+
})), restartRemark]
|
|
2715
|
+
}));
|
|
3214
2716
|
};
|
|
3215
2717
|
var NetworkSettingsModal$1 = /*#__PURE__*/memo(NetworkSettingsModal);
|
|
3216
2718
|
|
|
@@ -3236,7 +2738,7 @@ const LeftList = /*#__PURE__*/memo(_ref => {
|
|
|
3236
2738
|
className: "list-container",
|
|
3237
2739
|
children: /*#__PURE__*/jsx(List, {
|
|
3238
2740
|
header: /*#__PURE__*/jsxs("div", {
|
|
3239
|
-
className:
|
|
2741
|
+
className: "grid ".concat(gridColumns, " w-full list-header"),
|
|
3240
2742
|
children: [/*#__PURE__*/jsx("div", {
|
|
3241
2743
|
children: "Name"
|
|
3242
2744
|
}), /*#__PURE__*/jsx("div", {
|
|
@@ -3248,13 +2750,13 @@ const LeftList = /*#__PURE__*/memo(_ref => {
|
|
|
3248
2750
|
dataSource: dataSource,
|
|
3249
2751
|
rowKey: "id",
|
|
3250
2752
|
renderItem: item => /*#__PURE__*/jsx(List.Item, {
|
|
3251
|
-
className:
|
|
2753
|
+
className: "list-item ".concat(selectedPresetId === item.id ? 'selected' : ''),
|
|
3252
2754
|
style: {
|
|
3253
2755
|
padding: "9px 24px"
|
|
3254
2756
|
},
|
|
3255
2757
|
onClick: () => onSelectPreset(item),
|
|
3256
2758
|
children: /*#__PURE__*/jsxs("div", {
|
|
3257
|
-
className:
|
|
2759
|
+
className: "grid ".concat(gridColumns, " w-full text-text-normal"),
|
|
3258
2760
|
children: [/*#__PURE__*/jsx("div", {
|
|
3259
2761
|
title: item.name,
|
|
3260
2762
|
children: item.name || "Untitled Preset"
|
|
@@ -3371,10 +2873,9 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
3371
2873
|
return fields.category_list.options.map(category => {
|
|
3372
2874
|
const isInitiallySelected = initialSelected.includes(category.name);
|
|
3373
2875
|
const shouldDisable = isEditing ? !isInitiallySelected : false;
|
|
3374
|
-
return {
|
|
3375
|
-
...category,
|
|
2876
|
+
return _objectSpread2(_objectSpread2({}, category), {}, {
|
|
3376
2877
|
disabled: shouldDisable
|
|
3377
|
-
};
|
|
2878
|
+
});
|
|
3378
2879
|
});
|
|
3379
2880
|
}, [initialSelected, isEditing, hasCategoryList, fields.category_list]);
|
|
3380
2881
|
return /*#__PURE__*/jsxs(Flex, {
|
|
@@ -3433,13 +2934,13 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
3433
2934
|
disabled: isEditing
|
|
3434
2935
|
})
|
|
3435
2936
|
})]
|
|
3436
|
-
}), isEditing ? /*#__PURE__*/jsx(SubmitButton, {
|
|
3437
|
-
action: onLoad
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
2937
|
+
}), isEditing ? /*#__PURE__*/jsx(SubmitButton, _objectSpread2(_objectSpread2({
|
|
2938
|
+
action: onLoad
|
|
2939
|
+
}, hasCategoryList && {
|
|
2940
|
+
disabled: !currentSelected.length
|
|
2941
|
+
}), {}, {
|
|
3441
2942
|
children: texts.loadButton
|
|
3442
|
-
}) : /*#__PURE__*/jsx(SubmitButton, {
|
|
2943
|
+
})) : /*#__PURE__*/jsx(SubmitButton, {
|
|
3443
2944
|
action: onSave,
|
|
3444
2945
|
loading: isLoading,
|
|
3445
2946
|
children: texts.saveButton
|
|
@@ -3497,7 +2998,7 @@ const Preset = _ref => {
|
|
|
3497
2998
|
const fetchPresetList = useCallback(async () => {
|
|
3498
2999
|
try {
|
|
3499
3000
|
const data = await getPresetList();
|
|
3500
|
-
const presets = data
|
|
3001
|
+
const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
|
|
3501
3002
|
setPresetList(presets);
|
|
3502
3003
|
} catch (error) {
|
|
3503
3004
|
console.error('Failed to fetch preset list:', error);
|
|
@@ -3509,6 +3010,7 @@ const Preset = _ref => {
|
|
|
3509
3010
|
// setPresetChanged(prev => prev + 1); // 触发更新
|
|
3510
3011
|
}, [form]);
|
|
3511
3012
|
const handleAddNew = useCallback(() => {
|
|
3013
|
+
var _fields$category_list;
|
|
3512
3014
|
const unsavedPreset = presetList.find(item => !item.id);
|
|
3513
3015
|
if (unsavedPreset) {
|
|
3514
3016
|
AntdMessage.warning('Existing unsaved preset detected.');
|
|
@@ -3522,7 +3024,7 @@ const Preset = _ref => {
|
|
|
3522
3024
|
}, {});
|
|
3523
3025
|
|
|
3524
3026
|
// 特殊处理 category_list
|
|
3525
|
-
if (fields.category_list
|
|
3027
|
+
if ((_fields$category_list = fields.category_list) !== null && _fields$category_list !== void 0 && _fields$category_list.options) {
|
|
3526
3028
|
newPreset.category_list = fields.category_list.options.map(item => item.name);
|
|
3527
3029
|
}
|
|
3528
3030
|
setPresetList([...presetList, newPreset]);
|
|
@@ -3538,7 +3040,7 @@ const Preset = _ref => {
|
|
|
3538
3040
|
try {
|
|
3539
3041
|
AntdModal.confirm({
|
|
3540
3042
|
icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
|
|
3541
|
-
title:
|
|
3043
|
+
title: "".concat(texts.deleteConfirm, " \"").concat(presetName, "\"?"),
|
|
3542
3044
|
cancelText: 'No',
|
|
3543
3045
|
okText: 'Yes',
|
|
3544
3046
|
onOk: async () => {
|
|
@@ -3563,7 +3065,7 @@ const Preset = _ref => {
|
|
|
3563
3065
|
}
|
|
3564
3066
|
}, [selectedPreset, form, AntdModal, AntdMessage, fetchPresetList, texts]);
|
|
3565
3067
|
const handleLoadPreset = useCallback(async () => {
|
|
3566
|
-
if (!selectedPreset
|
|
3068
|
+
if (!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id)) return;
|
|
3567
3069
|
|
|
3568
3070
|
// 显示加载模态框
|
|
3569
3071
|
const modalInstance = Modal.info({
|
|
@@ -3580,12 +3082,11 @@ const Preset = _ref => {
|
|
|
3580
3082
|
}
|
|
3581
3083
|
});
|
|
3582
3084
|
try {
|
|
3583
|
-
await loadPreset({
|
|
3584
|
-
id: selectedPreset.id
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
});
|
|
3085
|
+
await loadPreset(_objectSpread2({
|
|
3086
|
+
id: selectedPreset.id
|
|
3087
|
+
}, selectedPreset.category_list && {
|
|
3088
|
+
category_list: selectedPreset.category_list
|
|
3089
|
+
}));
|
|
3589
3090
|
// 成功时延迟关闭
|
|
3590
3091
|
setTimeout(() => {
|
|
3591
3092
|
modalInstance.destroy();
|
|
@@ -3624,13 +3125,13 @@ const Preset = _ref => {
|
|
|
3624
3125
|
title: texts.title,
|
|
3625
3126
|
width: width,
|
|
3626
3127
|
open: open,
|
|
3627
|
-
wrapClassName:
|
|
3128
|
+
wrapClassName: "preset-management ".concat(className),
|
|
3628
3129
|
footer: null,
|
|
3629
3130
|
onCancel: onClose,
|
|
3630
3131
|
centered: true,
|
|
3631
3132
|
styles: {
|
|
3632
3133
|
body: {
|
|
3633
|
-
height:
|
|
3134
|
+
height: "".concat(height, "px")
|
|
3634
3135
|
}
|
|
3635
3136
|
},
|
|
3636
3137
|
children: /*#__PURE__*/jsxs(Row, {
|
|
@@ -3641,7 +3142,7 @@ const Preset = _ref => {
|
|
|
3641
3142
|
className: "h-full",
|
|
3642
3143
|
children: /*#__PURE__*/jsx(LeftList, {
|
|
3643
3144
|
dataSource: presetList,
|
|
3644
|
-
selectedPresetId: selectedPreset
|
|
3145
|
+
selectedPresetId: selectedPreset === null || selectedPreset === void 0 ? void 0 : selectedPreset.id,
|
|
3645
3146
|
onSelectPreset: handleSelectPreset,
|
|
3646
3147
|
onAddNew: handleAddNew,
|
|
3647
3148
|
onRemove: handleRemove,
|
|
@@ -3660,7 +3161,7 @@ const Preset = _ref => {
|
|
|
3660
3161
|
onSave: handleSave,
|
|
3661
3162
|
onLoad: handleLoadPreset,
|
|
3662
3163
|
isLoading: loading,
|
|
3663
|
-
isEditing: !!selectedPreset
|
|
3164
|
+
isEditing: !!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id),
|
|
3664
3165
|
fields: fields,
|
|
3665
3166
|
texts: {
|
|
3666
3167
|
loadButton: texts.loadButton,
|
|
@@ -3683,5 +3184,5 @@ const Preset = _ref => {
|
|
|
3683
3184
|
};
|
|
3684
3185
|
var PresetModal = /*#__PURE__*/memo(Preset);
|
|
3685
3186
|
|
|
3686
|
-
export { AuthorizationModal$1 as AuthorizationModal, NetworkSettingsModal$1 as NetworkSettingsModal, PresetModal, PtpModal$1 as PtpModal, SystemOperations$1 as SystemOperations, UpgradeManager$1 as UpgradeManager, useAuth,
|
|
3187
|
+
export { AuthorizationModal$1 as AuthorizationModal, NetworkSettingsModal$1 as NetworkSettingsModal, PresetModal, PtpModal$1 as PtpModal, SystemOperations$1 as SystemOperations, UpgradeManager$1 as UpgradeManager, useAuth, useHardwareUsage$1 as useHardwareUsage, useSystemOperations$1 as useSystemOperations, useUpgrade$1 as useUpgrade };
|
|
3687
3188
|
//# sourceMappingURL=index.esm.js.map
|