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.js CHANGED
@@ -7,6 +7,70 @@ var jsxRuntime = require('react/jsx-runtime');
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
+
10
74
  const useHardwareWebSocket = socketUrl => {
11
75
  // cpu_percent cpu使用率
12
76
  // cpu_freq.current cpu频率
@@ -24,9 +88,7 @@ const useHardwareWebSocket = socketUrl => {
24
88
  const handleMessage = react.useCallback(message => {
25
89
  try {
26
90
  if (message) {
27
- setSystemStatus(prev => ({
28
- ...prev,
29
- ...message,
91
+ setSystemStatus(prev => _objectSpread2(_objectSpread2(_objectSpread2({}, prev), message), {}, {
30
92
  lastUpdated: Date.now() // 添加更新时间戳
31
93
  }));
32
94
  }
@@ -37,7 +99,7 @@ const useHardwareWebSocket = socketUrl => {
37
99
 
38
100
  // 监听消息 如果latestMessage变化,说明有新消息
39
101
  react.useEffect(() => {
40
- if (!latestMessage?.data) return;
102
+ if (!(latestMessage !== null && latestMessage !== void 0 && latestMessage.data)) return;
41
103
  try {
42
104
  const parsedMessage = JSON.parse(latestMessage.data);
43
105
  handleMessage(parsedMessage);
@@ -45,7 +107,7 @@ const useHardwareWebSocket = socketUrl => {
45
107
  console.error('Message parsing error:', error);
46
108
  console.debug('Raw message:', latestMessage.data);
47
109
  }
48
- }, [latestMessage?.data, handleMessage]);
110
+ }, [latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.data, handleMessage]);
49
111
  return {
50
112
  ps_status: systemStatus
51
113
  };
@@ -80,7 +142,7 @@ const UsageItem = /*#__PURE__*/react.memo(_ref => {
80
142
  children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
81
143
  size: 4,
82
144
  children: [/*#__PURE__*/jsxRuntime.jsx("i", {
83
- className: `iconfont ${iconClass} text-xl`
145
+ className: "iconfont ".concat(iconClass, " text-xl")
84
146
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
85
147
  className: "inline-block w-10 text-center",
86
148
  children: children
@@ -92,7 +154,10 @@ var UsageItem$1 = UsageItem;
92
154
 
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, '℃'));
@@ -214,7 +279,7 @@ const AuthorizationModal = _ref => {
214
279
  onOk(trimmedCode);
215
280
  };
216
281
  const statusAlert = isActivated ? /*#__PURE__*/jsxRuntime.jsx(antd.Alert, {
217
- message: `${statusMessage}, will expire on ${expiresTime}`,
282
+ message: "".concat(statusMessage, ", will expire on ").concat(expiresTime),
218
283
  type: "success",
219
284
  showIcon: true
220
285
  }) : /*#__PURE__*/jsxRuntime.jsx(antd.Alert, {
@@ -303,7 +368,7 @@ const useAuth = options => {
303
368
  try {
304
369
  setLoading(true);
305
370
  const result = await fetchAuthInfo();
306
- if (result?.commands) {
371
+ if (result !== null && result !== void 0 && result.commands) {
307
372
  const commands = result.commands;
308
373
  setAuthData(commands);
309
374
  setIsRegistered(commands.accredit_status);
@@ -329,10 +394,10 @@ const useAuth = options => {
329
394
  license_data: code
330
395
  }
331
396
  });
332
- if (result?.commands) {
397
+ if (result !== null && result !== void 0 && result.commands) {
333
398
  const commands = result.commands;
334
399
  // type accredit_message
335
- if (commands?.accredit_status) {
400
+ if (commands !== null && commands !== void 0 && commands.accredit_status) {
336
401
  setIsRegistered(true);
337
402
  setAuthData(commands);
338
403
  closeModal();
@@ -459,7 +524,7 @@ const useUpgrade = _ref => {
459
524
  if (onMenuClick) {
460
525
  onMenuClick(key);
461
526
  } else {
462
- console.warn(`Unknown menu key: ${key} and no onMenuClick provided`);
527
+ console.warn("Unknown menu key: ".concat(key, " and no onMenuClick provided"));
463
528
  }
464
529
  }
465
530
  };
@@ -472,7 +537,7 @@ const useUpgrade = _ref => {
472
537
  try {
473
538
  const res = await downloadFiles();
474
539
  if (res.status !== 200) {
475
- throw new Error(`Unexpected status code: ${res.status}`);
540
+ throw new Error("Unexpected status code: ".concat(res.status));
476
541
  }
477
542
 
478
543
  // 默认值,兼容接口响应头没有定义文件名
@@ -482,7 +547,7 @@ const useUpgrade = _ref => {
482
547
  // 获取接口响应的content-disposition字段值,以便获取到文件名
483
548
  if (contentDisposition) {
484
549
  const filenameMatch = contentDisposition.match(/filename\s*=\s*"?([^";]+)"?/i);
485
- if (filenameMatch?.[1]) {
550
+ if (filenameMatch !== null && filenameMatch !== void 0 && filenameMatch[1]) {
486
551
  fileName = decodeURIComponent(filenameMatch[1]); // 处理编码后的文件名(如 %20 转空格)
487
552
  }
488
553
  }
@@ -511,7 +576,7 @@ const useUpgrade = _ref => {
511
576
  }
512
577
  };
513
578
  const onUpload = () => {
514
- if (inputRef?.current) {
579
+ if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
515
580
  inputRef.current.click();
516
581
  }
517
582
  };
@@ -522,7 +587,8 @@ const useUpgrade = _ref => {
522
587
  return;
523
588
  }
524
589
  try {
525
- const file = event.target.files?.[0];
590
+ var _event$target$files;
591
+ const file = (_event$target$files = event.target.files) === null || _event$target$files === void 0 ? void 0 : _event$target$files[0];
526
592
  if (!file) return;
527
593
  showLoader();
528
594
  setCurrentStatus('Uploading...');
@@ -570,7 +636,7 @@ const useUpgrade = _ref => {
570
636
  const response = await upgradeStatus({
571
637
  cancelToken: statusCancelToken.current.token
572
638
  });
573
- if (response?.status === 200) {
639
+ if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
574
640
  const {
575
641
  code,
576
642
  message: statusMessage
@@ -658,7 +724,7 @@ const useUpgrade = _ref => {
658
724
  },
659
725
  spin: true
660
726
  }),
661
- tip: currentStatus === "Uploading..." ? `${currentStatus} ${uploadProgress}%` : currentStatus,
727
+ tip: currentStatus === "Uploading..." ? "".concat(currentStatus, " ").concat(uploadProgress, "%") : currentStatus,
662
728
  size: "large",
663
729
  fullscreen: true
664
730
  })]
@@ -683,7 +749,7 @@ const useSystemOperations = function () {
683
749
  try {
684
750
  AntdModal.confirm({
685
751
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ExclamationCircleFilled, {}),
686
- title: `${confirmTitle} ${action}?`,
752
+ title: "".concat(confirmTitle, " ").concat(action, "?"),
687
753
  cancelText,
688
754
  okText,
689
755
  onOk: () => {
@@ -700,7 +766,7 @@ const useSystemOperations = function () {
700
766
  }
701
767
  });
702
768
  } catch (error) {
703
- console.error(`${action.toUpperCase()} ERROR: `, error);
769
+ console.error("".concat(action.toUpperCase(), " ERROR: "), error);
704
770
  }
705
771
  }, [AntdModal, confirmTitle, cancelText, okText, onPowerOff, onRestart]);
706
772
  const getMenuItems = react.useCallback(() => [{
@@ -723,566 +789,20 @@ const useSystemOperations = function () {
723
789
  };
724
790
  var useSystemOperations$1 = useSystemOperations;
725
791
 
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
-
792
+ const _excluded = ["menuItems", "onMenuClick", "downloadFiles", "upgradeExecute", "upgradeStatus", "acceptFileTypes", "uploadCompleteDelay", "statusPollingInterval", "children"];
1273
793
  const UpgradeManager = _ref => {
1274
794
  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;
795
+ menuItems = [],
796
+ onMenuClick,
797
+ downloadFiles,
798
+ upgradeExecute,
799
+ upgradeStatus,
800
+ acceptFileTypes = "application/octet-stream",
801
+ uploadCompleteDelay = 3000,
802
+ statusPollingInterval = 1000,
803
+ children
804
+ } = _ref,
805
+ dropdownProps = _objectWithoutProperties(_ref, _excluded);
1286
806
  const [upgradeElement] = useUpgrade$1({
1287
807
  menuItems,
1288
808
  onMenuClick,
@@ -1298,11 +818,9 @@ const UpgradeManager = _ref => {
1298
818
  const dropdownElement = upgradeElement.props.children[0];
1299
819
  const otherElements = upgradeElement.props.children.slice(1);
1300
820
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1301
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, {
1302
- ...dropdownProps,
1303
- ...dropdownElement.props,
821
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, _objectSpread2(_objectSpread2(_objectSpread2({}, dropdownProps), dropdownElement.props), {}, {
1304
822
  children: children
1305
- }), otherElements]
823
+ })), otherElements]
1306
824
  });
1307
825
  }
1308
826
 
@@ -2540,7 +2058,7 @@ const SystemOperations = _ref => {
2540
2058
  try {
2541
2059
  AntdModal.confirm({
2542
2060
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ExclamationCircleFilled, {}),
2543
- title: `${confirmTitle} ${action}?`,
2061
+ title: "".concat(confirmTitle, " ").concat(action, "?"),
2544
2062
  cancelText,
2545
2063
  okText,
2546
2064
  onOk: () => {
@@ -2557,7 +2075,7 @@ const SystemOperations = _ref => {
2557
2075
  }
2558
2076
  });
2559
2077
  } catch (error) {
2560
- console.error(`${action.toUpperCase()} ERROR: `, error);
2078
+ console.error("".concat(action.toUpperCase(), " ERROR: "), error);
2561
2079
  }
2562
2080
  };
2563
2081
  const handleMenuClick = _ref2 => {
@@ -2698,12 +2216,12 @@ function convertPtpStatusToArray(ptpStatus, fieldConfigs, fieldOrder) {
2698
2216
  formType: 'text'
2699
2217
  };
2700
2218
  const value = ptpStatus[key];
2701
- return {
2219
+ return _objectSpread2(_objectSpread2({
2702
2220
  key,
2703
- value,
2704
- ...config,
2221
+ value
2222
+ }, config), {}, {
2705
2223
  rawData: ptpStatus
2706
- };
2224
+ });
2707
2225
  });
2708
2226
  }
2709
2227
  const PtpModal = _ref => {
@@ -2725,7 +2243,7 @@ const PtpModal = _ref => {
2725
2243
  react.useEffect(() => {
2726
2244
  if (open) {
2727
2245
  getPtpInfo().then(data => {
2728
- if (data?.[0]) {
2246
+ if (data !== null && data !== void 0 && data[0]) {
2729
2247
  setPtpStatus(data[0]);
2730
2248
  form.setFieldsValue(data[0]);
2731
2249
  }
@@ -2738,8 +2256,7 @@ const PtpModal = _ref => {
2738
2256
  }, [ptpStatus]);
2739
2257
  const handleValueChange = changedValues => {
2740
2258
  if ('t1_domain_number' in changedValues) {
2741
- setPtpStatus(prev => ({
2742
- ...prev,
2259
+ setPtpStatus(prev => _objectSpread2(_objectSpread2({}, prev), {}, {
2743
2260
  t1_domain_number: changedValues.t1_domain_number
2744
2261
  }));
2745
2262
  }
@@ -2759,6 +2276,7 @@ const PtpModal = _ref => {
2759
2276
  }
2760
2277
  };
2761
2278
  const renderFormItem = item => {
2279
+ var _item$statusMap, _item$min, _item$max;
2762
2280
  switch (item.formType) {
2763
2281
  case 'select':
2764
2282
  return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
@@ -2769,7 +2287,7 @@ const PtpModal = _ref => {
2769
2287
  return /*#__PURE__*/jsxRuntime.jsx(antd.Switch, {});
2770
2288
  case 'badge':
2771
2289
  const normalizedValue = typeof item.value === 'boolean' ? item.value ? 1 : 0 : item.value;
2772
- const status = item.statusMap?.[normalizedValue] || {
2290
+ const status = ((_item$statusMap = item.statusMap) === null || _item$statusMap === void 0 ? void 0 : _item$statusMap[normalizedValue]) || {
2773
2291
  text: 'Unknown',
2774
2292
  color: 'gray'
2775
2293
  };
@@ -2791,8 +2309,8 @@ const PtpModal = _ref => {
2791
2309
  disabled: item.readOnly,
2792
2310
  controls: false,
2793
2311
  keyboard: false,
2794
- min: item.min ?? Number.MIN_SAFE_INTEGER,
2795
- max: item.max ?? Number.MAX_SAFE_INTEGER
2312
+ min: (_item$min = item.min) !== null && _item$min !== void 0 ? _item$min : Number.MIN_SAFE_INTEGER,
2313
+ max: (_item$max = item.max) !== null && _item$max !== void 0 ? _item$max : Number.MAX_SAFE_INTEGER
2796
2314
  });
2797
2315
  default:
2798
2316
  return /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
@@ -2803,19 +2321,18 @@ const PtpModal = _ref => {
2803
2321
  if (!open || !ptpStatus) return null;
2804
2322
 
2805
2323
  // 合并默认模态框属性和传入的属性
2806
- const mergedModalProps = {
2324
+ const mergedModalProps = _objectSpread2({
2807
2325
  title: "PTP",
2808
2326
  width: 650,
2809
2327
  open,
2810
2328
  okText: "Apply",
2811
2329
  cancelText: "Close",
2812
2330
  onCancel: onClose,
2813
- onOk: handleSubmit,
2814
- ...modalProps
2815
- };
2331
+ onOk: handleSubmit
2332
+ }, modalProps);
2816
2333
 
2817
2334
  // 合并默认表单属性和传入的属性
2818
- const mergedFormProps = {
2335
+ const mergedFormProps = _objectSpread2({
2819
2336
  form: form,
2820
2337
  name: "ptpForm",
2821
2338
  labelCol: {
@@ -2825,25 +2342,23 @@ const PtpModal = _ref => {
2825
2342
  span: 16
2826
2343
  },
2827
2344
  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,
2345
+ onValuesChange: handleValueChange
2346
+ }, formProps);
2347
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
2348
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
2835
2349
  children: ptpStatusArray.map(item => /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
2836
2350
  label: item.label,
2837
2351
  name: item.key,
2838
2352
  initialValue: item.value,
2839
2353
  children: renderFormItem(item)
2840
2354
  }, item.key))
2841
- })
2842
- });
2355
+ }))
2356
+ }));
2843
2357
  };
2844
2358
  var PtpModal$1 = /*#__PURE__*/react.memo(PtpModal);
2845
2359
 
2846
2360
  const NetworkFieldGroup = _ref => {
2361
+ var _fieldConfig$netmask$, _fieldConfig$netmask;
2847
2362
  let {
2848
2363
  prefix,
2849
2364
  interfaces,
@@ -2864,14 +2379,12 @@ const NetworkFieldGroup = _ref => {
2864
2379
  enabled: true
2865
2380
  }
2866
2381
  };
2867
- const mergedFieldConfig = {
2868
- ...defaultFieldConfig,
2869
- ...fieldConfig,
2382
+ const mergedFieldConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultFieldConfig), fieldConfig), {}, {
2870
2383
  netmask: {
2871
2384
  label: "Netmask",
2872
- enabled: fieldConfig.netmask?.enabled ?? defaultFieldConfig.netmask.enabled // 合并 enabled
2385
+ 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
2386
  }
2874
- };
2387
+ });
2875
2388
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2876
2389
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Typography.Title, {
2877
2390
  level: 5,
@@ -2942,24 +2455,20 @@ const NetworkSettingsModal = _ref2 => {
2942
2455
  hasInitialized: false
2943
2456
  });
2944
2457
  const preparedFieldConfig = react.useMemo(() => {
2945
- const config = {
2946
- ...fieldConfig
2947
- };
2458
+ const config = _objectSpread2({}, fieldConfig);
2948
2459
 
2949
2460
  // 确保LAN和QSFP的配置存在
2950
2461
  config.LAN = config.LAN || {};
2951
2462
  config.QSFP = config.QSFP || {};
2952
2463
  if (sections.includes('LAN')) {
2953
- config.LAN.netmask = {
2954
- ...(config.LAN.netmask || {}),
2464
+ config.LAN.netmask = _objectSpread2(_objectSpread2({}, config.LAN.netmask || {}), {}, {
2955
2465
  enabled: showNetmask.LAN
2956
- };
2466
+ });
2957
2467
  }
2958
2468
  if (sections.includes('QSFP')) {
2959
- config.QSFP.netmask = {
2960
- ...(config.QSFP.netmask || {}),
2469
+ config.QSFP.netmask = _objectSpread2(_objectSpread2({}, config.QSFP.netmask || {}), {}, {
2961
2470
  enabled: showNetmask.QSFP
2962
- };
2471
+ });
2963
2472
  }
2964
2473
  return config;
2965
2474
  }, [fieldConfig, showNetmask, sections]);
@@ -3027,28 +2536,23 @@ const NetworkSettingsModal = _ref2 => {
3027
2536
  const initialValues = react.useMemo(() => {
3028
2537
  const values = {};
3029
2538
  if (sections.includes('LAN') && lanConfigs.length > 0) {
3030
- values.LAN = lanConfigs.map(config => ({
2539
+ values.LAN = lanConfigs.map(config => _objectSpread2({
3031
2540
  connection_id: config.connection_id,
3032
2541
  display_name: config.display_name,
3033
- ip_address: config.ip_address,
3034
- ...(showNetmask.LAN ? {
3035
- netmask: config.netmask
3036
- } : {})
3037
- }));
2542
+ ip_address: config.ip_address
2543
+ }, showNetmask.LAN ? {
2544
+ netmask: config.netmask
2545
+ } : {}));
3038
2546
  }
3039
2547
  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
- }),
2548
+ values.QSFP = st2110Interfaces.map(iface => _objectSpread2(_objectSpread2({}, iface.id !== undefined && {
2549
+ id: iface.id
2550
+ }), {}, {
3045
2551
  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
- }));
2552
+ ip_address: iface.ip_address || iface.ip
2553
+ }, showNetmask.QSFP ? {
2554
+ netmask: iface.netmask
2555
+ } : {}));
3052
2556
  }
3053
2557
  return values;
3054
2558
  }, [lanConfigs, st2110Interfaces, sections, showNetmask]);
@@ -3110,32 +2614,32 @@ const NetworkSettingsModal = _ref2 => {
3110
2614
 
3111
2615
  // 更新LAN配置
3112
2616
  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 ? {
2617
+ const lanData = values.LAN.map((item, index) => {
2618
+ var _lanConfigs$index;
2619
+ return _objectSpread2({
2620
+ connection_id: (_lanConfigs$index = lanConfigs[index]) === null || _lanConfigs$index === void 0 ? void 0 : _lanConfigs$index.connection_id,
2621
+ ip_address: item.ip_address
2622
+ }, showNetmask.LAN ? {
3117
2623
  netmask: item.netmask
3118
- } : {})
3119
- }));
2624
+ } : {});
2625
+ });
3120
2626
  updatePromises.push(updateLanConfig(lanData));
3121
2627
  }
3122
2628
 
3123
2629
  // 更新QSFP配置
3124
2630
  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 ? {
2631
+ const interfacesData = values.QSFP.map((item, index) => {
2632
+ var _st2110Interfaces$ind, _st2110Interfaces$ind2, _st2110Interfaces$ind3;
2633
+ return _objectSpread2(_objectSpread2(_objectSpread2({}, (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind = st2110Interfaces[index]) === null || _st2110Interfaces$ind === void 0 ? void 0 : _st2110Interfaces$ind.id) !== undefined && {
2634
+ id: st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind2 = st2110Interfaces[index]) === null || _st2110Interfaces$ind2 === void 0 ? void 0 : _st2110Interfaces$ind2.id
2635
+ }), (st2110Interfaces === null || st2110Interfaces === void 0 || (_st2110Interfaces$ind3 = st2110Interfaces[index]) === null || _st2110Interfaces$ind3 === void 0 ? void 0 : _st2110Interfaces$ind3.ip) !== undefined ? {
3131
2636
  ip: item.ip_address
3132
2637
  } : {
3133
2638
  ip_address: item.ip_address
3134
- }),
3135
- ...(showNetmask.QSFP ? {
2639
+ }), showNetmask.QSFP ? {
3136
2640
  netmask: item.netmask
3137
- } : {})
3138
- }));
2641
+ } : {});
2642
+ });
3139
2643
  const st2110Data = st2110Interfaces.some(iface => 'id' in iface) ? {
3140
2644
  st2110_interfaces: interfacesData
3141
2645
  } : {
@@ -3161,7 +2665,7 @@ const NetworkSettingsModal = _ref2 => {
3161
2665
  }, [form, sections, lanConfigs, st2110Interfaces, updateLanConfig, updateSysConfig, handleSuccess, message]);
3162
2666
 
3163
2667
  // 合并默认模态框属性和传入的属性
3164
- const mergedModalProps = {
2668
+ const mergedModalProps = _objectSpread2({
3165
2669
  title: "Network Settings",
3166
2670
  width: 650,
3167
2671
  open,
@@ -3171,21 +2675,19 @@ const NetworkSettingsModal = _ref2 => {
3171
2675
  okText: "Apply",
3172
2676
  cancelText: "Close",
3173
2677
  centered: true,
3174
- styles: {
2678
+ styles: _objectSpread2({
3175
2679
  body: {
3176
2680
  padding: "16px 24px 8px 24px"
3177
- },
3178
- ...(restartRemark !== null && {
3179
- footer: {
3180
- paddingBottom: 28
3181
- }
3182
- })
3183
- },
3184
- ...modalProps
3185
- };
2681
+ }
2682
+ }, restartRemark !== null && {
2683
+ footer: {
2684
+ paddingBottom: 28
2685
+ }
2686
+ })
2687
+ }, modalProps);
3186
2688
 
3187
2689
  // 合并默认表单属性和传入的属性
3188
- const mergedFormProps = {
2690
+ const mergedFormProps = _objectSpread2({
3189
2691
  form: form,
3190
2692
  labelCol: {
3191
2693
  span: 6
@@ -3193,13 +2695,10 @@ const NetworkSettingsModal = _ref2 => {
3193
2695
  wrapperCol: {
3194
2696
  span: 18
3195
2697
  },
3196
- autoComplete: "off",
3197
- ...formProps
3198
- };
3199
- return /*#__PURE__*/jsxRuntime.jsxs(antd.Modal, {
3200
- ...mergedModalProps,
3201
- children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Form, {
3202
- ...mergedFormProps,
2698
+ autoComplete: "off"
2699
+ }, formProps);
2700
+ return /*#__PURE__*/jsxRuntime.jsxs(antd.Modal, _objectSpread2(_objectSpread2({}, mergedModalProps), {}, {
2701
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Form, _objectSpread2(_objectSpread2({}, mergedFormProps), {}, {
3203
2702
  children: [sections.includes('LAN') && lanConfigs.length > 0 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3204
2703
  children: [/*#__PURE__*/jsxRuntime.jsx(NetworkFieldGroup, {
3205
2704
  prefix: "LAN",
@@ -3211,8 +2710,8 @@ const NetworkSettingsModal = _ref2 => {
3211
2710
  interfaces: st2110Interfaces,
3212
2711
  fieldConfig: preparedFieldConfig.QSFP
3213
2712
  })]
3214
- }), restartRemark]
3215
- });
2713
+ })), restartRemark]
2714
+ }));
3216
2715
  };
