seeder-st2110-components 1.3.5 → 1.3.6

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 CHANGED
@@ -1,10 +1,74 @@
1
- import { useState, useCallback, useEffect, memo, useMemo, useRef, forwardRef, useContext, createContext } from 'react';
1
+ import { useState, useCallback, useEffect, memo, useMemo, useRef } from 'react';
2
2
  import { useWebSocket, useInterval } from 'ahooks';
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';
3
+ 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
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { LoadingOutlined, ExclamationCircleFilled, FolderOpenOutlined, FolderOutlined, PlusOutlined } from '@ant-design/icons';
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
+
8
72
  const useHardwareWebSocket = socketUrl => {
9
73
  // cpu_percent cpu使用率
10
74
  // cpu_freq.current cpu频率
@@ -22,9 +86,7 @@ const useHardwareWebSocket = socketUrl => {
22
86
  const handleMessage = useCallback(message => {
23
87
  try {
24
88
  if (message) {
25
- setSystemStatus(prev => ({
26
- ...prev,
27
- ...message,
89
+ setSystemStatus(prev => _objectSpread2(_objectSpread2(_objectSpread2({}, prev), message), {}, {
28
90
  lastUpdated: Date.now() // 添加更新时间戳
29
91
  }));
30
92
  }
@@ -35,7 +97,7 @@ const useHardwareWebSocket = socketUrl => {
35
97
 
36
98
  // 监听消息 如果latestMessage变化,说明有新消息
37
99
  useEffect(() => {
38
- if (!latestMessage?.data) return;
100
+ if (!(latestMessage !== null && latestMessage !== void 0 && latestMessage.data)) return;
39
101
  try {
40
102
  const parsedMessage = JSON.parse(latestMessage.data);
41
103
  handleMessage(parsedMessage);
@@ -43,7 +105,7 @@ const useHardwareWebSocket = socketUrl => {
43
105
  console.error('Message parsing error:', error);
44
106
  console.debug('Raw message:', latestMessage.data);
45
107
  }
46
- }, [latestMessage?.data, handleMessage]);
108
+ }, [latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.data, handleMessage]);
47
109
  return {
48
110
  ps_status: systemStatus
49
111
  };
@@ -78,7 +140,7 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
78
140
  children: /*#__PURE__*/jsxs(Space, {
79
141
  size: 4,
80
142
  children: [/*#__PURE__*/jsx("i", {
81
- className: `iconfont ${iconClass} text-xl`
143
+ className: "iconfont ".concat(iconClass, " text-xl")
82
144
  }), /*#__PURE__*/jsx("span", {
83
145
  className: "inline-block w-10 text-center",
84
146
  children: children
@@ -90,7 +152,10 @@ var UsageItem$1 = UsageItem;
90
152
 
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 => sensors?.[field]?.map(item => item.current) || []).filter(temp => typeof temp === 'number');
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 ?? null,
112
- cpu_temp: sensors_temperatures?.coretemp?.[0]?.current ?? null,
113
- mem_total: mem?.total ?? null,
114
- mem_usage: mem?.percent ?? null,
115
- mem_temp: getMaxSensorTemp(sensors_temperatures?.spd5118),
116
- nic_temp: getMaxNicTemp(sensors_temperatures) ?? null,
117
- hd_temp: getMaxSensorTemp(sensors_temperatures?.nvme),
118
- gpu_usage: gpu_stats?.[0]?.["utilization.gpu"] ?? null,
119
- gpu_temp: gpu_stats?.[0]?.["temperature.gpu"] ?? null
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: `${numValue}${unit}`,
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, '℃'));
@@ -212,7 +277,7 @@ const AuthorizationModal = _ref => {
212
277
  onOk(trimmedCode);
213
278
  };
214
279
  const statusAlert = isActivated ? /*#__PURE__*/jsx(Alert, {
215
- message: `${statusMessage}, will expire on ${expiresTime}`,
280
+ message: "".concat(statusMessage, ", will expire on ").concat(expiresTime),
216
281
  type: "success",
217
282
  showIcon: true
218
283
  }) : /*#__PURE__*/jsx(Alert, {
@@ -301,7 +366,7 @@ const useAuth = options => {
301
366
  try {
302
367
  setLoading(true);
303
368
  const result = await fetchAuthInfo();
304
- if (result?.commands) {
369
+ if (result !== null && result !== void 0 && result.commands) {
305
370
  const commands = result.commands;
306
371
  setAuthData(commands);
307
372
  setIsRegistered(commands.accredit_status);
@@ -327,10 +392,10 @@ const useAuth = options => {
327
392
  license_data: code
328
393
  }
329
394
  });
330
- if (result?.commands) {
395
+ if (result !== null && result !== void 0 && result.commands) {
331
396
  const commands = result.commands;
332
397
  // type accredit_message
333
- if (commands?.accredit_status) {
398
+ if (commands !== null && commands !== void 0 && commands.accredit_status) {
334
399
  setIsRegistered(true);
335
400
  setAuthData(commands);
336
401
  closeModal();
@@ -457,7 +522,7 @@ const useUpgrade = _ref => {
457
522
  if (onMenuClick) {
458
523
  onMenuClick(key);
459
524
  } else {
460
- console.warn(`Unknown menu key: ${key} and no onMenuClick provided`);
525
+ console.warn("Unknown menu key: ".concat(key, " and no onMenuClick provided"));
461
526
  }
462
527
  }
463
528
  };
@@ -470,7 +535,7 @@ const useUpgrade = _ref => {
470
535
  try {
471
536
  const res = await downloadFiles();
472
537
  if (res.status !== 200) {
473
- throw new Error(`Unexpected status code: ${res.status}`);
538
+ throw new Error("Unexpected status code: ".concat(res.status));
474
539
  }
475
540
 
476
541
  // 默认值,兼容接口响应头没有定义文件名
@@ -480,7 +545,7 @@ const useUpgrade = _ref => {
480
545
  // 获取接口响应的content-disposition字段值,以便获取到文件名
481
546
  if (contentDisposition) {
482
547
  const filenameMatch = contentDisposition.match(/filename\s*=\s*"?([^";]+)"?/i);
483
- if (filenameMatch?.[1]) {
548
+ if (filenameMatch !== null && filenameMatch !== void 0 && filenameMatch[1]) {
484
549
  fileName = decodeURIComponent(filenameMatch[1]); // 处理编码后的文件名(如 %20 转空格)
485
550
  }
486
551
  }
@@ -509,7 +574,7 @@ const useUpgrade = _ref => {
509
574
  }
510
575
  };
511
576
  const onUpload = () => {
512
- if (inputRef?.current) {
577
+ if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
513
578
  inputRef.current.click();
514
579
  }
515
580
  };
@@ -520,7 +585,8 @@ const useUpgrade = _ref => {
520
585
  return;
521
586
  }
522
587
  try {
523
- const file = event.target.files?.[0];
588
+ var _event$target$files;
589
+ const file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
524
590
  if (!file) return;
525
591
  showLoader();
526
592
  setCurrentStatus('Uploading...');
@@ -568,7 +634,7 @@ const useUpgrade = _ref => {
568
634
  const response = await upgradeStatus({
569
635
  cancelToken: statusCancelToken.current.token
570
636
  });
571
- if (response?.status === 200) {
637
+ if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
572
638
  const {
573
639
  code,
574
640
  message: statusMessage
@@ -656,7 +722,7 @@ const useUpgrade = _ref => {
656
722
  },
657
723
  spin: true
658
724
  }),
659
- tip: currentStatus === "Uploading..." ? `${currentStatus} ${uploadProgress}%` : currentStatus,
725
+ tip: currentStatus === "Uploading..." ? "".concat(currentStatus, " ").concat(uploadProgress, "%") : currentStatus,
660
726
  size: "large",
661
727
  fullscreen: true
662
728
  })]
@@ -681,7 +747,7 @@ const useSystemOperations = function () {
681
747
  try {
682
748
  AntdModal.confirm({
683
749
  icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
684
- title: `${confirmTitle} ${action}?`,
750
+ title: "".concat(confirmTitle, " ").concat(action, "?"),
685
751
  cancelText,
686
752
  okText,
687
753
  onOk: () => {
@@ -698,7 +764,7 @@ const useSystemOperations = function () {
698
764
  }
699
765
  });
700
766
  } catch (error) {
701
- console.error(`${action.toUpperCase()} ERROR: `, error);
767
+ console.error("".concat(action.toUpperCase(), " ERROR: "), error);
702
768
  }
703
769
  }, [AntdModal, confirmTitle, cancelText, okText, onPowerOff, onRestart]);
704
770
  const getMenuItems = useCallback(() => [{
@@ -721,566 +787,20 @@ const useSystemOperations = function () {
721
787
  };
722
788
  var useSystemOperations$1 = useSystemOperations;
723
789
 
724
- const PopoverContent = /*#__PURE__*/forwardRef((_ref, ref) => {
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
-
790
+ const _excluded = ["menuItems", "onMenuClick", "downloadFiles", "upgradeExecute", "upgradeStatus", "acceptFileTypes", "uploadCompleteDelay", "statusPollingInterval", "children"];
1271
791
  const UpgradeManager = _ref => {
1272
792
  let {
1273
- menuItems = [],
1274
- onMenuClick,
1275
- downloadFiles,
1276
- upgradeExecute,
1277
- upgradeStatus,
1278
- acceptFileTypes = "application/octet-stream",
1279
- uploadCompleteDelay = 3000,
1280
- statusPollingInterval = 1000,
1281
- children,
1282
- ...dropdownProps
1283
- } = _ref;
793
+ menuItems = [],
794
+ onMenuClick,
795
+ downloadFiles,
796
+ upgradeExecute,
797
+ upgradeStatus,
798
+ acceptFileTypes = "application/octet-stream",
799
+ uploadCompleteDelay = 3000,
800
+ statusPollingInterval = 1000,
801
+ children
802
+ } = _ref,
803
+ dropdownProps = _objectWithoutProperties(_ref, _excluded);
1284
804
  const [upgradeElement] = useUpgrade$1({
1285
805
  menuItems,
1286
806
  onMenuClick,
@@ -1296,11 +816,9 @@ const UpgradeManager = _ref => {
1296
816
  const dropdownElement = upgradeElement.props.children[0];
1297
817
  const otherElements = upgradeElement.props.children.slice(1);
1298
818
  return /*#__PURE__*/jsxs(Fragment, {
1299
- children: [/*#__PURE__*/jsx(Dropdown, {
1300
- ...dropdownProps,
1301
- ...dropdownElement.props,
819
+ children: [/*#__PURE__*/jsx(Dropdown, _objectSpread2(_objectSpread2(_objectSpread2({}, dropdownProps), dropdownElement.props), {}, {
1302
820
  children: children
1303
- }), otherElements]
821
+ })), otherElements]
1304
822
  });
1305
823
  }
1306
824
 
@@ -2538,7 +2056,7 @@ const SystemOperations = _ref => {
2538
2056
  try {
2539
2057
  AntdModal.confirm({
2540
2058
  icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
2541
- title: `${confirmTitle} ${action}?`,
2059
+ title: "".concat(confirmTitle, " ").concat(action, "?"),
2542
2060
  cancelText,
2543
2061
  okText,
2544
2062
  onOk: () => {
@@ -2555,7 +2073,7 @@ const SystemOperations = _ref => {
2555
2073
  }
2556
2074
  });
2557
2075
  } catch (error) {
2558
- console.error(`${action.toUpperCase()} ERROR: `, error);
2076
+ console.error("".concat(action.toUpperCase(), " ERROR: "), error);
2559
2077
  }
2560
2078
  };
2561
2079
  const handleMenuClick = _ref2 => {
@@ -2696,12 +2214,12 @@ function convertPtpStatusToArray(ptpStatus, fieldConfigs, fieldOrder) {
2696
2214
  formType: 'text'
2697
2215
  };
2698
2216
  const value = ptpStatus[key];
2699
- return {
2217
+ return _objectSpread2(_objectSpread2({
2700
2218
  key,
2701
- value,
2702
- ...config,
2219
+ value
2220
+ }, config), {}, {
2703
2221
  rawData: ptpStatus
2704
- };
2222
+ });
2705
2223
  });
2706
2224
  }
2707
2225
  const PtpModal = _ref => {
@@ -2723,7 +2241,7 @@ const PtpModal = _ref => {
2723
2241
  useEffect(() => {
2724
2242
  if (open) {
2725
2243
  getPtpInfo().then(data => {
2726
- if (data?.[0]) {
2244
+ if (data !== null && data !== void 0 && data[0]) {
2727
2245
  setPtpStatus(data[0]);
2728
2246
  form.setFieldsValue(data[0]);
2729
2247
  }
@@ -2736,8 +2254,7 @@ const PtpModal = _ref => {
2736
2254
  }, [ptpStatus]);
2737
2255
  const handleValueChange = changedValues => {
2738
2256
  if ('t1_domain_number' in changedValues) {
2739
- setPtpStatus(prev => ({
2740
- ...prev,
2257
+ setPtpStatus(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
2741
2258
  t1_domain_number: changedValues.t1_domain_number
2742
2259
  }));
2743
2260
  }
@@ -2757,6 +2274,7 @@ const PtpModal = _ref => {
2757
2274
  }
2758
2275
  };
2759
2276
  const renderFormItem = item => {
2277
+ var _item$statusMap, _item$min, _item$max;
2760
2278
  switch (item.formType) {
2761
2279
  case 'select':
2762
2280
  return /*#__PURE__*/jsx(Select, {
@@ -2767,7 +2285,7 @@ const PtpModal = _ref => {
2767
2285
  return /*#__PURE__*/jsx(Switch, {});
2768
2286
  case 'badge':
2769
2287
  const normalizedValue = typeof item.value === 'boolean' ? item.value ? 1 : 0 : item.value;
2770
- const status = item.statusMap?.[normalizedValue] || {
2288
+ const status = ((_item$statusMap = item.statusMap) === null || _item$statusMap === void 0 ? void 0 : _item$statusMap[normalizedValue]) || {
2771
2289
  text: 'Unknown',
2772
2290
  color: 'gray'
2773
2291
  };
@@ -2789,8 +2307,8 @@ const PtpModal = _ref => {
2789
2307
  disabled: item.readOnly,
2790
2308
  controls: false,
2791
2309
  keyboard: false,
2792
- min: item.min ?? Number.MIN_SAFE_INTEGER,
2793
- max: item.max ?? Number.MAX_SAFE_INTEGER
2310
+ min: (_item$min = item.min) !== null && _item$min !== void 0 ? _item$min : Number.MIN_SAFE_INTEGER,
2311
+ max: (_item$max = item.max) !== null && _item$max !== void 0 ? _item$max : Number.MAX_SAFE_INTEGER
2794
2312
  });
2795
2313
  default:
2796
2314
  return /*#__PURE__*/jsx(Input, {
@@ -2801,19 +2319,18 @@ const PtpModal = _ref => {
2801
2319
  if (!open || !ptpStatus) return null;
2802
2320
 
2803
2321
  // 合并默认模态框属性和传入的属性
2804
- const mergedModalProps = {
2322
+ const mergedModalProps = _objectSpread2({
2805
2323
  title: "PTP",
2806
2324
  width: 650,
2807
2325
  open,
2808
2326
  okText: "Apply",
2809
2327
  cancelText: "Close",
2810
2328
  onCancel: onClose,
2811
- onOk: handleSubmit,
2812
- ...modalProps
2813
- };
2329
+ onOk: handleSubmit
2330
+ }, modalProps);
2814
2331
 
2815
2332
  // 合并默认表单属性和传入的属性
2816
- const mergedFormProps = {
2333
+ const mergedFormProps = _objectSpread2({
2817
2334
  form: form,
2818
2335
  name: "ptpForm",
2819
2336
  labelCol: {
@@ -2823,25 +2340,23 @@ const PtpModal = _ref => {
2823
2340
  span: 16
2824
2341
  },
2825
2342
  autoComplete: "off",
2826
- onValuesChange: handleValueChange,
2827
- ...formProps
2828
- };
2829
- return /*#__PURE__*/jsx(Modal, {
2830
- ...mergedModalProps,
2831
- children: /*#__PURE__*/jsx(Form, {
2832
- ...mergedFormProps,
2343
+ onValuesChange: handleValueChange
2344
+ }, formProps);
2345
+ return /*#__PURE__*/jsx(Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
2346
+ children: /*#__PURE__*/jsx(Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
2833
2347
  children: ptpStatusArray.map(item => /*#__PURE__*/jsx(Form.Item, {
2834
2348
  label: item.label,
2835
2349
  name: item.key,
2836
2350
  initialValue: item.value,
2837
2351
  children: renderFormItem(item)
2838
2352
  }, item.key))
2839
- })
2840
- });
2353
+ }))
2354
+ }));
2841
2355
  };
2842
2356
  var PtpModal$1 = /*#__PURE__*/memo(PtpModal);
2843
2357
 
2844
2358
  const NetworkFieldGroup = _ref => {
2359
+ var _fieldConfig$netmask$, _fieldConfig$netmask;
2845
2360
  let {
2846
2361
  prefix,
2847
2362
  interfaces,
@@ -2862,14 +2377,12 @@ const NetworkFieldGroup = _ref => {
2862
2377
  enabled: true
2863
2378
  }
2864
2379
  };
2865
- const mergedFieldConfig = {
2866
- ...defaultFieldConfig,
2867
- ...fieldConfig,
2380
+ const mergedFieldConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultFieldConfig), fieldConfig), {}, {
2868
2381
  netmask: {
2869
2382
  label: "Netmask",
2870
- enabled: fieldConfig.netmask?.enabled ?? defaultFieldConfig.netmask.enabled // 合并 enabled
2383
+ 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
2384
  }
2872
- };
2385
+ });
2873
2386
  return /*#__PURE__*/jsxs(Fragment, {
2874
2387
  children: [/*#__PURE__*/jsx(Typography.Title, {
2875
2388
  level: 5,
@@ -2940,24 +2453,20 @@ const NetworkSettingsModal = _ref2 => {
2940
2453
  hasInitialized: false
2941
2454
  });
2942
2455
  const preparedFieldConfig = useMemo(() => {
2943
- const config = {
2944
- ...fieldConfig
2945
- };
2456
+ const config = _objectSpread2({}, fieldConfig);
2946
2457
 
2947
2458
  // 确保LAN和QSFP的配置存在
2948
2459
  config.LAN = config.LAN || {};
2949
2460
  config.QSFP = config.QSFP || {};
2950
2461
  if (sections.includes('LAN')) {
2951
- config.LAN.netmask = {
2952
- ...(config.LAN.netmask || {}),
2462
+ config.LAN.netmask = _objectSpread2(_objectSpread2({}, config.LAN.netmask || {}), {}, {
2953
2463
  enabled: showNetmask.LAN
2954
- };
2464
+ });
2955
2465
  }
2956
2466
  if (sections.includes('QSFP')) {
2957
- config.QSFP.netmask = {
2958
- ...(config.QSFP.netmask || {}),
2467
+ config.QSFP.netmask = _objectSpread2(_objectSpread2({}, config.QSFP.netmask || {}), {}, {
2959
2468
  enabled: showNetmask.QSFP
2960
- };
2469
+ });
2961
2470
  }
2962
2471
  return config;
2963
2472
  }, [fieldConfig, showNetmask, sections]);
@@ -3025,28 +2534,23 @@ const NetworkSettingsModal = _ref2 => {
3025
2534
  const initialValues = useMemo(() => {
3026
2535
  const values = {};
3027
2536
  if (sections.includes('LAN') && lanConfigs.length > 0) {
3028
- values.LAN = lanConfigs.map(config => ({
2537
+ values.LAN = lanConfigs.map(config => _objectSpread2({
3029
2538
  connection_id: config.connection_id,
3030
2539
  display_name: config.display_name,
3031
- ip_address: config.ip_address,
3032
- ...(showNetmask.LAN ? {
3033
- netmask: config.netmask
3034
- } : {})
3035
- }));
2540
+ ip_address: config.ip_address
2541
+ }, showNetmask.LAN ? {
2542
+ netmask: config.netmask
2543
+ } : {}));
3036
2544
  }
3037
2545
  if (sections.includes('QSFP') && st2110Interfaces.length > 0) {
3038
- values.QSFP = st2110Interfaces.map(iface => ({
3039
- // 只有当iface中存在id字段时才包含id
3040
- ...(iface.id !== undefined && {
3041
- id: iface.id
3042
- }),
2546
+ values.QSFP = st2110Interfaces.map(iface => _objectSpread2(_objectSpread2({}, iface.id !== undefined && {
2547
+ id: iface.id
2548
+ }), {}, {
3043
2549
  display_name: iface.display_name,
3044
- ip_address: iface.ip_address || iface.ip,
3045
- // 优先取ip_address,没有则取ip
3046
- ...(showNetmask.QSFP ? {
3047
- netmask: iface.netmask
3048
- } : {})
3049
- }));
2550
+ ip_address: iface.ip_address || iface.ip
2551
+ }, showNetmask.QSFP ? {
2552
+ netmask: iface.netmask
2553
+ } : {}));
3050
2554
  }
3051
2555
  return values;
3052
2556
  }, [lanConfigs, st2110Interfaces, sections, showNetmask]);
@@ -3108,32 +2612,32 @@ const NetworkSettingsModal = _ref2 => {
3108
2612
 
3109
2613
  // 更新LAN配置
3110
2614
  if (sections.includes('LAN') && values.LAN) {
3111
- const lanData = values.LAN.map((item, index) => ({
3112
- connection_id: lanConfigs[index]?.connection_id,
3113
- ip_address: item.ip_address,
3114
- ...(showNetmask.LAN ? {
2615
+ const lanData = values.LAN.map((item, index) => {
2616
+ var _lanConfigs$index;
2617
+ return _objectSpread2({
2618
+ connection_id: (_lanConfigs$index = lanConfigs[index]) === null || _lanConfigs$index === void 0 ? void 0 : _lanConfigs$index.connection_id,
2619
+ ip_address: item.ip_address
2620
+ }, showNetmask.LAN ? {
3115
2621
  netmask: item.netmask
3116
- } : {})
3117
- }));
2622
+ } : {});
2623
+ });
3118
2624
  updatePromises.push(updateLanConfig(lanData));
3119
2625
  }
3120
2626
 
3121
2627
  // 更新QSFP配置
3122
2628
  if (sections.includes('QSFP') && values.QSFP) {
3123
- const interfacesData = values.QSFP.map((item, index) => ({
3124
- // 只有当原始数据中存在id时才包含id
3125
- ...(st2110Interfaces?.[index]?.id !== undefined && {
3126
- id: st2110Interfaces?.[index]?.id
3127
- }),
3128
- ...(st2110Interfaces?.[index]?.ip !== undefined ? {
2629
+ const interfacesData = values.QSFP.map((item, index) => {
2630
+ var _st2110Interfaces$ind, _st2110Interfaces$ind2, _st2110Interfaces$ind3;
2631
+ return _objectSpread2(_objectSpread2(_objectSpread2({}, (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind = st2110Interfaces[index]) === null || _st2110Interfaces$ind === void 0 ? void 0 : _st2110Interfaces$ind.id) !== undefined && {
2632
+ id: st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind2 = st2110Interfaces[index]) === null || _st2110Interfaces$ind2 === void 0 ? void 0 : _st2110Interfaces$ind2.id
2633
+ }), (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind3 = st2110Interfaces[index]) === null || _st2110Interfaces$ind3 === void 0 ? void 0 : _st2110Interfaces$ind3.ip) !== undefined ? {
3129
2634
  ip: item.ip_address
3130
2635
  } : {
3131
2636
  ip_address: item.ip_address
3132
- }),
3133
- ...(showNetmask.QSFP ? {
2637
+ }), showNetmask.QSFP ? {
3134
2638
  netmask: item.netmask
3135
- } : {})
3136
- }));
2639
+ } : {});
2640
+ });
3137
2641
  const st2110Data = st2110Interfaces.some(iface => 'id' in iface) ? {
3138
2642
  st2110_interfaces: interfacesData
3139
2643
  } : {
@@ -3159,7 +2663,7 @@ const NetworkSettingsModal = _ref2 => {
3159
2663
  }, [form, sections, lanConfigs, st2110Interfaces, updateLanConfig, updateSysConfig, handleSuccess, message]);
3160
2664
 
3161
2665
  // 合并默认模态框属性和传入的属性
3162
- const mergedModalProps = {
2666
+ const mergedModalProps = _objectSpread2({
3163
2667
  title: "Network Settings",
3164
2668
  width: 650,
3165
2669
  open,
@@ -3169,21 +2673,19 @@ const NetworkSettingsModal = _ref2 => {
3169
2673
  okText: "Apply",
3170
2674
  cancelText: "Close",
3171
2675
  centered: true,
3172
- styles: {
2676
+ styles: _objectSpread2({
3173
2677
  body: {
3174
2678
  padding: "16px 24px 8px 24px"
3175
- },
3176
- ...(restartRemark !== null && {
3177
- footer: {
3178
- paddingBottom: 28
3179
- }
3180
- })
3181
- },
3182
- ...modalProps
3183
- };
2679
+ }
2680
+ }, restartRemark !== null && {
2681
+ footer: {
2682
+ paddingBottom: 28
2683
+ }
2684
+ })
2685
+ }, modalProps);
3184
2686
 
3185
2687
  // 合并默认表单属性和传入的属性
3186
- const mergedFormProps = {
2688
+ const mergedFormProps = _objectSpread2({
3187
2689
  form: form,
3188
2690
  labelCol: {
3189
2691
  span: 6
@@ -3191,13 +2693,10 @@ const NetworkSettingsModal = _ref2 => {
3191
2693
  wrapperCol: {
3192
2694
  span: 18
3193
2695
  },
3194
- autoComplete: "off",
3195
- ...formProps
3196
- };
3197
- return /*#__PURE__*/jsxs(Modal, {
3198
- ...mergedModalProps,
3199
- children: [/*#__PURE__*/jsxs(Form, {
3200
- ...mergedFormProps,
2696
+ autoComplete: "off"
2697
+ }, formProps);
2698
+ return /*#__PURE__*/jsxs(Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
2699
+ children: [/*#__PURE__*/jsxs(Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
3201
2700
  children: [sections.includes('LAN') && lanConfigs.length > 0 && /*#__PURE__*/jsxs(Fragment, {
3202
2701
  children: [/*#__PURE__*/jsx(NetworkFieldGroup, {
3203
2702
  prefix: "LAN",
@@ -3209,8 +2708,8 @@ const NetworkSettingsModal = _ref2 => {
3209
2708
  interfaces: st2110Interfaces,
3210
2709
  fieldConfig: preparedFieldConfig.QSFP
3211
2710
  })]
3212
- }), restartRemark]
3213
- });
2711
+ })), restartRemark]
2712
+ }));
3214
2713
  };
3215
2714
  var NetworkSettingsModal$1 = /*#__PURE__*/memo(NetworkSettingsModal);
3216
2715
 
@@ -3236,7 +2735,7 @@ const LeftList = /*#__PURE__*/memo(_ref => {
3236
2735
  className: "list-container",
3237
2736
  children: /*#__PURE__*/jsx(List, {
3238
2737
  header: /*#__PURE__*/jsxs("div", {
3239
- className: `grid ${gridColumns} w-full list-header`,
2738
+ className: "grid ".concat(gridColumns, " w-full list-header"),
3240
2739
  children: [/*#__PURE__*/jsx("div", {
3241
2740
  children: "Name"
3242
2741
  }), /*#__PURE__*/jsx("div", {
@@ -3248,13 +2747,13 @@ const LeftList = /*#__PURE__*/memo(_ref => {
3248
2747
  dataSource: dataSource,
3249
2748
  rowKey: "id",
3250
2749
  renderItem: item => /*#__PURE__*/jsx(List.Item, {
3251
- className: `list-item ${selectedPresetId === item.id ? 'selected' : ''}`,
2750
+ className: "list-item ".concat(selectedPresetId === item.id ? 'selected' : ''),
3252
2751
  style: {
3253
2752
  padding: "9px 24px"
3254
2753
  },
3255
2754
  onClick: () => onSelectPreset(item),
3256
2755
  children: /*#__PURE__*/jsxs("div", {
3257
- className: `grid ${gridColumns} w-full text-text-normal`,
2756
+ className: "grid ".concat(gridColumns, " w-full text-text-normal"),
3258
2757
  children: [/*#__PURE__*/jsx("div", {
3259
2758
  title: item.name,
3260
2759
  children: item.name || "Untitled Preset"
@@ -3371,10 +2870,9 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
3371
2870
  return fields.category_list.options.map(category => {
3372
2871
  const isInitiallySelected = initialSelected.includes(category.name);
3373
2872
  const shouldDisable = isEditing ? !isInitiallySelected : false;
3374
- return {
3375
- ...category,
2873
+ return _objectSpread2(_objectSpread2({}, category), {}, {
3376
2874
  disabled: shouldDisable
3377
- };
2875
+ });
3378
2876
  });
3379
2877
  }, [initialSelected, isEditing, hasCategoryList, fields.category_list]);
3380
2878
  return /*#__PURE__*/jsxs(Flex, {
@@ -3433,13 +2931,13 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
3433
2931
  disabled: isEditing
3434
2932
  })
3435
2933
  })]
3436
- }), isEditing ? /*#__PURE__*/jsx(SubmitButton, {
3437
- action: onLoad,
3438
- ...(hasCategoryList && {
3439
- disabled: !currentSelected.length
3440
- }),
2934
+ }), isEditing ? /*#__PURE__*/jsx(SubmitButton, _objectSpread2(_objectSpread2({
2935
+ action: onLoad
2936
+ }, hasCategoryList && {
2937
+ disabled: !currentSelected.length
2938
+ }), {}, {
3441
2939
  children: texts.loadButton
3442
- }) : /*#__PURE__*/jsx(SubmitButton, {
2940
+ })) : /*#__PURE__*/jsx(SubmitButton, {
3443
2941
  action: onSave,
3444
2942
  loading: isLoading,
3445
2943
  children: texts.saveButton
@@ -3497,7 +2995,7 @@ const Preset = _ref => {
3497
2995
  const fetchPresetList = useCallback(async () => {
3498
2996
  try {
3499
2997
  const data = await getPresetList();
3500
- const presets = data?.preset_list || data || [];
2998
+ const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
3501
2999
  setPresetList(presets);
3502
3000
  } catch (error) {
3503
3001
  console.error('Failed to fetch preset list:', error);
@@ -3509,6 +3007,7 @@ const Preset = _ref => {
3509
3007
  // setPresetChanged(prev => prev + 1); // 触发更新
3510
3008
  }, [form]);
3511
3009
  const handleAddNew = useCallback(() => {
3010
+ var _fields$category_list;
3512
3011
  const unsavedPreset = presetList.find(item => !item.id);
3513
3012
  if (unsavedPreset) {
3514
3013
  AntdMessage.warning('Existing unsaved preset detected.');
@@ -3522,7 +3021,7 @@ const Preset = _ref => {
3522
3021
  }, {});
3523
3022
 
3524
3023
  // 特殊处理 category_list
3525
- if (fields.category_list?.options) {
3024
+ if ((_fields$category_list = fields.category_list) !== null && _fields$category_list !== void 0 && _fields$category_list.options) {
3526
3025
  newPreset.category_list = fields.category_list.options.map(item => item.name);
3527
3026
  }
3528
3027
  setPresetList([...presetList, newPreset]);
@@ -3538,7 +3037,7 @@ const Preset = _ref => {
3538
3037
  try {
3539
3038
  AntdModal.confirm({
3540
3039
  icon: /*#__PURE__*/jsx(ExclamationCircleFilled, {}),
3541
- title: `${texts.deleteConfirm} "${presetName}"?`,
3040
+ title: "".concat(texts.deleteConfirm, " \"").concat(presetName, "\"?"),
3542
3041
  cancelText: 'No',
3543
3042
  okText: 'Yes',
3544
3043
  onOk: async () => {
@@ -3563,7 +3062,7 @@ const Preset = _ref => {
3563
3062
  }
3564
3063
  }, [selectedPreset, form, AntdModal, AntdMessage, fetchPresetList, texts]);
3565
3064
  const handleLoadPreset = useCallback(async () => {
3566
- if (!selectedPreset?.id) return;
3065
+ if (!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id)) return;
3567
3066
 
3568
3067
  // 显示加载模态框
3569
3068
  const modalInstance = Modal.info({
@@ -3580,12 +3079,11 @@ const Preset = _ref => {
3580
3079
  }
3581
3080
  });
3582
3081
  try {
3583
- await loadPreset({
3584
- id: selectedPreset.id,
3585
- ...(selectedPreset.category_list && {
3586
- category_list: selectedPreset.category_list
3587
- })
3588
- });
3082
+ await loadPreset(_objectSpread2({
3083
+ id: selectedPreset.id
3084
+ }, selectedPreset.category_list && {
3085
+ category_list: selectedPreset.category_list
3086
+ }));
3589
3087
  // 成功时延迟关闭
3590
3088
  setTimeout(() => {
3591
3089
  modalInstance.destroy();
@@ -3624,13 +3122,13 @@ const Preset = _ref => {
3624
3122
  title: texts.title,
3625
3123
  width: width,
3626
3124
  open: open,
3627
- wrapClassName: `preset-management ${className}`,
3125
+ wrapClassName: "preset-management ".concat(className),
3628
3126
  footer: null,
3629
3127
  onCancel: onClose,
3630
3128
  centered: true,
3631
3129
  styles: {
3632
3130
  body: {
3633
- height: `${height}px`
3131
+ height: "".concat(height, "px")
3634
3132
  }
3635
3133
  },
3636
3134
  children: /*#__PURE__*/jsxs(Row, {
@@ -3641,7 +3139,7 @@ const Preset = _ref => {
3641
3139
  className: "h-full",
3642
3140
  children: /*#__PURE__*/jsx(LeftList, {
3643
3141
  dataSource: presetList,
3644
- selectedPresetId: selectedPreset?.id,
3142
+ selectedPresetId: selectedPreset === null || selectedPreset === void 0 ? void 0 : selectedPreset.id,
3645
3143
  onSelectPreset: handleSelectPreset,
3646
3144
  onAddNew: handleAddNew,
3647
3145
  onRemove: handleRemove,
@@ -3660,7 +3158,7 @@ const Preset = _ref => {
3660
3158
  onSave: handleSave,
3661
3159
  onLoad: handleLoadPreset,
3662
3160
  isLoading: loading,
3663
- isEditing: !!selectedPreset?.id,
3161
+ isEditing: !!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id),
3664
3162
  fields: fields,
3665
3163
  texts: {
3666
3164
  loadButton: texts.loadButton,
@@ -3683,5 +3181,5 @@ const Preset = _ref => {
3683
3181
  };
3684
3182
  var PresetModal = /*#__PURE__*/memo(Preset);
3685
3183
 
3686
- export { AuthorizationModal$1 as AuthorizationModal, NetworkSettingsModal$1 as NetworkSettingsModal, PresetModal, PtpModal$1 as PtpModal, SystemOperations$1 as SystemOperations, UpgradeManager$1 as UpgradeManager, useAuth, useDirectoryTree$1 as useDirectoryTree, useHardwareUsage$1 as useHardwareUsage, useHardwareWebSocket$1 as useHardwareWebSocket, useSystemOperations$1 as useSystemOperations, useUpgrade$1 as useUpgrade };
3184
+ 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, useHardwareWebSocket$1 as useHardwareWebSocket, useSystemOperations$1 as useSystemOperations, useUpgrade$1 as useUpgrade };
3687
3185
  //# sourceMappingURL=index.esm.js.map