chengjie 3 月之前
父节点
当前提交
44c95521fb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/api/yjbdc/yjbdcController.js

+ 5 - 0
src/api/yjbdc/yjbdcController.js

@@ -426,11 +426,16 @@ export async function GetYJBDCArticleList(ctx) {
426 426
             // 随机选择三个不重复的索引用于今日推荐
427 427
             
428 428
             if (result.length > 3) {
429
+                let n=0;
429 430
                 while (recommendIndices.length < 3) {
430 431
                     const randomIndex = Math.floor(Math.random() * (result.length - 4)) + 4; // 从第5条开始随机选择
431 432
                     if (!recommendIndices.includes(randomIndex)) {
432 433
                         recommendIndices.push(randomIndex);
433 434
                     }
435
+                    n++;
436
+                    if (n>100000){
437
+                        break;
438
+                    }
434 439
                 }
435 440
 
436 441
             } else {