Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2381,9 +2381,36 @@ <h3 id="exportModalTitle">📦 数据导出</h3>
}
const slotsLeft=needed-locked.length;
if(free.length<slotsLeft){showToast(`任务不足 ${needed} 个,请再添加一些`);return;}
// Shuffle free pool and pick what's needed
for(let i=free.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[free[i],free[j]]=[free[j],free[i]];}
const picked=new Set([...locked,...free.slice(0,slotsLeft)].map(({gi,ti})=>`${gi}_${ti}`));
// Group-based prioritization: prioritize tasks from earlier groups
// 1. Sort free tasks by group index (gi) first
free.sort((a,b)=>a.gi-b.gi);

// 2. For each group, shuffle tasks within the group
let groupedFree=[];
let currentGroup=-1;
let groupTasks=[];

for(const task of free){
if(task.gi!==currentGroup){
if(groupTasks.length>0){
// Shuffle current group tasks
for(let i=groupTasks.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[groupTasks[i],groupTasks[j]]=[groupTasks[j],groupTasks[i]];}
groupedFree.push(...groupTasks);
groupTasks=[];
}
currentGroup=task.gi;
}
groupTasks.push(task);
}

// Add the last group
if(groupTasks.length>0){
for(let i=groupTasks.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[groupTasks[i],groupTasks[j]]=[groupTasks[j],groupTasks[i]];}
groupedFree.push(...groupTasks);
}

// 3. Pick tasks in group priority order
const picked=new Set([...locked,...groupedFree.slice(0,slotsLeft)].map(({gi,ti})=>`${gi}_${ti}`));
for(let gi=0;gi<groups.length;gi++)for(let ti=0;ti<groups[gi].tasks.length;ti++)groups[gi].tasks[ti].active=picked.has(`${gi}_${ti}`);
ls.set(getUserKey('groups'),JSON.stringify(groups));
renderTaskPanel();
Expand Down