3217
2716
  var NetworkSettingsModal$1 = /*#__PURE__*/react.memo(NetworkSettingsModal);
3218
2717
 
@@ -3238,7 +2737,7 @@ const LeftList = /*#__PURE__*/react.memo(_ref => {
3238
2737
  className: "list-container",
3239
2738
  children: /*#__PURE__*/jsxRuntime.jsx(antd.List, {
3240
2739
  header: /*#__PURE__*/jsxRuntime.jsxs("div", {
3241
- className: `grid ${gridColumns} w-full list-header`,
2740
+ className: "grid ".concat(gridColumns, " w-full list-header"),
3242
2741
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3243
2742
  children: "Name"
3244
2743
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -3250,13 +2749,13 @@ const LeftList = /*#__PURE__*/react.memo(_ref => {
3250
2749
  dataSource: dataSource,
3251
2750
  rowKey: "id",
3252
2751
  renderItem: item => /*#__PURE__*/jsxRuntime.jsx(antd.List.Item, {
3253
- className: `list-item ${selectedPresetId === item.id ? 'selected' : ''}`,
2752
+ className: "list-item ".concat(selectedPresetId === item.id ? 'selected' : ''),
3254
2753
  style: {
3255
2754
  padding: "9px 24px"
3256
2755
  },
3257
2756
  onClick: () => onSelectPreset(item),
3258
2757
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
3259
- className: `grid ${gridColumns} w-full text-text-normal`,
2758
+ className: "grid ".concat(gridColumns, " w-full text-text-normal"),
3260
2759
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3261
2760
  title: item.name,
3262
2761
  children: item.name || "Untitled Preset"
@@ -3373,10 +2872,9 @@ const RightDetailForm = /*#__PURE__*/react.memo(_ref3 => {
3373
2872
  return fields.category_list.options.map(category => {
3374
2873
  const isInitiallySelected = initialSelected.includes(category.name);
3375
2874
  const shouldDisable = isEditing ? !isInitiallySelected : false;
3376
- return {
3377
- ...category,
2875
+ return _objectSpread2(_objectSpread2({}, category), {}, {
3378
2876
  disabled: shouldDisable
3379
- };
2877
+ });
3380
2878
  });
3381
2879
  }, [initialSelected, isEditing, hasCategoryList, fields.category_list]);
3382
2880
  return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
@@ -3435,13 +2933,13 @@ const RightDetailForm = /*#__PURE__*/react.memo(_ref3 => {
3435
2933
  disabled: isEditing
3436
2934
  })
3437
2935
  })]
3438
- }), isEditing ? /*#__PURE__*/jsxRuntime.jsx(SubmitButton, {
3439
- action: onLoad,
3440
- ...(hasCategoryList && {
3441
- disabled: !currentSelected.length
3442
- }),
2936
+ }), isEditing ? /*#__PURE__*/jsxRuntime.jsx(SubmitButton, _objectSpread2(_objectSpread2({
2937
+ action: onLoad
2938
+ }, hasCategoryList && {
2939
+ disabled: !currentSelected.length
2940
+ }), {}, {
3443
2941
  children: texts.loadButton
3444
- }) : /*#__PURE__*/jsxRuntime.jsx(SubmitButton, {
2942
+ })) : /*#__PURE__*/jsxRuntime.jsx(SubmitButton, {
3445
2943
  action: onSave,
3446
2944
  loading: isLoading,
3447
2945
  children: texts.saveButton
@@ -3499,7 +2997,7 @@ const Preset = _ref => {
3499
2997
  const fetchPresetList = react.useCallback(async () => {
3500
2998
  try {
3501
2999
  const data = await getPresetList();
3502
- const presets = data?.preset_list || data || [];
3000
+ const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
3503
3001
  setPresetList(presets);
3504
3002
  } catch (error) {
3505
3003
  console.error('Failed to fetch preset list:', error);
@@ -3511,6 +3009,7 @@ const Preset = _ref => {
3511
3009
  // setPresetChanged(prev => prev + 1); // 触发更新
3512
3010
  }, [form]);
3513
3011
  const handleAddNew = react.useCallback(() => {
3012
+ var _fields$category_list;
3514
3013
  const unsavedPreset = presetList.find(item => !item.id);
3515
3014
  if (unsavedPreset) {
3516
3015
  AntdMessage.warning('Existing unsaved preset detected.');
@@ -3524,7 +3023,7 @@ const Preset = _ref => {
3524
3023
  }, {});
3525
3024
 
3526
3025
  // 特殊处理 category_list
3527
- if (fields.category_list?.options) {
3026
+ if ((_fields$category_list = fields.category_list) !== null && _fields$category_list !== void 0 && _fields$category_list.options) {
3528
3027
  newPreset.category_list = fields.category_list.options.map(item => item.name);
3529
3028
  }
3530
3029
  setPresetList([...presetList, newPreset]);
@@ -3540,7 +3039,7 @@ const Preset = _ref => {
3540
3039
  try {
3541
3040
  AntdModal.confirm({
3542
3041
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ExclamationCircleFilled, {}),
3543
- title: `${texts.deleteConfirm} "${presetName}"?`,
3042
+ title: "".concat(texts.deleteConfirm, " \"").concat(presetName, "\"?"),
3544
3043
  cancelText: 'No',
3545
3044
  okText: 'Yes',
3546
3045
  onOk: async () => {
@@ -3565,7 +3064,7 @@ const Preset = _ref => {
3565
3064
  }
3566
3065
  }, [selectedPreset, form, AntdModal, AntdMessage, fetchPresetList, texts]);
3567
3066
  const handleLoadPreset = react.useCallback(async () => {
3568
- if (!selectedPreset?.id) return;
3067
+ if (!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id)) return;
3569
3068
 
3570
3069
  // 显示加载模态框
3571
3070
  const modalInstance = antd.Modal.info({
@@ -3582,12 +3081,11 @@ const Preset = _ref => {
3582
3081
  }
3583
3082
  });
3584
3083
  try {
3585
- await loadPreset({
3586
- id: selectedPreset.id,
3587
- ...(selectedPreset.category_list && {
3588
- category_list: selectedPreset.category_list
3589
- })
3590
- });
3084
+ await loadPreset(_objectSpread2({
3085
+ id: selectedPreset.id
3086
+ }, selectedPreset.category_list && {
3087
+ category_list: selectedPreset.category_list
3088
+ }));
3591
3089
  // 成功时延迟关闭
3592
3090
  setTimeout(() => {
3593
3091
  modalInstance.destroy();
@@ -3626,13 +3124,13 @@ const Preset = _ref => {
3626
3124
  title: texts.title,
3627
3125
  width: width,
3628
3126
  open: open,
3629
- wrapClassName: `preset-management ${className}`,
3127
+ wrapClassName: "preset-management ".concat(className),
3630
3128
  footer: null,
3631
3129
  onCancel: onClose,
3632
3130
  centered: true,
3633
3131
  styles: {
3634
3132
  body: {
3635
- height: `${height}px`
3133
+ height: "".concat(height, "px")
3636
3134
  }
3637
3135
  },
3638
3136
  children: /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
@@ -3643,7 +3141,7 @@ const Preset = _ref => {
3643
3141
  className: "h-full",
3644
3142
  children: /*#__PURE__*/jsxRuntime.jsx(LeftList, {
3645
3143
  dataSource: presetList,
3646
- selectedPresetId: selectedPreset?.id,
3144
+ selectedPresetId: selectedPreset === null || selectedPreset === void 0 ? void 0 : selectedPreset.id,
3647
3145
  onSelectPreset: handleSelectPreset,
3648
3146
  onAddNew: handleAddNew,
3649
3147
  onRemove: handleRemove,
@@ -3662,7 +3160,7 @@ const Preset = _ref => {
3662
3160
  onSave: handleSave,
3663
3161
  onLoad: handleLoadPreset,
3664
3162
  isLoading: loading,
3665
- isEditing: !!selectedPreset?.id,
3163
+ isEditing: !!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id),
3666
3164
  fields: fields,
3667
3165
  texts: {
3668
3166
  loadButton: texts.loadButton,
@@ -3692,7 +3190,6 @@ exports.PtpModal = PtpModal$1;
3692
3190
  exports.SystemOperations = SystemOperations$1;
3693
3191
  exports.UpgradeManager = UpgradeManager$1;
3694
3192
  exports.useAuth = useAuth;
3695
- exports.useDirectoryTree = useDirectoryTree$1;
3696
3193
  exports.useHardwareUsage = useHardwareUsage$1;
3697
3194
  exports.useHardwareWebSocket = useHardwareWebSocket$1;
3698
3195
  exports.useSystemOperations = useSystemOperations$1;