Talegorithm 2 dní pred
rodič
commit
00b7cc8efb
1 zmenil súbory, kde vykonal 17 pridanie a 1 odobranie
  1. 17 1
      knowhub/server.py

+ 17 - 1
knowhub/server.py

@@ -1584,7 +1584,23 @@ def frontend():
 
             container.innerHTML = list.map(k => {
                 // 确保types是数组
-                const types = Array.isArray(k.types) ? k.types : (typeof k.types === 'string' ? JSON.parse(k.types) : []);
+                let types = [];
+                if (Array.isArray(k.types)) {
+                    types = k.types;
+                } else if (typeof k.types === 'string') {
+                    // 如果是JSON字符串(以[开头),尝试解析
+                    if (k.types.startsWith('[')) {
+                        try {
+                            types = JSON.parse(k.types);
+                        } catch (e) {
+                            console.error('解析types失败:', k.types, e);
+                            types = [k.types];
+                        }
+                    } else {
+                        // 如果是普通字符串,包装成数组
+                        types = [k.types];
+                    }
+                }
                 const eval_data = k.eval || {};
 
                 return `