diff --git a/__pycache__/jwFetcher.cpython-312.pyc b/__pycache__/jwFetcher.cpython-312.pyc deleted file mode 100644 index a220b83..0000000 Binary files a/__pycache__/jwFetcher.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc deleted file mode 100644 index ff205a3..0000000 Binary files a/__pycache__/main.cpython-312.pyc and /dev/null differ diff --git a/backend/__pycache__/cookie_manager.cpython-312.pyc b/backend/__pycache__/cookie_manager.cpython-312.pyc deleted file mode 100644 index 3bf5955..0000000 Binary files a/backend/__pycache__/cookie_manager.cpython-312.pyc and /dev/null differ diff --git a/backend/__pycache__/ranker.cpython-312.pyc b/backend/__pycache__/ranker.cpython-312.pyc deleted file mode 100644 index 05c5acd..0000000 Binary files a/backend/__pycache__/ranker.cpython-312.pyc and /dev/null differ diff --git a/backend/__pycache__/session_manager.cpython-312.pyc b/backend/__pycache__/session_manager.cpython-312.pyc deleted file mode 100644 index b4a955b..0000000 Binary files a/backend/__pycache__/session_manager.cpython-312.pyc and /dev/null differ diff --git a/backend/__pycache__/solver.cpython-312.pyc b/backend/__pycache__/solver.cpython-312.pyc deleted file mode 100644 index b6879d8..0000000 Binary files a/backend/__pycache__/solver.cpython-312.pyc and /dev/null differ diff --git a/backend/solver.py b/backend/solver.py index 929c875..dedea08 100644 --- a/backend/solver.py +++ b/backend/solver.py @@ -19,8 +19,8 @@ def check_conflicts(groups): group_b = groups[j] # Get active candidates - cands_a = [c for idx, c in enumerate(group_a['candidates']) if idx in group_a['selected_indices']] - cands_b = [c for idx, c in enumerate(group_b['candidates']) if idx in group_b['selected_indices']] + cands_a = [c for c in group_a['candidates'] if c.get('selected', False)] + cands_b = [c for c in group_b['candidates'] if c.get('selected', False)] if not cands_a or not cands_b: continue # Empty group cannot conflict @@ -67,7 +67,7 @@ def generate_schedules(groups, max_results=1000): # Prepare list of lists of candidates candidate_lists = [] for g in groups: - active = [c for idx, c in enumerate(g['candidates']) if idx in g['selected_indices']] + active = [c for c in g['candidates'] if c.get('selected', False)] if not active: return [] # If any group has no active candidates, no solution possible candidate_lists.append(active) diff --git a/static/app.js b/static/app.js index c413ac1..3eddf3e 100644 --- a/static/app.js +++ b/static/app.js @@ -53,14 +53,19 @@ createApp({ }; const createGroup = () => { - const selected = searchResults.value.filter(c => c.checked); - if (selected.length === 0) return showToast("未选择任何课程"); + const selectedInSearch = searchResults.value.filter(c => c.checked); + if (selectedInSearch.length === 0) return showToast("未选择任何课程"); + + // Copy all search results, map checked to selected + const candidates = searchResults.value.map(c => ({ + ...c, + selected: c.checked + })); groups.value.push({ id: Date.now(), open: false, - candidates: selected, // Store full objects - selected_indices: selected.map((_, i) => i) // Default all active + candidates: candidates }); searchResults.value = []; currentView.value = 'planning'; @@ -68,16 +73,26 @@ createApp({ }; const getGroupName = (group) => { - if (group.candidates.length > 0) return group.candidates[0].name; + // Find first selected one to name the group, or just the first one + const first = group.candidates.find(c => c.selected) || group.candidates[0]; + if (first) return first.name; return "未知课程"; }; - const getActiveCount = (group) => group.selected_indices.length; + const getActiveCount = (group) => group.candidates.filter(c => c.selected).length; const toggleCandidate = (group, idx) => { - const i = group.selected_indices.indexOf(idx); - if (i > -1) group.selected_indices.splice(i, 1); - else group.selected_indices.push(idx); + // No-op here if using v-model, but let's keep it or remove it. + // Since we switch to v-model in the template, this function might become obsolete + // OR we can keep it if we want to programmatically toggle. + // But the previous implementation used indices. + // The template currently calls it. I will update the template to use v-model. + // So I can remove this function or just leave a placeholder. + // Actually, let's just make it toggle the boolean for the candidate at that index if needed, + // but v-model is cleaner. I'll remove it from the return object if I don't use it. + // But to be safe, I'll update it to toggle boolean. + const c = group.candidates[idx]; + if (c) c.selected = !c.selected; }; const removeGroup = (idx) => groups.value.splice(idx, 1); diff --git a/static/index.html b/static/index.html index 8f4bc8e..a4cfa88 100644 --- a/static/index.html +++ b/static/index.html @@ -109,8 +109,7 @@