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