Просмотр исходного кода

🐛 fix(channels): resolve type mismatch when copying tested channels

Fix JSON unmarshal error that occurred when copying channels after testing. The JavaScript timestamp (floating point number) in the test_time field was causing type conversion errors in Go backend which expected an int64.

Solution:
- Create deep copy of channel record instead of modifying original
- Remove test_time and response_time fields before sending to backend
- Allow backend to use default values for these fields

Error fixed: "json: cannot unmarshal number into Go struct field Channel.test_time of type int64"
Apple\Apple 9 месяцев назад
Родитель
Сommit
b366bf585c
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      web/src/components/table/ChannelsTable.js

+ 4 - 1
web/src/components/table/ChannelsTable.js

@@ -878,11 +878,14 @@ const ChannelsTable = () => {
   };
 
   const copySelectedChannel = async (record) => {
-    const channelToCopy = record;
+    const channelToCopy = { ...record };
     channelToCopy.name += t('_复制');
     channelToCopy.created_time = null;
     channelToCopy.balance = 0;
     channelToCopy.used_quota = 0;
+    // 删除可能导致类型不匹配的字段
+    delete channelToCopy.test_time;
+    delete channelToCopy.response_time;
     if (!channelToCopy) {
       showError(t('渠道未找到,请刷新页面后重试。'));
       return;