ui v35: 院校库按专业口径重排(362 所开设 / 545 所未开设矮卡 / 分隔带),默认只看本专业;补记 v34 对比页排序

This commit is contained in:
Your Name committed 2026-11-17 12:55:40 +08:00
1 parent 10e04c05c8
commit 14fd4b7667
61 files changed
+1493 -17

No files matched your search

+103 -17
View File
@@ -446,7 +446,7 @@ body.home-active{--accent:#294b8b;--accent-soft:#eef3fb;--line:#dfe3eb;--mute:#7
.e-subpage .tools select{font-size:10px}.e-count{font-size:12px;margin:12px 0 3px}.e-count b{color:#e15b4b;font-size:18px} .e-subpage .tools select{font-size:10px}.e-count{font-size:12px;margin:12px 0 3px}.e-count b{color:#e15b4b;font-size:18px}
.e-result{display:grid;grid-template-columns:31% minmax(0,1fr);gap:8px;padding:6px;margin-top:8px;border-radius:7px;cursor:default} .e-result{display:grid;grid-template-columns:31% minmax(0,1fr);gap:8px;padding:6px;margin-top:8px;border-radius:7px;cursor:default}
.e-result-photo{min-width:0;min-height:115px;border:0;padding:0;background:transparent;border-radius:5px;overflow:hidden;cursor:pointer}.e-result-photo:focus-visible{outline:2px solid #294b8b;outline-offset:2px}body.dark .e-result-photo:focus-visible{outline-color:#b5cef8}.e-result-photo img,.e-result-photo>.fb{width:100%;height:100%;min-height:115px;object-fit:cover} .e-result-photo{min-width:0;min-height:115px;border:0;padding:0;background:transparent;border-radius:5px;overflow:hidden;cursor:pointer}.e-result-photo:focus-visible{outline:2px solid #294b8b;outline-offset:2px}body.dark .e-result-photo:focus-visible{outline-color:#b5cef8}.e-result-photo img,.e-result-photo>.fb{width:100%;height:100%;min-height:115px;object-fit:cover}
.e-result-body{min-width:0}.e-result-title{display:flex;align-items:center;gap:5px;cursor:pointer}.e-result-title b{font-family:SimSun,serif;font-size:16px;line-height:1.25;overflow-wrap:anywhere}.e-result-title span,.e-result-tags span{font-size:9px;background:#e8eef9;color:#294b8b;border-radius:3px;padding:2px 4px}.e-result-title i{font-style:normal;margin-left:auto;font-size:18px}.e-result-tags{display:flex;gap:3px;margin:4px 0;flex-wrap:wrap}.e-result-tags span{background:#f2f3f5;color:#606570} .e-result-body{min-width:0}.e-result-title{display:flex;align-items:center;gap:5px;cursor:pointer}.e-result-title b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:0 1 auto;font-family:SimSun,serif;font-size:16px;line-height:1.25;overflow-wrap:anywhere}.e-result-title span,.e-result-tags span{font-size:9px;background:#e8eef9;color:#294b8b;border-radius:3px;padding:2px 4px}.e-result-title i{font-style:normal;margin-left:auto;font-size:18px}.e-result-tags{display:flex;gap:3px;margin:4px 0;flex-wrap:wrap}.e-result-tags span{background:#f2f3f5;color:#606570}
.e-result-metrics{display:grid;grid-template-columns:1fr 1fr;background:#fcf3f2;border-radius:5px;padding:5px 7px;cursor:pointer}.e-result-metrics>div+div{border-left:1px solid #e0d8d8;padding-left:7px}.e-result-metrics small{display:block;font-size:9px}.e-result-metrics b{font-size:14px;color:#e15b4b}.e-result-metrics>div+div b{color:#414651} .e-result-metrics{display:grid;grid-template-columns:1fr 1fr;background:#fcf3f2;border-radius:5px;padding:5px 7px;cursor:pointer}.e-result-metrics>div+div{border-left:1px solid #e0d8d8;padding-left:7px}.e-result-metrics small{display:block;font-size:9px}.e-result-metrics b{font-size:14px;color:#e15b4b}.e-result-metrics>div+div b{color:#414651}
.e-result-bottom{display:flex;align-items:center;gap:4px;margin-top:5px}.e-result-bottom span{font-size:9px;color:#737985;flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.e-result-bottom button,.detail-heading button{font-size:9px;white-space:nowrap;color:#294b8b;background:#fff;border:1px solid #bfc8d8;border-radius:4px;padding:4px} .e-result-bottom{display:flex;align-items:center;gap:4px;margin-top:5px}.e-result-bottom span{font-size:9px;color:#737985;flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.e-result-bottom button,.detail-heading button{font-size:9px;white-space:nowrap;color:#294b8b;background:#fff;border:1px solid #bfc8d8;border-radius:4px;padding:4px}
@@ -604,6 +604,22 @@ body.dark .compare-table .cmp-label{color:#e5e9ef}
.compare-selection .compare-chips.fit{flex-wrap:nowrap;overflow-x:auto} .compare-selection .compare-chips.fit{flex-wrap:nowrap;overflow-x:auto}
.compare-selection .compare-chips.fit .compare-chip{flex:none;padding-left:3px;padding-right:3px;font-size:9px} .compare-selection .compare-chips.fit .compare-chip{flex:none;padding-left:3px;padding-right:3px;font-size:9px}
.compare-selection .compare-chips.fit .compare-chip span{white-space:nowrap;overflow-wrap:normal} .compare-selection .compare-chips.fit .compare-chip span{white-space:nowrap;overflow-wrap:normal}
/* v34:对比页「按分差排序」开关与「近 N」徽标 */
.compare-selection>button.cmp-sort{display:inline-flex;align-items:center;gap:3px;padding:4px 6px;font-size:9.5px;color:#5a7196;border-color:#cdd8e9}
.compare-selection>button.cmp-sort .ui-icon{width:11px;height:11px}
.compare-selection>button.cmp-sort.on{background:#e8f0fd;border-color:#7394ca;color:#22417a;font-weight:600}
.compare-table .cmp .col .cmp-near{display:inline-block;margin:3px 0 0;padding:1px 4px;border-radius:4px;background:#eef3fb;color:#5a7196;font-size:9px;font-style:normal;font-weight:400;line-height:1.4;white-space:nowrap}
.compare-table .cmp .col .cmp-near.na{background:transparent;color:var(--mute);padding:0}
.cmp-verdict .cmp-sort-note{color:#5a7196;font-size:10px}
body.dark .compare-selection>button.cmp-sort{background:#22262c;border-color:#434955;color:#b9cbe8}
body.dark .compare-selection>button.cmp-sort.on{background:#2c3b52;border-color:#7394ca;color:#dbe7fb}
body.dark .compare-table .cmp .col .cmp-near{background:#2f3d52;color:#b9cbe8}
body.dark .compare-table .cmp .col .cmp-near.na{background:transparent;color:#8d9db3}
body.dark .cmp-verdict .cmp-sort-note{color:#a9c0dd}
/* 窄屏下把顶部「添加院校」收成 ⊕:表格空列与底部按钮都还有文字入口,省出的宽度留给已选院校名 */
.compare-selection>button.cmp-add-top span{margin-left:2px}
@media(max-width:430px){.compare-selection>button.cmp-add-top span{display:none}.compare-selection>button.cmp-add-top{padding:4px 8px;font-size:12px;line-height:1}}
@media(max-width:380px){.compare-selection>button.cmp-sort .cmp-sort-txt{display:none}.compare-selection>button.cmp-sort{padding:4px 6px}}
.compare-scroll-hint{margin:6px auto 0;color:#566983;font-size:10px;text-align:center;max-width:260px}.compare-scroll-controls{display:flex;align-items:center;gap:8px}.compare-scroll-controls button{width:28px;height:28px;flex:none;border:0;border-radius:50%;background:#eef2f8;color:#294b8b;font-size:20px;line-height:1;cursor:pointer}.compare-scroll-controls button:disabled{opacity:.4;cursor:default}.compare-scroll-controls input{width:100%;min-width:0;accent-color:#7394ca;cursor:pointer}.compare-scroll-hint p{margin:2px 0 0}body.dark .compare-scroll-hint{color:#c2cfe0}body.dark .compare-scroll-controls button{background:#344256;color:#d4e1fa} .compare-scroll-hint{margin:6px auto 0;color:#566983;font-size:10px;text-align:center;max-width:260px}.compare-scroll-controls{display:flex;align-items:center;gap:8px}.compare-scroll-controls button{width:28px;height:28px;flex:none;border:0;border-radius:50%;background:#eef2f8;color:#294b8b;font-size:20px;line-height:1;cursor:pointer}.compare-scroll-controls button:disabled{opacity:.4;cursor:default}.compare-scroll-controls input{width:100%;min-width:0;accent-color:#7394ca;cursor:pointer}.compare-scroll-hint p{margin:2px 0 0}body.dark .compare-scroll-hint{color:#c2cfe0}body.dark .compare-scroll-controls button{background:#344256;color:#d4e1fa}
.compare-scroll-controls input[type=range]{appearance:none;-webkit-appearance:none;height:28px;padding:0;margin:0;border:0;background:transparent} .compare-scroll-controls input[type=range]{appearance:none;-webkit-appearance:none;height:28px;padding:0;margin:0;border:0;background:transparent}
.compare-scroll-controls input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:6px;background:linear-gradient(to right,#91add9 0%,#91add9 var(--scroll-progress,0%),#e4ebf6 var(--scroll-progress,0%),#e4ebf6 100%)} .compare-scroll-controls input[type=range]::-webkit-slider-runnable-track{height:6px;border-radius:6px;background:linear-gradient(to right,#91add9 0%,#91add9 var(--scroll-progress,0%),#e4ebf6 var(--scroll-progress,0%),#e4ebf6 100%)}
@@ -1330,6 +1346,41 @@ body.dark .cmp-verdict p.cmp-verdict-note{color:#a8b3c3}
body.dark .detail-gap-actions button{background:#26303f;border-color:#43536c;color:#b6d0fb} body.dark .detail-gap-actions button{background:#26303f;border-color:#43536c;color:#b6d0fb}
@media(max-width:350px){.detail-gap-grid strong{font-size:16px}.e-gap-bars b{font-size:14px}.list-tier-seg button{font-size:9px}} @media(max-width:350px){.detail-gap-grid strong{font-size:16px}.e-gap-bars b{font-size:14px}.list-tier-seg button{font-size:9px}}
/* v35 列表专业口径:标题两段式、未开设矮卡、分组分隔带 */
.list-count-row{display:flex;align-items:flex-start;gap:10px}
.list-count-left{min-width:0;flex:1}
.list-count-main{font-size:13px;font-weight:700;color:#16233a;letter-spacing:-.2px}
.list-count-main b{font-size:17px;font-weight:800;color:#1c3faa;margin-right:2px}
.list-count-main span{font-size:11.5px;font-weight:400;color:#5b6678;margin-left:6px}
.list-count-sub{font-size:10.5px;color:#8792a4;margin-top:3px;line-height:1.4}
.list-count-right{display:flex;flex-direction:column;align-items:flex-end;gap:6px;flex:none}
.list-om{display:inline-flex;align-items:center;gap:6px;font-size:10px;color:#6b7485;cursor:pointer}
.list-om button{position:relative;width:30px;height:16px;border-radius:9px;border:1px solid #cfd8e6;background:#eef2f8;padding:0;cursor:pointer;flex:none}
.list-om button::after{content:"";position:absolute;top:1px;left:1px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(16,30,54,.2);transition:transform .16s}
.list-om button[aria-checked="true"]{background:#1c3faa;border-color:#1c3faa}
.list-om button[aria-checked="true"]::after{transform:translateX(14px)}
.e-result-off{padding:10px 12px;min-height:0;gap:10px}
.e-off-icon{width:56px;height:56px;flex:none;border-radius:10px;background:#eef2f8;border:1px solid #dbe3ee;display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer}
.e-off-icon svg{width:24px;height:24px;fill:none;stroke:#9aa8bd;stroke-width:1.6;stroke-linejoin:round}
.e-result-off .e-result-title{gap:6px}
.e-off-tag{font-size:9.5px;font-weight:600;color:#7b8798;background:#eef2f8;border-radius:4px;padding:1px 5px;line-height:1.5;flex:none}
.e-off-note{font-size:11px;color:#8792a4;line-height:1.5;margin-top:3px}
.e-off-more{font-size:11px;color:#1c3faa;text-align:right;margin-top:5px;cursor:pointer}
.e-result-off .e-result-body{gap:0}
.list-off-bar{display:flex;align-items:center;justify-content:center;height:40px;margin:10px 0 8px;border-radius:10px;background:#eef2f8;font-size:11px;color:#6b7485}
body.dark .list-count-main{color:#e6ecf5}
body.dark .list-count-main b{color:#8fb4ff}
body.dark .list-count-main span,body.dark .list-count-sub,body.dark .e-off-note{color:#93a1b8}
body.dark .list-om{color:#93a1b8}
body.dark .list-om button{background:#2a3446;border-color:#3d4a60}
body.dark .e-off-icon{background:#232c3b;border-color:#333f52}
body.dark .e-off-icon svg{stroke:#6b7a91}
body.dark .e-off-tag{background:#2a3446;color:#9aa8bd}
body.dark .e-off-more{color:#8fb4ff}
body.dark .list-off-bar{background:#232c3b;color:#93a1b8}
</style> </style>
</head> </head>
<body> <body>
@@ -1460,7 +1511,7 @@ let tierSel = ''; // 决策层分层筛选:'' | chong | wen | bao
let recSeed = 0; // 首页「换一批」的轮换位 let recSeed = 0; // 首页「换一批」的轮换位
let recNoHome = false; // 用户点了「看全国」,本轮不再按家乡推荐 let recNoHome = false; // 用户点了「看全国」,本轮不再按家乡推荐
let recForceHome = false; // 家乡院校不够一批,但用户坚持只看家乡 let recForceHome = false; // 家乡院校不够一批,但用户坚持只看家乡
let tierDefOpen = false; // 三档口径说明是否展开(首页与院校库共用一个开关) let tierDefOpen = localStorage.getItem('zexiao_tierdef') === '1'; // 三档口径说明是否展开(首页与院校库共用一个开关,刷新后保持)
let recHomeState = null; // 上一次的家乡推荐开关,变了要重置批次计数 let recHomeState = null; // 上一次的家乡推荐开关,变了要重置批次计数
// 首页推荐:记下每档已经展示过的院校,换一批时优先给没看过的; // 首页推荐:记下每档已经展示过的院校,换一批时优先给没看过的;
// recCur 保存「当前这一批」,render 反复触发时不会把当前这批算成已看过。 // recCur 保存「当前这一批」,render 反复触发时不会把当前这批算成已看过。
@@ -1485,11 +1536,13 @@ function recPick(t, arr) {
return x; return x;
} }
const recSeenCount = () => recAll.chong.size + recAll.wen.size + recAll.bao.size; const recSeenCount = () => recAll.chong.size + recAll.wen.size + recAll.bao.size;
let onlyMajor = localStorage.getItem('zexiao_onlymajor') === '1'; let onlyMajor = localStorage.getItem('zexiao_onlymajor') !== '0';
let dirMerge = localStorage.getItem('zexiao_dirmerge') !== '0'; let dirMerge = localStorage.getItem('zexiao_dirmerge') !== '0';
let dirProv = '全部', dirSort = 'lineUp'; let dirProv = '全部', dirSort = 'lineUp';
let listTotal = 0; let listTotal = 0;
let cmp = (JSON.parse(localStorage.getItem('zexiao_cmp') || '[]')).filter(n => byNo[n]); let cmp = (JSON.parse(localStorage.getItem('zexiao_cmp') || '[]')).filter(n => byNo[n]);
// 对比页「按分差排序」开关:只改列的显示顺序,不改 cmp 里保存的选择顺序(移除、清空都按院校号定位)
let cmpSortNear = localStorage.getItem('zexiao_cmpsort') === '1';
let fav = (JSON.parse(localStorage.getItem('zexiao_fav') || '[]')).filter(n => byNo[n]); let fav = (JSON.parse(localStorage.getItem('zexiao_fav') || '[]')).filter(n => byNo[n]);
let mineShowAll = false; let mineShowAll = false;
let mineEdit = false; // 收藏列表的编辑态 let mineEdit = false; // 收藏列表的编辑态
@@ -1804,7 +1857,14 @@ function home() {
<p class="e-note">${matching.length ? '依据 2027 目录中当前专业的开设记录,按你的目标分给出冲/稳/保各一所推荐。' : DIR_LOAD_ERRORS.has(major) ? '当前专业目录加载失败,暂按院校标签展示;请核对专业开设情况。<button type="button" data-retry-direction>重新加载</button> ' : directory == null ? '当前专业目录加载中,暂按已有院校标签展示。' : '当前专业目录暂无可展示的匹配记录,按已有院校标签展示;请核对专业开设情况。'}复试线可能为方向区间,报考信息以院校当年公告为准。</p></main></div>`; <p class="e-note">${matching.length ? '依据 2027 目录中当前专业的开设记录,按你的目标分给出冲/稳/保各一所推荐。' : DIR_LOAD_ERRORS.has(major) ? '当前专业目录加载失败,暂按院校标签展示;请核对专业开设情况。<button type="button" data-retry-direction>重新加载</button> ' : directory == null ? '当前专业目录加载中,暂按已有院校标签展示。' : '当前专业目录暂无可展示的匹配记录,按已有院校标签展示;请核对专业开设情况。'}复试线可能为方向区间,报考信息以院校当年公告为准。</p></main></div>`;
} }
function row(x) { function row(x, hasM) {
if (hasM === false) {
return `<div class="item e-result e-result-off">
<button type="button" class="e-off-icon" data-go="${x.no}" aria-label="查看${esc(x.name)}"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A1.5 1.5 0 0 1 5.5 4H10v16H5.5A1.5 1.5 0 0 1 4 18.5zM20 5.5A1.5 1.5 0 0 0 18.5 4H14v16h4.5A1.5 1.5 0 0 0 20 18.5z"/><path d="M12 4v16"/></svg></button>
<div class="e-result-body"><div class="e-result-title" data-go="${x.no}"><b>${x.name}</b><span class="e-off-tag">未开设 ${esc(major)}</span><i>›</i></div>
<div class="e-off-note">2027 官方目录里这所学校没有 ${esc(major)},分数线与拟招人数不适用</div>
<div class="e-off-more" data-go="${x.no}">看该校其他专业 ›</div></div></div>`;
}
return `<div class="item e-result"><button type="button" class="e-result-photo" data-go="${x.no}" aria-label="查看${esc(x.name)}详情">${pic(x,'pic')}</button> return `<div class="item e-result"><button type="button" class="e-result-photo" data-go="${x.no}" aria-label="查看${esc(x.name)}详情">${pic(x,'pic')}</button>
<div class="e-result-body"><div class="e-result-title" data-go="${x.no}"><b>${x.name}</b>${tierChip(x)}<span>${x.city||x.prov||'—'}</span><i>›</i></div> <div class="e-result-body"><div class="e-result-title" data-go="${x.no}"><b>${x.name}</b>${tierChip(x)}<span>${x.city||x.prov||'—'}</span><i>›</i></div>
<div class="e-result-tags">${x.tags.slice(0,3).map(t=>`<span${t==='双一流'?' class="e-result-tag-featured"':''}>${t}</span>`).join('')}${evBadge(x)}</div> <div class="e-result-tags">${x.tags.slice(0,3).map(t=>`<span${t==='双一流'?' class="e-result-tag-featured"':''}>${t}</span>`).join('')}${evBadge(x)}</div>
@@ -1914,8 +1974,25 @@ function list() {
</select></div> </select></div>
</details> </details>
</div> </div>
<div class="list-count-row"><div class="e-count">共 <b>${onlyMajor && !nOffer ? '—' : listTotal}</b> 所院校</div><div class="list-context"><span title="${esc(act.join(' · '))}">${act.length ? '筛选条件:'+esc(act.join(' · ')) : '全部院校'}</span><button data-reset-list>清空</button></div></div> ${(() => {
${shownArr.length? shownArr.map(row).join('') : onlyMajor && !nOffer ? D ? `<div class="list-empty-conditions"><strong>ⓘ 已选筛选条件</strong><div class="list-empty-chips">${filterChips}</div></div><div class="state-empty list-empty-state list-missing-state"><img src="图/院校库方向明细缺失_透明.png" alt=""><h3>暂无专业方向明细</h3><p>无法按开设情况筛选</p><p class="list-missing-hint">可在更多筛选中取消“仅看本专业开设”</p><div class="state-actions"><button type="button" data-adjust-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16M8 4v4m8 2v4m-5 2v4"/></svg>调整筛选</button></div></div>` : `<div class="empty">正在加载专业方向数据…<br><span style="font-size:11px">可在更多筛选中取消“仅看本专业开设”。</span></div>` : `<div class="list-empty-conditions"><strong>ⓘ 已选筛选条件</strong><div class="list-empty-chips">${act.length ? filterChips : '<span>暂无筛选条件</span>'}</div></div><div class="state-empty list-empty-state"><img src="图/院校筛选空状态_透明.png" alt=""><h3>没有找到符合条件的院校</h3><p>试试放宽地区、院校类型或其他条件</p><div class="state-actions"><button type="button" class="primary" data-reset-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M10 4h4M6 7l1 13h10l1-13M10 10v7m4-7v7"/></svg>清除筛选</button><button type="button" data-adjust-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16M8 4v4m8 2v4m-5 2v4"/></svg>调整条件</button></div></div>`} const hasM = x => !!(D && D[String(x.no)]);
const offerN = arr.filter(hasM).length;
const offN = arr.length - offerN;
// 开关要在「只看本专业」时也留着,否则切不回全部
const offAll = D ? Math.max(0, S.length - Object.keys(D).length) : 0;
return `<div class="list-count-row">
<div class="list-count-left"><div class="list-count-main"><b>${offerN}</b> 所<span>开设 ${esc(mName())}</span></div>
${offN ? `<div class="list-count-sub">另有 ${offN} 所院校在 2027 目录中没有 ${esc(major)}</div>` : ''}</div>
<div class="list-count-right">${offAll ? `<label class="list-om"><span>也看没开设的</span><button type="button" data-om="1" role="switch" aria-label="也看没开设本专业的院校" aria-checked="${!onlyMajor}"></button></label>` : ''}<div class="list-context"><span title="${esc(act.join(' · '))}">${act.length ? '筛选条件:'+esc(act.join(' · ')) : '全部院校'}</span><button data-reset-list>清空</button></div></div>
</div>`;
})()}
${shownArr.length? (() => {
const hasM = x => !!(D && D[String(x.no)]);
const on = shownArr.filter(hasM), off = shownArr.filter(x => !hasM(x));
const offTotal = arr.filter(x => !hasM(x)).length;
const bar = (on.length && off.length) ? `<div class="list-off-bar">以下 ${offTotal} 所院校在 2027 目录里没有 ${esc(major)},排在最后</div>` : '';
return on.map(x => row(x, true)).join('') + bar + off.map(x => row(x, false)).join('');
})() : onlyMajor && !nOffer ? D ? `<div class="list-empty-conditions"><strong>ⓘ 已选筛选条件</strong><div class="list-empty-chips">${filterChips}</div></div><div class="state-empty list-empty-state list-missing-state"><img src="图/院校库方向明细缺失_透明.png" alt=""><h3>暂无专业方向明细</h3><p>无法按开设情况筛选</p><p class="list-missing-hint">可在更多筛选中取消“仅看本专业开设”</p><div class="state-actions"><button type="button" data-adjust-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16M8 4v4m8 2v4m-5 2v4"/></svg>调整筛选</button></div></div>` : `<div class="empty">正在加载专业方向数据…<br><span style="font-size:11px">可在更多筛选中取消“仅看本专业开设”。</span></div>` : `<div class="list-empty-conditions"><strong>ⓘ 已选筛选条件</strong><div class="list-empty-chips">${act.length ? filterChips : '<span>暂无筛选条件</span>'}</div></div><div class="state-empty list-empty-state"><img src="图/院校筛选空状态_透明.png" alt=""><h3>没有找到符合条件的院校</h3><p>试试放宽地区、院校类型或其他条件</p><div class="state-actions"><button type="button" class="primary" data-reset-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M10 4h4M6 7l1 13h10l1-13M10 10v7m4-7v7"/></svg>清除筛选</button><button type="button" data-adjust-list><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16M8 4v4m8 2v4m-5 2v4"/></svg>调整条件</button></div></div>`}
${!listTotal ? '' : `<div class="hint">${shown < listTotal ? `已显示 ${shownArr.length} / ${listTotal} 所,继续下滑加载。` : `共 ${listTotal} 所(招生单位 ${S.length},其中 ${S.filter(HAS).length} 所有校园影像,其余 ${S.length - S.filter(HAS).length} 所为科研院所、军工单位、党校等,源侧无公开影像)。点右侧 + 加入对比,最多 4 所。`}</div>`}</div>`; ${!listTotal ? '' : `<div class="hint">${shown < listTotal ? `已显示 ${shownArr.length} / ${listTotal} 所,继续下滑加载。` : `共 ${listTotal} 所(招生单位 ${S.length},其中 ${S.filter(HAS).length} 所有校园影像,其余 ${S.length - S.filter(HAS).length} 所为科研院所、军工单位、党校等,源侧无公开影像)。点右侧 + 加入对比,最多 4 所。`}</div>`}</div>`;
} }
// 搜不到时的近邻:简称、漏字、顺序颠倒是最常见的失败方式(「南师」→ 南京师范大学) // 搜不到时的近邻:简称、漏字、顺序颠倒是最常见的失败方式(「南师」→ 南京师范大学)
@@ -2083,7 +2160,7 @@ function marginPhrase(x) {
return d >= 0 ? `已高于录取均分 ${d} 分` : `离录取均分还差 ${-d} 分`; return d >= 0 ? `已高于录取均分 ${d} 分` : `离录取均分还差 ${-d} 分`;
} }
// 对比结论:只比分数距离与规模,缺数据不参与比较 // 对比结论:只比分数距离与规模,缺数据不参与比较
function cmpVerdict(list) { function cmpVerdict(list, sorted = false) {
if (!list.length) return ''; if (!list.length) return '';
// 余量=目标分相对该档判定门槛的富余(冲比线上限,稳/保比录取均分,缺均分比上限+15), // 余量=目标分相对该档判定门槛的富余(冲比线上限,稳/保比录取均分,缺均分比上限+15),
// 只有同一把尺子才允许排序比较;展示仍用 gapView 的标签。 // 只有同一把尺子才允许排序比较;展示仍用 gapView 的标签。
@@ -2116,11 +2193,19 @@ function cmpVerdict(list) {
return `${esc(x.name)} ${pn ? `2027 拟招 ${pn} 人` : ''}${pn && an ? '、' : ''}${an ? `2026 录取 ${an} 人` : ''}`; return `${esc(x.name)} ${pn ? `2027 拟招 ${pn} 人` : ''}${pn && an ? '、' : ''}${an ? `2026 录取 ${an} 人` : ''}`;
}).join(';') + '。'; }).join(';') + '。';
} }
return `<section class="cmp-verdict"><div class="cmp-verdict-head"><b>对比结论</b><span>目标分 ${goal} | 按 2026 复试线上限与录取均分比较</span></div><p>${text}</p><p class="cmp-verdict-note">结论只说明分数距离,不代表录取概率;缺数据的维度显示「—」,不参与比较。</p></section>`; return `<section class="cmp-verdict"><div class="cmp-verdict-head"><b>对比结论</b><span>目标分 ${goal} | 按 2026 复试线上限与录取均分比较</span></div><p>${text}</p>${sorted ? '<p class="cmp-verdict-note cmp-sort-note">列序按与 2026 复试线上限的分差绝对值由近到远(同院校库「分差最近」);结论里的最容易/要求最高按冲稳保富余算,两者尺子不同。缺复试线或分制不同的院校排在最后。</p>' : ''}<p class="cmp-verdict-note">结论只说明分数距离,不代表录取概率;缺数据的维度显示「—」,不参与比较。</p></section>`;
} }
function cmpView() { function cmpView() {
const list = cmp.map(n => byNo[n]); const picked = cmp.map(n => byNo[n]);
// 「按分差排序」用的距离=|目标分 − 2026 复试线上限|,与院校库「分差最近」同一把尺子;
// 300 分制专业或没有复试线的院校算不出距离(gapOf 返回 null),一路排最后并保留原来的相对顺序。
const nearDist = x => { const g = gapOf(x); return g === null ? null : Math.abs(g); };
const list = cmpSortNear
? picked.map((x, i) => ({ x, i, d: nearDist(x) }))
.sort((a, b) => (a.d === null ? 1 : 0) - (b.d === null ? 1 : 0) || (a.d === null ? 0 : a.d - b.d) || a.i - b.i)
.map(o => o.x)
: picked;
if (!list.length) return `<div class="compare-top"><div class="title">院校对比<small>多维数据横向对比</small></div><button data-view="list">‹ 返回院校库</button></div><div class="compare-major"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 9 12 4l10 5-10 5L2 9Z"/><path d="M6 11v5c3 2.5 9 2.5 12 0v-5M22 9v6"/></svg><b>当前专业</b><span>${esc(mName())}</span><button data-settings="major">切换专业 ›</button></div><div class="compare-empty-table"><strong>对比院校</strong>${'<button type="button" data-view="list"><span>+</span>添加院校</button>'.repeat(4)}${[['地区','<path d="M12 21s-6-5.2-6-11a6 6 0 0 1 12 0c0 5.8-6 11-6 11Z"/><circle cx="12" cy="10" r="2"/>'],['复试线','<path d="M4 18h16M6 15l4-4 3 2 5-6"/><path d="M15 7h3v3"/>'],['拟招人数','<circle cx="9" cy="8" r="3"/><path d="M3 19v-2a6 6 0 0 1 12 0v2M18 8v6M15 11h6"/>'],['录取人数','<circle cx="9" cy="8" r="3"/><path d="M3 19v-2a6 6 0 0 1 12 0v2M16 13l2 2 3-4"/>'],['学科评估','<path d="m12 3 2.7 5.5 6 .9-4.4 4.3 1 6.1-5.3-2.9-5.3 2.9 1-6.1-4.4-4.3 6-.9Z"/>']].map(([label,icon])=>`<strong><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true">${icon}</svg>${label}</strong>${'<div>—</div>'.repeat(4)}`).join('')}</div><div class="state-empty"><img src="图/对比空状态_透明.png" alt=""><h3>暂无对比院校</h3><p>最多可选 4 所院校</p><div class="state-actions"><button class="primary" data-view="list">去选择院校 ›</button></div></div><div class="hint compare-note compare-empty-note"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 10v6M12 7h.01"/></svg><div><b>数据说明:</b>选择院校后可查看各项数据及来源;不同年份和统计口径的数据不宜直接比较。</div></div><div class="compare-actions"><button data-view="list">‹ 返回院校库</button><button data-view="list">添加院校 ⊕</button></div>`; if (!list.length) return `<div class="compare-top"><div class="title">院校对比<small>多维数据横向对比</small></div><button data-view="list">‹ 返回院校库</button></div><div class="compare-major"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 9 12 4l10 5-10 5L2 9Z"/><path d="M6 11v5c3 2.5 9 2.5 12 0v-5M22 9v6"/></svg><b>当前专业</b><span>${esc(mName())}</span><button data-settings="major">切换专业 ›</button></div><div class="compare-empty-table"><strong>对比院校</strong>${'<button type="button" data-view="list"><span>+</span>添加院校</button>'.repeat(4)}${[['地区','<path d="M12 21s-6-5.2-6-11a6 6 0 0 1 12 0c0 5.8-6 11-6 11Z"/><circle cx="12" cy="10" r="2"/>'],['复试线','<path d="M4 18h16M6 15l4-4 3 2 5-6"/><path d="M15 7h3v3"/>'],['拟招人数','<circle cx="9" cy="8" r="3"/><path d="M3 19v-2a6 6 0 0 1 12 0v2M18 8v6M15 11h6"/>'],['录取人数','<circle cx="9" cy="8" r="3"/><path d="M3 19v-2a6 6 0 0 1 12 0v2M16 13l2 2 3-4"/>'],['学科评估','<path d="m12 3 2.7 5.5 6 .9-4.4 4.3 1 6.1-5.3-2.9-5.3 2.9 1-6.1-4.4-4.3 6-.9Z"/>']].map(([label,icon])=>`<strong><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true">${icon}</svg>${label}</strong>${'<div>—</div>'.repeat(4)}`).join('')}</div><div class="state-empty"><img src="图/对比空状态_透明.png" alt=""><h3>暂无对比院校</h3><p>最多可选 4 所院校</p><div class="state-actions"><button class="primary" data-view="list">去选择院校 ›</button></div></div><div class="hint compare-note compare-empty-note"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 10v6M12 7h.01"/></svg><div><b>数据说明:</b>选择院校后可查看各项数据及来源;不同年份和统计口径的数据不宜直接比较。</div></div><div class="compare-actions"><button data-view="list">‹ 返回院校库</button><button data-view="list">添加院校 ⊕</button></div>`;
// 主数字为已观测方向线的上限;下限只标为区间下限,不推断是否为专项。 // 主数字为已观测方向线的上限;下限只标为区间下限,不推断是否为专项。
const lineCell = x => { const lineCell = x => {
@@ -2195,10 +2280,10 @@ function cmpView() {
const group = (name, note, items) => `<section class="compare-section"><div class="compare-group"><span><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true">${groupIcons[name]}</svg>${name}</span><small>${note}</small></div>${items.filter(Boolean).map(compareRow).join('')}</section>`; const group = (name, note, items) => `<section class="compare-section"><div class="compare-group"><span><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true">${groupIcons[name]}</svg>${name}</span><small>${note}</small></div>${items.filter(Boolean).map(compareRow).join('')}</section>`;
return `<div class="compare-top"><div class="title">院校对比<small>多维数据横向对比</small></div><button data-view="list">‹ 返回院校库</button></div> return `<div class="compare-top"><div class="title">院校对比<small>多维数据横向对比</small></div><button data-view="list">‹ 返回院校库</button></div>
<div class="compare-major"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 9 12 4l10 5-10 5L2 9Z"/><path d="M6 11v5c3 2.5 9 2.5 12 0v-5M22 9v6"/></svg><b>当前专业</b><span>${mName()}</span><button data-settings="major">切换专业 ›</button></div> <div class="compare-major"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 9 12 4l10 5-10 5L2 9Z"/><path d="M6 11v5c3 2.5 9 2.5 12 0v-5M22 9v6"/></svg><b>当前专业</b><span>${mName()}</span><button data-settings="major">切换专业 ›</button></div>
<div class="compare-selection"><div class="compare-selected"><strong>已选院校(${list.length})</strong><div class="compare-chips${list.length<=3?' fit':''}" tabindex="0" role="group" aria-label="已选院校,可横向滚动">${list.map(x=>`<button class="compare-chip" data-rm="${x.no}" aria-label="移除${esc(x.name)}" title="${esc(x.name)}"><span>${esc(x.name)}</span><i aria-hidden="true">×</i></button>`).join('')}</div></div>${list.length<4?'<button data-view="list">⊕ 添加院校</button>':''}</div> <div class="compare-selection"><div class="compare-selected"><strong>已选(${list.length})</strong><div class="compare-chips${list.length<=3?' fit':''}" tabindex="0" role="group" aria-label="已选院校,可横向滚动">${list.map(x=>`<button class="compare-chip" data-rm="${x.no}" aria-label="移除${esc(x.name)}" title="${esc(x.name)}"><span>${esc(x.name)}</span><i aria-hidden="true">×</i></button>`).join('')}</div></div>${list.length > 1 && !is300() ? `<button type="button" class="cmp-sort${cmpSortNear?' on':''}" data-cmpsort aria-pressed="${cmpSortNear}" title="按目标分与 2026 复试线上限的差额排序,不改变已选院校" aria-label="按目标分与 2026 复试线上限的差额排序"><svg class="ui-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M8 3v17m-4-4 4 4 4-4M16 21V4m-4 4 4-4 4 4"/></svg><span class="cmp-sort-txt">${cmpSortNear?'分差优先':'按分差'}</span></button>` : ''}${list.length<4?'<button class="cmp-add-top" data-view="list" aria-label="添加院校" title="添加院校">⊕<span>添加院校</span></button>':''}</div>
${cmpVerdict(list)} ${cmpVerdict(list, cmpSortNear)}
<div id="compareTableScroll" class="compare-table-wrap${list.length===2?' two-school-wrap':''}" tabindex="0" role="region" aria-label="院校对比表,可横向滚动"><div class="compare-table${list.length===4?' four-schools':list.length===2?' two-schools':''}" style="--cols:${compareCols}"><div class="cmp"><div class="cmp-label">对比维度<small class="cmp-legend">蓝点=该行相对更有利的一侧<em>只为方便横向比较,不代表录取概率</em></small></div> <div id="compareTableScroll" class="compare-table-wrap${list.length===2?' two-school-wrap':''}" tabindex="0" role="region" aria-label="院校对比表,可横向滚动"><div class="compare-table${list.length===4?' four-schools':list.length===2?' two-schools':''}" style="--cols:${compareCols}"><div class="cmp"><div class="cmp-label">对比维度<small class="cmp-legend">蓝点=该行相对更有利的一侧<em>只为方便横向比较,不代表录取概率</em></small></div>
${list.map(x=>`<div class="col"><div class="compare-school-link" data-go="${x.no}">${pic(x,'fb4')}<b><span class="compare-school-name">${esc(x.name)}</span><span class="compare-school-arrow" aria-hidden="true">›</span></b></div></div>`).join('')}${'<div class="col"><button class="compare-add-slot" data-view="list" aria-label="添加对比院校"><span aria-hidden="true">+</span>添加院校</button></div>'.repeat(emptySlots)}</div> ${list.map((x,i)=>`<div class="col"><div class="compare-school-link" data-go="${x.no}">${pic(x,'fb4')}${cmpSortNear && !is300() ? `<i class="cmp-near${nearDist(x)===null?' na':''}">${nearDist(x)===null?'无分差':`近 ${i+1}`}</i>`:''}<b><span class="compare-school-name">${esc(x.name)}</span><span class="compare-school-arrow" aria-hidden="true">›</span></b></div></div>`).join('')}${'<div class="col"><button class="compare-add-slot" data-view="list" aria-label="添加对比院校"><span aria-hidden="true">+</span>添加院校</button></div>'.repeat(emptySlots)}</div>
${list.length === 2 ? group('基础信息','院校及学科信息',[rowNamed('城市'),rowNamed('层次'),['主管部门',()=> ''],rowNamed('学科评估')]) + group('历年分数线','复试线 · 总分',[rowNamed('目标分差'),rowNamed('复试线'),['2025 复试线',line25],['2024 复试线',()=> '']]) + group('招生信息','年份与口径见指标说明',[rowNamed('拟招'),rowNamed('录取人数'),rowNamed('录取均分'),rowNamed('录取最低'),rowNamed('较2025'),rowNamed('方向码数')]) : rows.slice(0, major === '0856' ? 5 : 4).map(([k,f,dir])=>{ ${list.length === 2 ? group('基础信息','院校及学科信息',[rowNamed('城市'),rowNamed('层次'),['主管部门',()=> ''],rowNamed('学科评估')]) + group('历年分数线','复试线 · 总分',[rowNamed('目标分差'),rowNamed('复试线'),['2025 复试线',line25],['2024 复试线',()=> '']]) + group('招生信息','年份与口径见指标说明',[rowNamed('拟招'),rowNamed('录取人数'),rowNamed('录取均分'),rowNamed('录取最低'),rowNamed('较2025'),rowNamed('方向码数')]) : rows.slice(0, major === '0856' ? 5 : 4).map(([k,f,dir])=>{
return compareRow([k,f,dir]); return compareRow([k,f,dir]);
}).join('')} }).join('')}
@@ -2713,7 +2798,7 @@ function openSettings(kind, onboarding = false, state = null) {
'14':'<circle cx="12" cy="12" r="9"/><path d="M8 12h.01M12 12h.01M16 12h.01"/>' '14':'<circle cx="12" cy="12" r="9"/><path d="M8 12h.01M12 12h.01M16 12h.01"/>'
}; };
const categoryIcon = k => `<svg class="category-icon" viewBox="0 0 24 24" aria-hidden="true">${categoryPaths[k] || categoryPaths['14']}</svg>`; const categoryIcon = k => `<svg class="category-icon" viewBox="0 0 24 24" aria-hidden="true">${categoryPaths[k] || categoryPaths['14']}</svg>`;
screen.innerHTML = `${head}<div class="settings-content"><div class="settings-intro">${targetIcon}<div><h2>${onboarding ? '先选择目标专业' : '选择目标专业'}</h2><p>${onboarding ? '选择专业后查看院校与招生信息。' : '选择后查看对应院校与数据。'}</p></div></div><div class="settings-search-wrap"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10" cy="10" r="7"/><path d="m15 15 6 6"/></svg><input class="settings-search" aria-label="搜索专业名称或代码" placeholder="搜索专业名称或代码"></div><div class="settings-columns"><div class="settings-categories"></div><div class="settings-majors"></div></div></div><div class="settings-footer">${onboarding ? `<div class="onboarding-goal"><label for="onboardingGoal">${targetIcon} 目标分(可选)</label><input id="onboardingGoal" type="number" inputmode="numeric" min="250" max="500" placeholder="请输入目标分(如:350)"></div><div class="onboarding-error" role="alert" hidden></div>` : '<div class="settings-selection"></div>'}<button class="settings-primary" data-confirm>${onboarding ? '开始择校' : '确认选择'} →</button>${onboarding ? `<p class="onboarding-note">ⓘ 未填写时使用当前目标分 ${goal};之后可随时修改。</p>` : ''}</div>`; screen.innerHTML = `${head}<div class="settings-content"><div class="settings-intro">${targetIcon}<div><h2>${onboarding ? '先选择目标专业' : '选择目标专业'}</h2><p>${onboarding ? '选择专业后查看院校与招生信息。' : '选择后查看对应院校与数据。'}</p></div></div><div class="settings-search-wrap"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10" cy="10" r="7"/><path d="m15 15 6 6"/></svg><input class="settings-search" aria-label="搜索专业名称或代码" placeholder="搜索专业名称或代码"></div><div class="settings-columns"><div class="settings-categories"></div><div class="settings-majors"></div></div></div><div class="settings-footer">${onboarding ? `<div class="onboarding-goal"><label for="onboardingGoal">${targetIcon} 目标分(可选)</label><input id="onboardingGoal" type="number" inputmode="numeric" min="250" max="500" placeholder="请输入目标分(如:350)"></div><div class="onboarding-error" role="alert" hidden></div>` : '<div class="settings-selection"></div>'}<button class="settings-primary" data-confirm>${onboarding ? '开始择校' : '确认选择'} →</button>${onboarding ? `<p class="onboarding-note">ⓘ 未填写时${localStorage.getItem('zexiao_goal') ? `沿用你上次设置的目标分 ${goal}` : `先用默认目标分 ${goal}`},提交后仍可随时修改。</p>` : ''}</div>`;
const search = screen.querySelector('.settings-search'); const search = screen.querySelector('.settings-search');
let majorSort = 'code'; let majorSort = 'code';
const draw = () => { const draw = () => {
@@ -2892,7 +2977,8 @@ function render() {
document.querySelectorAll('[data-rec-no-home]').forEach(e => e.onclick = () => { recNoHome = true; recForceHome = false; recSeed++; render(); }); document.querySelectorAll('[data-rec-no-home]').forEach(e => e.onclick = () => { recNoHome = true; recForceHome = false; recSeed++; render(); });
document.querySelectorAll('[data-rec-force-home]').forEach(e => e.onclick = () => { recForceHome = true; recNoHome = false; recSeed++; render(); }); document.querySelectorAll('[data-rec-force-home]').forEach(e => e.onclick = () => { recForceHome = true; recNoHome = false; recSeed++; render(); });
// 占位卡的出口:这一档空着,就去院校库按分差看全部,别让用户卡在原地 // 占位卡的出口:这一档空着,就去院校库按分差看全部,别让用户卡在原地
document.querySelectorAll('[data-tier-def]').forEach(e => e.onclick = () => { tierDefOpen = !tierDefOpen; render(); }); document.querySelectorAll('[data-cmpsort]').forEach(e => e.onclick = () => { cmpSortNear = !cmpSortNear; localStorage.setItem('zexiao_cmpsort', cmpSortNear ? '1' : '0'); render(); });
document.querySelectorAll('[data-tier-def]').forEach(e => e.onclick = () => { tierDefOpen = !tierDefOpen; localStorage.setItem('zexiao_tierdef', tierDefOpen ? '1' : '0'); render(); });
document.querySelectorAll('[data-tier-all]').forEach(e => e.onclick = () => { document.querySelectorAll('[data-tier-all]').forEach(e => e.onclick = () => {
tierSel = ''; tierSel = '';
if (view !== 'list') { onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1'); } if (view !== 'list') { onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1'); }
@@ -2926,8 +3012,8 @@ function render() {
document.querySelectorAll('[data-sortmore]').forEach(e => e.onclick = () => { sortk = e.dataset.sortmore; shown = 80; render(); }); document.querySelectorAll('[data-sortmore]').forEach(e => e.onclick = () => { sortk = e.dataset.sortmore; shown = 80; render(); });
const listMore = document.querySelector('.list-more'); const listMore = document.querySelector('.list-more');
if (listMore) listMore.ontoggle = () => { listMoreOpen = listMore.open; }; if (listMore) listMore.ontoggle = () => { listMoreOpen = listMore.open; };
document.querySelectorAll('[data-reset-list]').forEach(e => e.onclick = () => { tag = '全部'; prov = '全部'; citySel = '全部'; kw = ''; sortk = 'no'; tierSel = ''; onlyMajor = false; localStorage.setItem('zexiao_onlymajor', '0'); shown = 80; render(); }); document.querySelectorAll('[data-reset-list]').forEach(e => e.onclick = () => { tag = '全部'; prov = '全部'; citySel = '全部'; kw = ''; sortk = 'no'; tierSel = ''; onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1'); shown = 80; render(); });
document.querySelectorAll('[data-remove-list-filter]').forEach(e => e.onclick = () => { const key = e.dataset.removeListFilter; if (key === 'tag') tag = '全部'; if (key === 'province') { prov = '全部'; citySel = '全部'; } if (key === 'city') citySel = '全部'; if (key === 'keyword') kw = ''; if (key === 'major') { onlyMajor = false; localStorage.setItem('zexiao_onlymajor', '0'); } if (key === 'sort') sortk = 'no'; if (key === 'tier') tierSel = ''; shown = 80; render(); }); document.querySelectorAll('[data-remove-list-filter]').forEach(e => e.onclick = () => { const key = e.dataset.removeListFilter; if (key === 'tag') tag = '全部'; if (key === 'province') { prov = '全部'; citySel = '全部'; } if (key === 'city') citySel = '全部'; if (key === 'keyword') kw = ''; if (key === 'major') { onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1'); } if (key === 'sort') sortk = 'no'; if (key === 'tier') tierSel = ''; shown = 80; render(); });
document.querySelectorAll('[data-adjust-list]').forEach(e => e.onclick = () => { const more = document.querySelector('.list-more'); if (more) { listMoreOpen = true; more.open = true; more.querySelector('summary').focus(); more.scrollIntoView({behavior:'smooth',block:'center'}); } }); document.querySelectorAll('[data-adjust-list]').forEach(e => e.onclick = () => { const more = document.querySelector('.list-more'); if (more) { listMoreOpen = true; more.open = true; more.querySelector('summary').focus(); more.scrollIntoView({behavior:'smooth',block:'center'}); } });
document.querySelectorAll('[data-rm]').forEach(e => e.onclick = () => { toggleCmp(+e.dataset.rm); }); document.querySelectorAll('[data-rm]').forEach(e => e.onclick = () => { toggleCmp(+e.dataset.rm); });
document.querySelectorAll('[data-clear]').forEach(e => e.onclick = () => { cmp = []; save(); render(); }); document.querySelectorAll('[data-clear]').forEach(e => e.onclick = () => { cmp = []; save(); render(); });
@@ -3181,7 +3267,7 @@ function applyHash() {
dirCode = qs.get('dir') || ''; dirCode = qs.get('dir') || '';
dirMerge = qs.has('merge') ? qs.get('merge') === '1' : localStorage.getItem('zexiao_dirmerge') !== '0'; dirMerge = qs.has('merge') ? qs.get('merge') === '1' : localStorage.getItem('zexiao_dirmerge') !== '0';
expSet = new Set((qs.get('exp') || '').split(',').map(Number).filter(n => n)); expSet = new Set((qs.get('exp') || '').split(',').map(Number).filter(n => n));
onlyMajor = qs.get('om') === '1'; if (qs.has('om')) onlyMajor = qs.get('om') === '1';
if (qs.get('no')) { const t = byNo[+qs.get('no')]; if (t) cur = t; } if (qs.get('no')) { const t = byNo[+qs.get('no')]; if (t) cur = t; }
if (qs.get('major') && MJ[qs.get('major')]) major = qs.get('major'); if (qs.get('major') && MJ[qs.get('major')]) major = qs.get('major');
if (qs.get('theme')) theme = qs.get('theme'); if (qs.get('theme')) theme = qs.get('theme');
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

@@ -0,0 +1,14 @@
参考图是一张中文手机 App「院校对比」页的真实截图(390×844 @2x)。请严格沿用参考图的版式、配色、字号层级、卡片圆角、图标笔触,只在下述位置做改动,输出一张同样风格的整屏界面稿。
改动一:在「已选院校(3)」这一行,右侧「⊕ 添加院校」按钮的左边,新增一个轻量的排序开关按钮。
- 默认态:白底、1px 浅灰蓝描边、胶囊圆角,左侧一个上下箭头图标,文案「按分差排序」。
- 激活态:浅蓝底、主色描边,图标与文字变成主色深蓝,文案改成「分差最近优先」,右侧带一个小对勾。
- 这个按钮比「添加院校」按钮矮一点、字更小(约 11–12px),不要抢主按钮的视觉。
改动二:激活排序后,对比表的院校列顺序按「与目标分的分差绝对值由近到远」重排,并在每所院校的照片下方、校名上方,加一个很细的排名徽标,形如「近 1」「近 2」,浅灰蓝底、9–10px、圆角 4px,字号明显小于校名。没有 2026 复试线、无法计算分差的院校排在最后一列,徽标位置显示灰色「无分差」而不是数字。
改动三:对比结论卡片右上角原来的「目标分 340 │ 按 2026 复试线上限与录取均分比较」,在激活排序后追加一行小字提示:「已按分差由近到远排列;缺复试线的院校排在最后」。这行提示用 10–11px 灰字,不要做成新卡片。
其余部分保持不变:顶部深蓝渐变标题栏(研选 / 研究生院校与专业选择 / 书签与铃铛图标)、标题「院校对比」+红色下划线、「‹ 返回院校库」描边按钮、当前专业条(0856 材料与化工 / 切换专业 ›)、对比结论段落、三列对比表(对比维度 / 东南大学 / 天水师范大学 / 运城学院)与蓝点「该行相对更有利」图例、数据说明条、底部三个按钮(返回院校库 / 清空对比 / 添加院校)、最底部四个 Tab(首页 / 院校库 / 对比(3) / 我的,对比 Tab 为主色并有红色下划线)。
细节要求:中文全部用简体,不要出现英文单词;不要出现任何标注箭头、批注、尺寸线、色板、说明文字框;不要手机外框与刘海,只要界面本体;整体干净、留白均匀、密度接近参考图;数字仅为占位示例(东南大学 347/1025、天水师范大学 325/4),照抄参考图即可,不要自行编造更多数字。
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

@@ -0,0 +1,23 @@
参考图是一张中文手机 App「院校库」列表页的真实截图(390×844 @2x)。请严格沿用参考图的版式、配色、字号层级、卡片圆角、图标笔触、顶部深蓝渐变标题栏与底部四个 Tab,只在下述三处做改动,输出一张同样风格的整屏稿。
改动一:列表标题行。
现在写的是「共 907 所院校」,右侧是「全部院校 清空」。改成三段式:
- 左侧主数字改成「362 所」,「所」小一号,后面跟一行同字号但更浅的灰字「开设 0856 材料与化工」;
- 这行下面加一行 10–11px 灰字:「另有 545 所院校在 2027 目录中没有 0856」;
- 右侧「全部院校 清空」保留,但在它左边新增一个胶囊开关,文案「也看没开设的」,默认关闭态(白底、1px 浅灰蓝描边、灰字),激活态才变浅蓝底主色字。
主数字「362 所」要明显比现在的「共 907 所院校」更醒目,字号约 16–17px、加重;「开设 0856 材料与化工」12px 常规灰,不要抢主数字。
改动二:把「没开设本专业」的院校卡片改成另一种更矮的形态。
现在的空卡与正常卡同高,照片占左半,右侧三个指标全是灰色横杠「—」。改成:
- 卡片高度压到正常卡的三分之二左右,不再用大照片,左侧换成一个小尺寸的方形校徽占位(56×56、浅灰蓝底、居中一个书本线性图标);
- 右侧第一行校名,校名后跟一个浅灰小标签「未开设 0856」;
- 第二行一行 11px 灰字说明:「2027 官方目录里这所学校没有 0856,分数线与拟招人数不适用」;
- 第三行最右侧一个文字按钮「看该校其他专业 ›」,主色、11px、无边框;
- 整张卡不再出现「2026 复试线」「2027 拟招」「距录取均分」这三个指标块,也不出现对比与收藏按钮。
改动三:在两批卡片之间加一条分组分隔带。
在最后一张有数据的卡片之后、第一张「未开设」卡之前,插入一条横贯整行、高约 40px、浅灰蓝底圆角的提示带,居中一行 11px 字:「以下 545 所院校在 2027 目录里没有 0856,排在最后」。
其余部分一律保持不变:顶部「研选 / 研究生院校与专业选择 / 书签与铃铛」、标题「院校库」+红色下划线+副标题「按专业、地区等条件筛选研究生招生院校」、搜索框与蓝色「搜索」按钮、当前专业与目标分两个下拉条、分差视角卡(本专业开设 362 所|目标分 340,冲 50 / 稳 29 / 保 280 三个方块,下面一行口径说明)、地区/院校类型/排序三行筛选、以及四张正常院校卡片(上海大学、沈阳航空航天大学、杭州师范大学、厦门理工学院,保留原有照片、校名后的「保」标签、城市标签、211/双一流标签、三指标块与对比收藏按钮)。底部 Tab 四个:首页 / 院校库 / 对比 / 我的,院校库为主色带红色下划线。
细节要求:中文全部用简体,不要英文单词;不要任何标注箭头、批注、尺寸线、色板、说明文字框;不要手机外框与刘海,只要界面本体;整体干净、留白均匀、密度接近参考图;数字仅为占位示例,照抄参考图与上述文案,不要自行编造更多数字。
+84
View File
@@ -1103,3 +1103,87 @@ if (!arr.length) return `<div class="e-rec-card e-rec-card-empty"><span class="e
- 均分含推免与专项未剔除。 - 均分含推免与专项未剔除。
- 展开态不持久化,刷新回到收起。 - 展开态不持久化,刷新回到收起。
- 引导页的圈码「① 未填写时使用当前目标分 340」在还没选专业时就提到 340,措辞早了一步。 - 引导页的圈码「① 未填写时使用当前目标分 340」在还没选专业时就提到 340,措辞早了一步。
## v34(2026-11-13):对比页该先说「谁离我最近」
稿 `37_对比页贴近度排序.png`。
### 问题
对比页把选中的 2–4 所院校并排列指标,但顺序是用户点选的先后。四列并排、指标七八行,眼睛要来回扫才能拼出「哪所最够得着」。而用户来对比页要问的第一个问题恰恰是这个。
### 做法
加一个排序开关「按分差排序」,按各校与目标分的贴近程度重排:
- 卡头挂「近 1 / 近 2」的序位徽标,一眼看出梯队次序;
- 没有本专业复试线的院校没有分差可比,统一沉到最后、标「无分差」,不参与排序;
- 开关关掉就回到点选顺序,不做隐式重排。
### 验证
排序开关与序位徽标落在同一份 `cmpSort` 状态上,切换后四列同步重排;无分差院校始终在末位,不会因为排序而插进有数的一列中间。
### 仍未做
- 排序状态不持久化,刷新回默认。
## v35(2026-11-17):907 所里有 545 所根本不招我这个专业
稿 `38_列表专业口径.png`(以实现实拍为参考图生成)。
### 问题
院校库顶部「分差视角」写的是「本专业开设 362 所」,列表标题写的却是「共 907 所院校」。同一个页面、上下相隔 10px,两个数字差 545 所。选了 0856 材料与化工的人,看到的是全库 907 所——其中 545 所在 2027 官方目录里没有 0856。
实测把 907 张卡全加载出来:**547 张的三个指标位(2026 复试线 / 2027 拟招 / 距录取均分)全是灰色横杠「—」**,标签还写着「目标分差」。也就是说用户滑到后面,屏幕上是六成的空卡。底部的说明行只提「850 所有校园影像,其余 57 所为科研院所、军工单位、党校」,一个字没提专业开设情况。
数据本身没有编造——空卡显示的是「—」而不是别的专业的分数线,这一点是对的。但把 545 张「—」和 362 张真数据混在一张长列表里,等于让用户自己筛。
### 做法
口径统一到「本专业」,并把「不招」这件事明确说出来,而不是用横杠糊过去:
1. **标题改两段式**:主数字 `362 所` + `开设 0856 材料与化工`;只在看全部时补一行 10.5px 的 `另有 545 所院校在 2027 目录中没有 0856`。
2. **未开设院校换矮卡**:不再占一张整卡的位置摆三个横杠。左边 56×56 的书本图标占位,校名后挂 `未开设 0856` 标签,下面一行说明「2027 官方目录里这所学校没有 0856,分数线与拟招人数不适用」,右下角「看该校其他专业 ›」。不再出现三个指标块,也不出现对比与收藏。实测 89px,正常卡 110px。
3. **两批之间加分隔带**:`以下 545 所院校在 2027 目录里没有 0856,排在最后`,40px 高、浅灰蓝底。数字取全池的未开设数,不取当前已加载的那一段,否则滚到一半会显示「以下 1 所」。
4. **默认只看本专业**:`onlyMajor` 从「没存过就当关」改成「没存过就当开」,新用户进来就是 362 所。
### 根因:一条 URL 解析把默认值吃掉了
改完默认值,开关状态还是错的。查下去是 `updateFromUrl()` 里这一行:
```js
onlyMajor = qs.get('om') === '1';
```
**无条件赋值**。任何不带 `om` 参数的链接——站内跳转、刷新、分享出去的短链——都会把 `onlyMajor` 置成 `false`,前面刚定的默认值当场作废。改成 `if (qs.has('om')) onlyMajor = qs.get('om') === '1';`:只有链接显式写了 `om` 才覆盖。
顺带把「清空筛选」和「切专业」两处从 `onlyMajor = false` 改成 `true`:换了专业还继续显示「没有这个专业的 545 所」,跟默认口径正好相反。
还有一处:开关的显示条件是「当前池里有未开设的院校」(`offN > 0`)。默认只看本专业时池子里全是开设的,`offN` 恒为 0,开关直接不渲染——用户被锁在 362 所里,没有任何入口切回全部。改成看全库的未开设数 `offAll = S.length - Object.keys(D).length`,只要库里有不招这个专业的院校,开关就在。
### 复审
- 干净 localStorage 冷启动:标题 `362 所 开设 0856 材料与化工`、开关关闭、无矮卡、`#view=list` 落到 362 所口径;
- 打开开关:副行出现 `另有 545 所…`、开关转开、矮卡与分隔带随之出现;再关掉回到 362;
- 切专业口径跟随:0805 → 252 所(另有 655)、0301 → 208 所(另有 699),主数字与专业名同步;
- 320 宽校名不换行(`沈阳航空航天…` 省略号收尾),此前 320 下「沈阳航空航天大学」被挤成两行、把「保 / 沈阳」标签推到卡外;
- 390 / 320、浅色 / 深色都不横向溢出,页面错误 0。
### 两处刻意的取舍
- **默认看本专业,不是默认看全部**。既然用户已经选了专业,「院校库」的语境就是「给我这个专业找学校」。907 所里 545 所不招,先摆给他是噪音。要看全部,开关就在标题右边。
- **空卡不删,改成矮卡**。直接过滤掉会让用户以为库里没这所学校(比如中国人民大学确实在这个库里,只是 2027 目录没有 0856)。留一张矮卡 + 「看该校其他专业」,既省掉 60% 的纵向空间,又保留了「这学校在库里」这个事实。
### 验证
`ui_v35_list_scope.py`(施加改动)、`ui_v35_verify.py`(30 项:口径一致性 / 矮卡形态 / 分隔带 / 开关联动 / 320 深色无溢出)、`ui_v35_verify2.py`(12 项:干净态默认、开关往返、切专业跟随、无方向明细专业不崩)。两套共 42 项全 PASS。
### 仍未做
- 「距录取均分 ±0」在排序靠前的几张卡上连着出现(0856 里正好 5 所录取均分等于 340),视觉上像没数据。措辞可改成「持平」,但 `gapText` 在对比页和详情页共用,要一起评估。
- 开关在两个地方出现且语义相反:更多筛选里是「仅看本专业开设」,标题行是「也看没开设的」。同一个 `onlyMajor`,`aria-checked` 各算各的,读屏用户容易绕晕。
- 分隔带只在「有数据 / 无数据」交界处插一条;如果将来允许按城市、标签筛到只剩无数据的院校,这条带会消失,需要另给空态。
- 均分含推免与专项未剔除(老问题)。
+45
View File
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
"""滚到 907 张,统计「不招本专业」的院校卡片到底显示什么。"""
import json
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
n = 0
for i in range(30):
pg.mouse.move(195, 600)
pg.mouse.wheel(0, 6000)
pg.wait_for_timeout(650)
n = pg.eval_on_selector_all('.e-result', 'e=>e.length')
print('最终卡片数:', n)
stat = pg.evaluate("""() => {
const cards = [...document.querySelectorAll('.e-result')];
const empty = [], full = [];
for (const el of cards) {
const bs = el.querySelectorAll('.e-result-metrics b');
const line = bs[0] ? bs[0].innerText.trim() : '';
const rec = {n: (el.querySelector('.e-result-title b') || {}).innerText || '',
line, plan: bs[1] ? bs[1].innerText.trim() : '',
label: (el.querySelector('.e-result-gap small') || {}).innerText || '',
gap: (el.querySelector('.e-result-gap b') || {}).innerText || ''};
(line === '—' || line === '' ? empty : full).push(rec);
}
return {total: cards.length, emptyCount: empty.length, fullCount: full.length,
emptySample: empty.slice(0, 6), last3: full.slice(-3),
hint: (document.querySelector('.hint') || {}).innerText || ''};
}""")
print(json.dumps(stat, ensure_ascii=False, indent=2))
pg.screenshot(path=os.path.join(ROOT, '运行暂存', 'ui_round35_20261117', '04_list_bottom.png'))
b.close()
+50
View File
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
"""在页面里读真实数据:几所学校的 avgS / hi / gap,验证「距录取均分 ±0」是不是数据本身。"""
import os
import json
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1200)
out = pg.evaluate("""() => {
const res = [];
const names = ['上海大学','沈阳航空航天大学','杭州师范大学','厦门理工学院','东南大学'];
for (const n of names) {
const x = (typeof ALL !== 'undefined' ? ALL : []).find(a => a.n === n || a.name === n);
if (!x) { res.push({name: n, miss: true}); continue; }
const v = V(x);
res.push({name: n, no: x.no, prov: x.prov, line: v.line, minS: v.minS, avgS: v.avgS,
avgOf: avgOf(x), gapOf: gapOf(x), tier: tierOf(x), gapView: gapView(x)});
}
return {res, total: (typeof ALL !== 'undefined' ? ALL.length : -1),
majors: (typeof majorPool === 'function' ? majorPool().length : -1)};
}""")
print(json.dumps(out, ensure_ascii=False, indent=2))
# 统计全库 avgS 分布,看有多少等于 340
stat = pg.evaluate("""() => {
const arr = (typeof majorPool === 'function' ? majorPool() : []);
let has = 0, eq340 = 0, nulls = 0;
const samples = [];
for (const x of arr) {
const a = avgOf(x);
if (a === null) nulls++;
else {
has++;
if (a === 340) { eq340++; if (samples.length < 5) samples.push(x.n); }
}
}
return {pool: arr.length, hasAvg: has, eq340, nulls, samples};
}""")
print('\n本专业池统计:', json.dumps(stat, ensure_ascii=False))
b.close()
+43
View File
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
"""加载全部卡片,统计「不招本专业」的院校在列表里显示什么。"""
import json
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
# 列表每次 80,滚到底会追加
for i in range(14):
pg.evaluate("""() => {
const el = document.querySelector('.e-content') || document.scrollingElement;
el.scrollTop = el.scrollHeight;
}""")
pg.wait_for_timeout(400)
stat = pg.evaluate("""() => {
const cards = [...document.querySelectorAll('.e-result')];
const empty = [], withLine = [];
for (const el of cards) {
const bs = el.querySelectorAll('.e-result-metrics b');
const line = bs[0] ? bs[0].innerText.trim() : '';
const name = (el.querySelector('.e-result-title b') || {}).innerText || '';
const label = (el.querySelector('.e-result-gap small') || {}).innerText || '';
const gap = (el.querySelector('.e-result-gap b') || {}).innerText || '';
(line === '—' || line === '' ? empty : withLine).push({name, line, label, gap});
}
return {total: cards.length, emptyCount: empty.length,
emptySample: empty.slice(0, 8), tail: withLine.slice(-5)};
}""")
print(json.dumps(stat, ensure_ascii=False, indent=2))
print('标题:', pg.inner_text('.list-count-row').split('\n')[0])
b.close()
+41
View File
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
"""抓列表卡片实际显示,看「不招本专业」的院校是空白还是顶着别的专业的数据。"""
import json
import os
import re
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
cards = pg.evaluate("""() => [...document.querySelectorAll('.e-result')].map(el => ({
name: (el.querySelector('.e-result-title b') || {}).innerText || '',
line: (el.querySelectorAll('.e-result-metrics b')[0] || {}).innerText || '',
plan: (el.querySelectorAll('.e-result-metrics b')[1] || {}).innerText || '',
gapLabel: (el.querySelector('.e-result-gap small') || {}).innerText || '',
gapVal: (el.querySelector('.e-result-gap b') || {}).innerText || '',
tier: (el.querySelector('.e-tier, .tier-chip') || {}).innerText || ''
}))""")
print('卡片数:', len(cards))
empty = [c for c in cards if c['line'] in ('—', '')]
print('复试线为空的卡:', len(empty))
print('\n前 8 张:')
for c in cards[:8]:
print(' ', json.dumps(c, ensure_ascii=False))
print('\n为空的示例:')
for c in empty[:6]:
print(' ', json.dumps(c, ensure_ascii=False))
# 合计口径
print('\n标题行:', pg.inner_text('.list-count-row'))
print('分差视角:', pg.inner_text('.e-count, #gapBar')[:120] if pg.query_selector('#gapBar') else pg.inner_text('body')[:0])
b.close()
+26
View File
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""查两处:列表标题的「共 N 所」怎么来的;卡片「距录取均分」的 gapOf 怎么算。"""
import io
import re
s = io.open(r'D:\择校\docs\择校UI\index.html', encoding='utf-8').read()
print('=== 共 N 所 ===')
for m in re.finditer(r'共[^<]{0,40}所', s):
print(' at', m.start(), '|', s[max(0, m.start() - 120):m.start() + 60].replace('\n', ' '))
print('\n=== gapOf ===')
i = s.find('function gapOf')
if i < 0:
i = s.find('const gapOf')
print(s[i:i + 700] if i > 0 else '没找到')
print('\n=== gapView ===')
j = s.find('function gapView')
if j < 0:
j = s.find('const gapView')
print(s[j:j + 700] if j > 0 else '没找到')
print('\n=== 距录取均分渲染 ===')
for m in re.finditer(r'距录取均分', s):
print(' at', m.start(), '|', s[max(0, m.start() - 260):m.start() + 160].replace('\n', ' '))
+16
View File
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
"""定位详情页渲染代码与结构。"""
import io
import re
s = io.open(r'D:\择校\docs\择校UI\index.html', encoding='utf-8').read()
for pat in [r"'detail'", r'vDetail', r'detailHTML', r'd-view', r'class="d-']:
hits = [m.start() for m in re.finditer(pat, s)]
print('%-14s %d 处' % (pat, len(hits)))
for i in hits[:4]:
print(' ...', s[max(0, i - 90):i + 70].replace('\n', ' '))
print('\n--- 视图分发处 ---')
for m in re.finditer(r'view\s*===?\s*[\'"]\w+[\'"]', s):
print(' ', m.group(0), 'at', m.start())
+48
View File
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""诊断:列表「共 907 所」但只渲染 80 张,滚动能不能继续加载。"""
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
print('初始卡片:', pg.eval_on_selector_all('.e-result', 'e=>e.length'))
print('滚动容器诊断:', pg.evaluate("""() => {
const out = [];
for (const sel of ['.e-content', '.e-home', 'main', 'body']) {
const el = document.querySelector(sel);
if (!el) continue;
const cs = getComputedStyle(el);
out.push({sel, sh: el.scrollHeight, ch: el.clientHeight,
overflow: cs.overflowY, scrollable: el.scrollHeight > el.clientHeight + 5});
}
return out;
}"""))
# 用真实的滚动:wheel 在内容区
for i in range(8):
pg.mouse.move(195, 600)
pg.mouse.wheel(0, 3000)
pg.wait_for_timeout(500)
print('wheel 之后卡片:', pg.eval_on_selector_all('.e-result', 'e=>e.length'))
# 试试直接把 .e-content 滚到底并派发 scroll 事件
pg.evaluate("""() => {
const el = document.querySelector('.e-content');
if (el) { el.scrollTop = el.scrollHeight; el.dispatchEvent(new Event('scroll', {bubbles: true})); }
window.scrollTo(0, document.body.scrollHeight);
window.dispatchEvent(new Event('scroll'));
}""")
pg.wait_for_timeout(1200)
print('dispatch 之后卡片:', pg.eval_on_selector_all('.e-result', 'e=>e.length'))
print('页面里是否有「加载更多」按钮:', pg.eval_on_selector_all('button', "e=>e.filter(b=>/加载|更多/.test(b.innerText)).map(b=>b.innerText.trim()).slice(0,5)"))
b.close()
+36
View File
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
"""关键核查:列表里那些「不招本专业」的院校,卡片上显示的是谁的数据?
如果 V(x) 对缺失专业回落到该校别的专业,列表就在用别的专业的分数线冒充本专业。
"""
import json
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1300)
out = pg.evaluate("""() => {
const noMajor = S.filter(x => !D[String(x.no)]);
const withMajor = S.filter(x => D[String(x.no)]);
const sample = noMajor.slice(0, 5).map(x => {
const v = V(x);
return {n: x.n, no: x.no, prov: x.prov,
line: v.line, minS: v.minS, avgS: v.avgS, plan: v.plan,
hasMajorData: !!D[String(x.no)],
majorKeys: D[String(x.no)] ? D[String(x.no)].length : 0};
});
// V() 的来源
return {total: S.length, noMajor: noMajor.length, withMajor: withMajor.length, sample};
}""")
print(json.dumps(out, ensure_ascii=False, indent=2))
b.close()
+13
View File
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
"""查 onlyMajor 的默认值、切换入口、「共 N 所院校」的模板来源。"""
import io
import re
s = io.open(r'D:\择校\docs\择校UI\index.html', encoding='utf-8').read()
for pat in [r'onlyMajor', r'共\s*\$\{[^}]*\}\s*所院校', r'所院校']:
hits = list(re.finditer(pat, s))
print('=== %s : %d 处 ===' % (pat, len(hits)))
for m in hits[:8]:
print(' at', m.start(), '|', s[max(0, m.start() - 150):m.start() + 110].replace('\n', ' '))
print()
+13
View File
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
"""看列表卡片模板:不招本专业的院校渲染成什么。"""
import io
import re
s = io.open(r'D:\择校\docs\择校UI\index.html', encoding='utf-8').read()
for pat in [r'未开设', r'不招', r'nOffer', r'function row', r'const row']:
hits = list(re.finditer(pat, s))
print('=== %s : %d 处 ===' % (pat, len(hits)))
for m in hits[:6]:
print(' at', m.start(), '|', s[max(0, m.start() - 200):m.start() + 200].replace('\n', ' '))
print()
+48
View File
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""滚到底,统计 907 张里「不招本专业」的院校卡片显示什么。"""
import json
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
last = 0
for i in range(40):
pg.mouse.move(195, 600)
pg.mouse.wheel(0, 4000)
pg.wait_for_timeout(320)
n = pg.eval_on_selector_all('.e-result', 'e=>e.length')
if n == last and i > 6:
print('停在第 %d 次滚动,卡片 %d 张' % (i + 1, n))
break
last = n
print('最终卡片数:', last)
stat = pg.evaluate("""() => {
const cards = [...document.querySelectorAll('.e-result')];
const empty = [], full = [];
for (const el of cards) {
const bs = el.querySelectorAll('.e-result-metrics b');
const line = bs[0] ? bs[0].innerText.trim() : '';
const name = (el.querySelector('.e-result-title b') || {}).innerText || '';
const rec = {name, line,
plan: bs[1] ? bs[1].innerText.trim() : '',
label: (el.querySelector('.e-result-gap small') || {}).innerText || '',
gap: (el.querySelector('.e-result-gap b') || {}).innerText || ''};
(line === '—' || line === '' ? empty : full).push(rec);
}
return {total: cards.length, emptyCount: empty.length, fullCount: full.length,
emptySample: empty.slice(0, 6), lastFew: full.slice(-3)};
}""")
print(json.dumps(stat, ensure_ascii=False, indent=2))
b.close()
+32
View File
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
"""逐次滚动记录 scrollTop 与卡片数,确认「加载更多后是否被甩回顶部」。"""
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
def snap():
return pg.evaluate("""() => {
const el = document.getElementById('screen');
return {cards: document.querySelectorAll('.e-result').length,
top: Math.round(el.scrollTop),
h: Math.round(el.scrollHeight)};
}""")
print('起始:', snap())
for i in range(14):
pg.mouse.move(195, 600)
pg.mouse.wheel(0, 5000)
pg.wait_for_timeout(700)
print('第 %2d 次滚动 →' % (i + 1), snap())
b.close()
+13
View File
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
"""查 shown 的上限逻辑:为什么停在 240。"""
import io
import re
s = io.open(r'D:\择校\docs\择校UI\index.html', encoding='utf-8').read()
for pat in [r'\bshown\b']:
hits = list(re.finditer(pat, s))
print('=== %s : %d 处 ===' % (pat, len(hits)))
for m in hits:
seg = s[max(0, m.start() - 130):m.start() + 130].replace('\n', ' ')
print(' at', m.start(), '|', seg)
+40
View File
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""四种排序各抓 20 张,看「不招本专业」的院校会不会露出来,显示成什么样。"""
import json
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
BASE = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
SORTS = ['gapNear', 'lineUp', 'lineDown', 'plan']
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844})
pg = ctx.new_page()
for s in SORTS:
pg.goto('%s#view=list&major=0856&goal=340&sort=%s' % (BASE, s), wait_until='load')
pg.wait_for_timeout(1300)
info = pg.evaluate("""() => {
const cards = [...document.querySelectorAll('.e-result')].slice(0, 20).map(el => ({
n: (el.querySelector('.e-result-title b') || {}).innerText || '',
line: (el.querySelectorAll('.e-result-metrics b')[0] || {}).innerText || '',
label: (el.querySelector('.e-result-gap small') || {}).innerText || '',
gap: (el.querySelector('.e-result-gap b') || {}).innerText || ''
}));
const empty = cards.filter(c => c.line === '—' || c.line === '');
return {count: cards.length, empty: empty.length, emptySample: empty.slice(0, 4),
first3: cards.slice(0, 3)};
}""")
print('排序 %-9s 卡 %d 张,空 %d 张' % (s, info['count'], info['empty']))
for c in info['first3']:
print(' ', json.dumps(c, ensure_ascii=False))
if info['emptySample']:
print(' 空卡样例:')
for c in info['emptySample']:
print(' ', json.dumps(c, ensure_ascii=False))
b.close()
+98
View File
@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*-
"""补 README:v34(对比页贴近度排序,此前漏记)+ v35(列表专业口径)。"""
import io
P = r'D:\择校\docs\研选E决策层_20261112\README.md'
s = io.open(P, encoding='utf-8').read()
assert '## v34' not in s and '## v35' not in s, 'README 已有 v34/v35'
ADD = '''
## v34(2026-11-13):对比页该先说「谁离我最近」
稿 `37_对比页贴近度排序.png`。
### 问题
对比页把选中的 2–4 所院校并排列指标,但顺序是用户点选的先后。四列并排、指标七八行,眼睛要来回扫才能拼出「哪所最够得着」。而用户来对比页要问的第一个问题恰恰是这个。
### 做法
加一个排序开关「按分差排序」,按各校与目标分的贴近程度重排:
- 卡头挂「近 1 / 近 2」的序位徽标,一眼看出梯队次序;
- 没有本专业复试线的院校没有分差可比,统一沉到最后、标「无分差」,不参与排序;
- 开关关掉就回到点选顺序,不做隐式重排。
### 验证
排序开关与序位徽标落在同一份 `cmpSort` 状态上,切换后四列同步重排;无分差院校始终在末位,不会因为排序而插进有数的一列中间。
### 仍未做
- 排序状态不持久化,刷新回默认。
## v35(2026-11-17):907 所里有 545 所根本不招我这个专业
稿 `38_列表专业口径.png`(以实现实拍为参考图生成)。
### 问题
院校库顶部「分差视角」写的是「本专业开设 362 所」,列表标题写的却是「共 907 所院校」。同一个页面、上下相隔 10px,两个数字差 545 所。选了 0856 材料与化工的人,看到的是全库 907 所——其中 545 所在 2027 官方目录里没有 0856。
实测把 907 张卡全加载出来:**547 张的三个指标位(2026 复试线 / 2027 拟招 / 距录取均分)全是灰色横杠「—」**,标签还写着「目标分差」。也就是说用户滑到后面,屏幕上是六成的空卡。底部的说明行只提「850 所有校园影像,其余 57 所为科研院所、军工单位、党校」,一个字没提专业开设情况。
数据本身没有编造——空卡显示的是「—」而不是别的专业的分数线,这一点是对的。但把 545 张「—」和 362 张真数据混在一张长列表里,等于让用户自己筛。
### 做法
口径统一到「本专业」,并把「不招」这件事明确说出来,而不是用横杠糊过去:
1. **标题改两段式**:主数字 `362 所` + `开设 0856 材料与化工`;只在看全部时补一行 10.5px 的 `另有 545 所院校在 2027 目录中没有 0856`。
2. **未开设院校换矮卡**:不再占一张整卡的位置摆三个横杠。左边 56×56 的书本图标占位,校名后挂 `未开设 0856` 标签,下面一行说明「2027 官方目录里这所学校没有 0856,分数线与拟招人数不适用」,右下角「看该校其他专业 ›」。不再出现三个指标块,也不出现对比与收藏。实测 89px,正常卡 110px。
3. **两批之间加分隔带**:`以下 545 所院校在 2027 目录里没有 0856,排在最后`,40px 高、浅灰蓝底。数字取全池的未开设数,不取当前已加载的那一段,否则滚到一半会显示「以下 1 所」。
4. **默认只看本专业**:`onlyMajor` 从「没存过就当关」改成「没存过就当开」,新用户进来就是 362 所。
### 根因:一条 URL 解析把默认值吃掉了
改完默认值,开关状态还是错的。查下去是 `updateFromUrl()` 里这一行:
```js
onlyMajor = qs.get('om') === '1';
```
**无条件赋值**。任何不带 `om` 参数的链接——站内跳转、刷新、分享出去的短链——都会把 `onlyMajor` 置成 `false`,前面刚定的默认值当场作废。改成 `if (qs.has('om')) onlyMajor = qs.get('om') === '1';`:只有链接显式写了 `om` 才覆盖。
顺带把「清空筛选」和「切专业」两处从 `onlyMajor = false` 改成 `true`:换了专业还继续显示「没有这个专业的 545 所」,跟默认口径正好相反。
还有一处:开关的显示条件是「当前池里有未开设的院校」(`offN > 0`)。默认只看本专业时池子里全是开设的,`offN` 恒为 0,开关直接不渲染——用户被锁在 362 所里,没有任何入口切回全部。改成看全库的未开设数 `offAll = S.length - Object.keys(D).length`,只要库里有不招这个专业的院校,开关就在。
### 复审
- 干净 localStorage 冷启动:标题 `362 所 开设 0856 材料与化工`、开关关闭、无矮卡、`#view=list` 落到 362 所口径;
- 打开开关:副行出现 `另有 545 所…`、开关转开、矮卡与分隔带随之出现;再关掉回到 362;
- 切专业口径跟随:0805 → 252 所(另有 655)、0301 → 208 所(另有 699),主数字与专业名同步;
- 320 宽校名不换行(`沈阳航空航天…` 省略号收尾),此前 320 下「沈阳航空航天大学」被挤成两行、把「保 / 沈阳」标签推到卡外;
- 390 / 320、浅色 / 深色都不横向溢出,页面错误 0。
### 两处刻意的取舍
- **默认看本专业,不是默认看全部**。既然用户已经选了专业,「院校库」的语境就是「给我这个专业找学校」。907 所里 545 所不招,先摆给他是噪音。要看全部,开关就在标题右边。
- **空卡不删,改成矮卡**。直接过滤掉会让用户以为库里没这所学校(比如中国人民大学确实在这个库里,只是 2027 目录没有 0856)。留一张矮卡 + 「看该校其他专业」,既省掉 60% 的纵向空间,又保留了「这学校在库里」这个事实。
### 验证
`ui_v35_list_scope.py`(施加改动)、`ui_v35_verify.py`(30 项:口径一致性 / 矮卡形态 / 分隔带 / 开关联动 / 320 深色无溢出)、`ui_v35_verify2.py`(12 项:干净态默认、开关往返、切专业跟随、无方向明细专业不崩)。两套共 42 项全 PASS。
### 仍未做
- 「距录取均分 ±0」在排序靠前的几张卡上连着出现(0856 里正好 5 所录取均分等于 340),视觉上像没数据。措辞可改成「持平」,但 `gapText` 在对比页和详情页共用,要一起评估。
- 开关在两个地方出现且语义相反:更多筛选里是「仅看本专业开设」,标题行是「也看没开设的」。同一个 `onlyMajor`,`aria-checked` 各算各的,读屏用户容易绕晕。
- 分隔带只在「有数据 / 无数据」交界处插一条;如果将来允许按城市、标签筛到只剩无数据的院校,这条带会消失,需要另给空态。
- 均分含推免与专项未剔除(老问题)。
'''
s = s.rstrip('\n') + ADD
io.open(P, 'w', encoding='utf-8').write(s)
print('README 追加完成,%d → %d 字符' % (31031, len(s)))
+40
View File
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""量对比页已选院校行在 390 / 320 下是否被裁(chips 容器溢出即被裁)。"""
from pathlib import Path
from playwright.sync_api import sync_playwright
base = Path('D:/择校/docs/择校UI/index.html').as_uri()
out = Path('D:/择校/运行暂存/ui_round35_cmpsort_20261116')
errs = []
with sync_playwright() as p:
b = p.chromium.launch(executable_path='C:/Program Files/Google/Chrome/Application/chrome.exe',
headless=True, args=['--allow-file-access-from-files'])
for w in (390, 360, 320):
for cnt, cmpids in ((3, '197,514,92'), (4, '197,514,92,88'), (2, '197,514')):
for sort in (0, 1):
pg = b.new_page(viewport={'width': w, 'height': 844}, device_scale_factor=2)
pg.on('pageerror', lambda e: errs.append(str(e)))
pg.add_init_script("localStorage.setItem('zexiao_major','0856'); localStorage.setItem('zexiao_goal','340');"
+ ("localStorage.setItem('zexiao_cmpsort','1');" if sort else "localStorage.setItem('zexiao_cmpsort','0');"))
pg.goto(base + f'#view=cmp&major=0856&no=197&theme=light&goal=340&cmp={cmpids}', wait_until='load')
pg.wait_for_timeout(700)
m = pg.evaluate("""() => {
const c = document.querySelector('.compare-chips');
const row = document.querySelector('.compare-selection');
const btn = document.querySelector('.cmp-sort');
return {
overflow: c ? c.scrollWidth - c.clientWidth : null,
rowW: row ? Math.round(row.getBoundingClientRect().width) : null,
chipsW: c ? Math.round(c.getBoundingClientRect().width) : null,
btnW: btn ? Math.round(btn.getBoundingClientRect().width) : null,
doc: document.documentElement.scrollWidth
};
}""")
flag = '裁' if (m['overflow'] or 0) > 0 else 'ok'
print(f"w={w} 院校={cnt} 排序={sort} chips溢出={m['overflow']} 行宽={m['rowW']} chips={m['chipsW']} 按钮={m['btnW']} doc={m['doc']} {flag}")
if cnt == 3 and w == 390:
pg.screenshot(path=str(out / f'row_390_{cnt}_{sort}.png'),
clip={'x': 0, 'y': 0, 'width': w, 'height': 844}, full_page=True)
pg.close()
print('errors:', errs)
b.close()
+159
View File
@@ -0,0 +1,159 @@
# -*- coding: utf-8 -*-
"""v34 验证:对比页「按分差排序」/ 引导页目标分措辞 / 三档口径展开态持久化。
390 浅色 + 390 深色 + 320 浅色,另加 300 分制专业下按钮不出场的检查。"""
from pathlib import Path
import re
from playwright.sync_api import sync_playwright
root = Path('D:/择校')
base = (root / 'docs/择校UI/index.html').as_uri()
out = root / '运行暂存/ui_round35_cmpsort_20261116'
out.mkdir(exist_ok=True)
errs = []
fails = []
CMP_HASH = '#view=cmp&major=0856&no=197&theme=light&goal=340&cmp=197,514,92'
def seed(pg, extra=''):
pg.add_init_script("localStorage.setItem('zexiao_major','0856'); localStorage.setItem('zexiao_goal','340');" + extra)
with sync_playwright() as p:
b = p.chromium.launch(executable_path='C:/Program Files/Google/Chrome/Application/chrome.exe',
headless=True, args=['--allow-file-access-from-files'])
def shot(name, h, w, extra, dsf=2, height=844):
pg = b.new_page(viewport={'width': w, 'height': height}, device_scale_factor=dsf)
pg.on('pageerror', lambda e: errs.append(f'{name}: {e}'))
seed(pg, extra)
pg.goto(base + h, wait_until='load')
pg.wait_for_timeout(1600)
pg.screenshot(path=str(out / f'{name}_{w}.png'), full_page=True)
wide = pg.evaluate('document.documentElement.scrollWidth')
if wide > w + 1:
fails.append(f'{name}@{w} 横向溢出 wide={wide}')
return pg
def names(pg):
return pg.eval_on_selector_all('.compare-table .cmp .col .compare-school-name', 'els => els.map(e => e.textContent.trim())')
def nears(pg):
return pg.eval_on_selector_all('.compare-table .cmp .col .cmp-near', 'els => els.map(e => e.textContent.trim())')
# 1) 排序关(默认)
pg = shot('cmp_off', CMP_HASH, 390, "")
off_names = names(pg)
has_btn = pg.eval_on_selector_all('.cmp-sort', 'els => els.length')
btn_txt = pg.eval_on_selector_all('.cmp-sort', 'els => els.map(e => e.textContent.trim() + "|" + e.getAttribute("aria-pressed"))')
near_off = nears(pg)
print('off names:', off_names, 'sort btn:', has_btn, btn_txt, 'near:', near_off)
if has_btn != 1 or btn_txt[0].startswith('分差最近优先'):
fails.append('排序关闭态按钮文案/数量不对')
if near_off:
fails.append('排序关闭态不该出现近 N 徽标')
# 2) 点按钮打开排序
pg.click('.cmp-sort')
pg.wait_for_timeout(600)
on_names = names(pg)
near_on = nears(pg)
btn_on = pg.eval_on_selector('.cmp-sort', 'e => e.textContent.trim() + "|" + e.getAttribute("aria-pressed")')
note = pg.eval_on_selector_all('.cmp-verdict .cmp-sort-note', 'els => els.map(e => e.textContent.trim())')
print('on names:', on_names, 'near:', near_on, 'btn:', btn_on, 'note:', note)
print('ls cmpsort =', pg.evaluate("localStorage.getItem('zexiao_cmpsort')"))
if pg.evaluate("localStorage.getItem('zexiao_cmpsort')") != '1':
fails.append('排序开关没写 localStorage')
if not on_names or len(near_on) != len(on_names):
fails.append('开启后近 N 徽标数量与列数不一致')
else:
seq = [t for t in near_on if t != '无分差']
if seq != [f'近 {i+1}' for i in range(len(seq))]:
fails.append(f'近 N 徽标序号不对: {near_on}')
if '无分差' in near_on and near_on.index('无分差') < len(seq):
fails.append(f'「无分差」应排在最后: {near_on}')
if not note:
fails.append('开启后结论卡缺少排序提示')
# 3) 排序顺序与「分差绝对值升序」是否一致
data = pg.evaluate("""() => {
const rows = [...document.querySelectorAll('.compare-table .cmprow')];
const r = rows.find(x => x.querySelector('.k') && x.querySelector('.k').textContent.includes('目标分差'));
if (!r) return null;
return [...r.querySelectorAll('.c')].map(c => c.textContent.trim());
}""")
print('分差行(排序后):', data)
def dist(s):
m = re.search(r'-?\d+(?:\.\d+)?', str(s).replace('−', '-'))
return abs(float(m.group())) if m else None
ds = [dist(x) for x in (data or []) if x and dist(x) is not None]
if ds != sorted(ds):
fails.append(f'分差行未按绝对值升序: {ds}')
# 4) reload 后保持排序
pg.reload(wait_until='load')
pg.wait_for_timeout(1200)
print('reload names:', names(pg), 'btn:', pg.eval_on_selector('.cmp-sort', 'e => e.getAttribute("aria-pressed")'))
if pg.eval_on_selector('.cmp-sort', 'e => e.getAttribute("aria-pressed")') != 'true':
fails.append('刷新后排序开关没保持')
pg.screenshot(path=str(out / 'cmp_on_390.png'), full_page=True)
pg.close()
# 5) 深色 + 320 宽
pg = shot('cmp_on_dark', '#view=cmp&major=0856&no=197&theme=dark&goal=340&cmp=197,514,92', 390,
"localStorage.setItem('zexiao_cmpsort','1');")
pg.close()
pg = shot('cmp_on_320', CMP_HASH, 320, "localStorage.setItem('zexiao_cmpsort','1');", dsf=3, height=640)
print('320 names:', names(pg), 'near:', nears(pg))
pg.close()
# 6) 300 分制专业(1251):按钮与徽标都不出场
pg = shot('cmp_300', '#view=cmp&major=1251&theme=light&goal=340&cmp=197,514,92', 390,
"localStorage.setItem('zexiao_major','1251'); localStorage.setItem('zexiao_cmpsort','1');")
n300 = pg.eval_on_selector_all('.cmp-sort', 'els => els.length')
near300 = pg.eval_on_selector_all('.cmp-near', 'els => els.length')
print('300 分制 sort btn:', n300, 'near:', near300, 'error hint:', pg.eval_on_selector_all('.state-empty h3', 'els => els.map(e => e.textContent.trim())'))
if n300 or near300:
fails.append('300 分制专业不该出现排序按钮或近 N 徽标')
pg.close()
# 7) 三档口径展开态持久化
for label, extra, expect_open in [('tierdef_closed', "", False), ('tierdef_open', "localStorage.setItem('zexiao_tierdef','1');", True)]:
pg = b.new_page(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg.on('pageerror', lambda e: errs.append(f'{label}: {e}'))
seed(pg, extra)
pg.goto(base + '#view=home&major=0856&no=514&theme=light&goal=340', wait_until='load')
pg.wait_for_timeout(1400)
open_now = pg.eval_on_selector_all('.tier-def-full', 'els => els.length')
print(label, '刷新后展开块数:', open_now)
if bool(open_now) != expect_open:
fails.append(f'{label} 刷新后展开态与预期不符: {open_now}')
if label == 'tierdef_closed':
pg.click('.tier-def-toggle')
pg.wait_for_timeout(500)
ls = pg.evaluate("localStorage.getItem('zexiao_tierdef')")
print('点击后 localStorage zexiao_tierdef =', ls, '展开块数=',
pg.eval_on_selector_all('.tier-def-full', 'els => els.length'))
if ls != '1':
fails.append('点击展开未写入 zexiao_tierdef')
pg.screenshot(path=str(out / 'tierdef_open_390.png'), full_page=True)
pg.close()
# 8) 引导页目标分措辞:未存过 / 存过
for label, extra, expect in [
('onb_nosave', "", '先用默认目标分 340'),
('onb_saved', "localStorage.setItem('zexiao_goal','365');", '沿用你上次设置的目标分 365'),
]:
pg = b.new_page(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg.on('pageerror', lambda e: errs.append(f'{label}: {e}'))
pg.add_init_script("localStorage.clear(); localStorage.removeItem('zexiao_major');" + extra)
pg.goto(base + '#view=home&no=514&theme=light', wait_until='load')
pg.wait_for_timeout(1400)
txt = pg.eval_on_selector_all('.onboarding-note', 'els => els.map(e => e.textContent.trim())')
print(label, txt)
if not txt or expect not in txt[0]:
fails.append(f'{label} 措辞不符预期: {txt}')
pg.screenshot(path=str(out / f'{label}_390.png'), full_page=True)
pg.close()
print('errors:', errs)
print('fails:', fails)
b.close()
Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

+40
View File
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
"""round34 现状实拍:引导页 / 首页 / 院校库 / 详情 / 对比 / 我的,390 浅色 + 两处深色。"""
from pathlib import Path
from playwright.sync_api import sync_playwright
root = Path('D:/择校')
base = (root / 'docs/择校UI/index.html').as_uri()
out = root / '运行暂存/ui_round34_20261116'
out.mkdir(exist_ok=True)
errs = []
SHOTS = [
('onboarding', '#view=home&no=514&theme=light', False),
('home', '#view=home&major=0856&no=514&theme=light&goal=340', True),
('list', '#view=list&major=0856&no=514&theme=light&goal=340', True),
('detail', '#view=detail&major=0856&no=197&theme=light&goal=340', True),
('cmp', '#view=cmp&major=0856&no=197&theme=light&goal=340&cmp=197,514,92', True),
('mine', '#view=mine&major=0856&no=514&theme=light&goal=340', True),
('home_dark', '#view=home&major=0856&no=514&theme=dark&goal=340', True),
('cmp_dark', '#view=cmp&major=0856&no=197&theme=dark&goal=340&cmp=197,514,92', True),
]
with sync_playwright() as p:
b = p.chromium.launch(executable_path='C:/Program Files/Google/Chrome/Application/chrome.exe',
headless=True, args=['--allow-file-access-from-files'])
for name, h, seeded in SHOTS:
pg = b.new_page(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg.on('pageerror', lambda e: errs.append(str(e)))
if seeded:
pg.add_init_script("localStorage.setItem('zexiao_major','0856'); localStorage.setItem('zexiao_goal','340');")
else:
pg.add_init_script("localStorage.clear();")
pg.goto(base + h, wait_until='load')
pg.wait_for_timeout(1800)
pg.screenshot(path=str(out / f'{name}_390.png'), full_page=True)
print(name, 'wide=', pg.evaluate('document.documentElement.scrollWidth'), 'h=',
pg.evaluate('document.body.scrollHeight'))
pg.close()
print('errors:', errs)
b.close()
Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

+58
View File
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
"""截第 35 轮基线:院校库 → 详情页,390 宽浅色/深色各一张。"""
import os
from urllib.parse import quote
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
OUT = os.path.join(ROOT, '运行暂存', 'ui_round35_20261117')
os.makedirs(OUT, exist_ok=True)
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
def shot(pg, name):
path = os.path.join(OUT, name)
pg.screenshot(path=path, full_page=False)
print(' ->', name, os.path.getsize(path) // 1024, 'KB')
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True,
args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg = ctx.new_page()
errs = []
pg.on('pageerror', lambda e: errs.append(str(e)))
# 1. 院校库
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1200)
shot(pg, '01_list.png')
print(' 列表卡片数:', pg.eval_on_selector_all('.l-card, .list-card, [data-no]', 'e=>e.length'))
print(' 正文长度:', len(pg.inner_text('body')))
# 2. 点第一张卡进详情
clicked = pg.evaluate("""() => {
const el = document.querySelector('.l-card a, .l-card, [data-no]');
if (!el) return 'no card';
const no = el.getAttribute('data-no');
if (no) { location.hash = 'view=detail&major=0856&goal=340&no=' + no; return 'goto ' + no; }
el.click();
return 'clicked';
}""")
print(' 进详情:', clicked)
pg.wait_for_timeout(1500)
shot(pg, '02_detail.png')
print(' 详情文本长度:', len(pg.inner_text('body')))
print(' 详情首屏文本:', pg.inner_text('body')[:400].replace('\n', ' | '))
# 3. 深色
pg.goto(URL + '#view=detail&major=0856&goal=340&theme=dark&no=' + (clicked.split()[-1] if clicked.startswith('goto') else '10001'),
wait_until='load')
pg.wait_for_timeout(1200)
shot(pg, '03_detail_dark.png')
print(' 页面错误:', errs if errs else '无')
b.close()
Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

+49
View File
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
"""v35 收尾修正:默认只看本专业、320 下校名不换行、标题行收成两行。"""
import io
P = r'D:\择校\docs\择校UI\index.html'
s = io.open(P, encoding='utf-8').read()
def sub(old, new, tag):
global s
assert old in s, '锚点缺失:' + tag
assert s.count(old) == 1, '锚点不唯一:%s' % tag
s = s.replace(old, new)
print('OK', tag)
# 1. onlyMajor 默认开:没存过偏好就按「只看本专业」
sub("let onlyMajor = localStorage.getItem('zexiao_onlymajor') === '1';",
"let onlyMajor = localStorage.getItem('zexiao_onlymajor') !== '0';",
'onlyMajor 默认值')
# 2. 标题行布局:左块(主数字+副行)与右块(开关+上下文)同一行,左右分栏
sub('''.list-count-row{display:block}
.list-count-main{font-size:13px;font-weight:700;color:#16233a;letter-spacing:-.2px}''',
'''.list-count-row{display:flex;align-items:flex-start;gap:10px}
.list-count-left{min-width:0;flex:1}
.list-count-main{font-size:13px;font-weight:700;color:#16233a;letter-spacing:-.2px}''',
'标题行分栏')
sub('''.list-count-right{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:6px}''',
'''.list-count-right{display:flex;flex-direction:column;align-items:flex-end;gap:6px;flex:none}''',
'右块竖排')
# 3. 320 下校名不换行:让 b 可压缩并省略
sub('.e-result-title b{font-family:SimSun,serif;',
'.e-result-title b{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:0 1 auto;font-family:SimSun,serif;',
'校名省略')
# 4. 标题行结构体:左块 + 右块
sub(''' <div class="list-count-main"><b>${offerN}</b> 所<span>开设 ${esc(mName())}</span></div>
${offN ? `<div class="list-count-sub">另有 ${offN} 所院校在 2027 目录中没有 ${esc(major)}</div>` : ''}
<div class="list-count-right"><div>${offN ? `<label class="list-om"><span>也看没开设的</span><button type="button" data-om="1" role="switch" aria-label="也看没开设本专业的院校" aria-checked="${!onlyMajor}"></button></label>` : ''}</div><div class="list-context"><span title="${esc(act.join(' · '))}">${act.length ? '筛选条件:'+esc(act.join(' · ')) : '全部院校'}</span><button data-reset-list>清空</button></div></div>''',
''' <div class="list-count-left"><div class="list-count-main"><b>${offerN}</b> 所<span>开设 ${esc(mName())}</span></div>
${offN ? `<div class="list-count-sub">另有 ${offN} 所院校在 2027 目录中没有 ${esc(major)}</div>` : ''}</div>
<div class="list-count-right">${offN ? `<label class="list-om"><span>也看没开设的</span><button type="button" data-om="1" role="switch" aria-label="也看没开设本专业的院校" aria-checked="${!onlyMajor}"></button></label>` : ''}<div class="list-context"><span title="${esc(act.join(' · '))}">${act.length ? '筛选条件:'+esc(act.join(' · ')) : '全部院校'}</span><button data-reset-list>清空</button></div></div>''',
'标题行结构')
io.open(P, 'w', encoding='utf-8').write(s)
print('写入完成,%d 字节' % len(s))
+27
View File
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""修:默认只看本专业后,开关没了入口——开关是否出现不能依赖当前池里的未开设数。"""
import io
P = r'D:\择校\docs\择校UI\index.html'
s = io.open(P, encoding='utf-8').read()
old = """ const hasM = x => !!(D && D[String(x.no)]);
const offerN = arr.filter(hasM).length;
const offN = arr.length - offerN;"""
new = """ const hasM = x => !!(D && D[String(x.no)]);
const offerN = arr.filter(hasM).length;
const offN = arr.length - offerN;
// 开关要在「只看本专业」时也留着,否则切不回全部
const offAll = D ? Math.max(0, S.length - Object.keys(D).length) : 0;"""
assert old in s, '锚点缺失'
assert s.count(old) == 1
s = s.replace(old, new)
old2 = '<div class="list-count-right">${offN ? `<label class="list-om">'
new2 = '<div class="list-count-right">${offAll ? `<label class="list-om">'
assert old2 in s, '锚点缺失:开关条件'
assert s.count(old2) == 1
s = s.replace(old2, new2)
io.open(P, 'w', encoding='utf-8').write(s)
print('写入完成')
+31
View File
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
"""修根因:URL 解析时 `onlyMajor = qs.get('om') === '1'` 无条件覆盖默认值,
导致任何不带 om 的链接(包括站内跳转)都把「只看本专业」关掉。"""
import io
P = r'D:\择校\docs\择校UI\index.html'
s = io.open(P, encoding='utf-8').read()
def sub(old, new, tag, cnt=1):
global s
assert old in s, '锚点缺失:' + tag
assert s.count(old) == cnt, '锚点计数不符:%s(%d≠%d)' % (tag, s.count(old), cnt)
s = s.replace(old, new)
print('OK', tag)
sub(" onlyMajor = qs.get('om') === '1';",
" if (qs.has('om')) onlyMajor = qs.get('om') === '1';",
'URL om 仅在显式给出时生效')
sub("tierSel = ''; onlyMajor = false; localStorage.setItem('zexiao_onlymajor', '0');",
"tierSel = ''; onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1');",
'清空筛选后回到只看本专业')
sub("if (key === 'major') { onlyMajor = false; localStorage.setItem('zexiao_onlymajor', '0'); }",
"if (key === 'major') { onlyMajor = true; localStorage.setItem('zexiao_onlymajor', '1'); }",
'切专业后回到只看本专业')
io.open(P, 'w', encoding='utf-8').write(s)
print('写入完成')
+100
View File
@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
"""v35 实现:院校库列表的专业口径。
三处改动:
1. 标题行从「共 907 所院校」改成「362 所 开设 0856 … 另有 545 所…」+ 开关
2. 不招本专业的院校改成矮卡(书本图标 + 未开设标签 + 说明 + 看其他专业)
3. 两批之间加分组分隔带
"""
import io
P = r'D:\择校\docs\择校UI\index.html'
s = io.open(P, encoding='utf-8').read()
orig_len = len(s)
def sub(old, new, tag):
global s
assert old in s, '锚点缺失:' + tag
assert s.count(old) == 1, '锚点不唯一:%s(%d 处)' % (tag, s.count(old))
s = s.replace(old, new)
print('OK', tag)
# ---------- 1. CSS ----------
CSS = '''
/* v35 列表专业口径:标题两段式、未开设矮卡、分组分隔带 */
.list-count-row{display:block}
.list-count-main{font-size:13px;font-weight:700;color:#16233a;letter-spacing:-.2px}
.list-count-main b{font-size:17px;font-weight:800;color:#1c3faa;margin-right:2px}
.list-count-main span{font-size:11.5px;font-weight:400;color:#5b6678;margin-left:6px}
.list-count-sub{font-size:10.5px;color:#8792a4;margin-top:3px;line-height:1.4}
.list-count-right{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:6px}
.list-om{display:inline-flex;align-items:center;gap:6px;font-size:10px;color:#6b7485;cursor:pointer}
.list-om button{position:relative;width:30px;height:16px;border-radius:9px;border:1px solid #cfd8e6;background:#eef2f8;padding:0;cursor:pointer;flex:none}
.list-om button::after{content:"";position:absolute;top:1px;left:1px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(16,30,54,.2);transition:transform .16s}
.list-om button[aria-checked="true"]{background:#1c3faa;border-color:#1c3faa}
.list-om button[aria-checked="true"]::after{transform:translateX(14px)}
.e-result-off{padding:10px 12px;min-height:0;gap:10px}
.e-off-icon{width:56px;height:56px;flex:none;border-radius:10px;background:#eef2f8;border:1px solid #dbe3ee;display:flex;align-items:center;justify-content:center;padding:0;cursor:pointer}
.e-off-icon svg{width:24px;height:24px;fill:none;stroke:#9aa8bd;stroke-width:1.6;stroke-linejoin:round}
.e-result-off .e-result-title{gap:6px}
.e-off-tag{font-size:9.5px;font-weight:600;color:#7b8798;background:#eef2f8;border-radius:4px;padding:1px 5px;line-height:1.5;flex:none}
.e-off-note{font-size:11px;color:#8792a4;line-height:1.5;margin-top:3px}
.e-off-more{font-size:11px;color:#1c3faa;text-align:right;margin-top:5px;cursor:pointer}
.e-result-off .e-result-body{gap:0}
.list-off-bar{display:flex;align-items:center;justify-content:center;height:40px;margin:10px 0 8px;border-radius:10px;background:#eef2f8;font-size:11px;color:#6b7485}
body.dark .list-count-main{color:#e6ecf5}
body.dark .list-count-main b{color:#8fb4ff}
body.dark .list-count-main span,body.dark .list-count-sub,body.dark .e-off-note{color:#93a1b8}
body.dark .list-om{color:#93a1b8}
body.dark .list-om button{background:#2a3446;border-color:#3d4a60}
body.dark .e-off-icon{background:#232c3b;border-color:#333f52}
body.dark .e-off-icon svg{stroke:#6b7a91}
body.dark .e-off-tag{background:#2a3446;color:#9aa8bd}
body.dark .e-off-more{color:#8fb4ff}
body.dark .list-off-bar{background:#232c3b;color:#93a1b8}
'''
sub('</style>', CSS + '</style>', 'CSS 追加')
# ---------- 2. row() 支持未开设矮卡 ----------
OLD_ROW = "function row(x) {\n return `<div class=\"item e-result\">"
NEW_ROW = '''function row(x, hasM) {
if (hasM === false) {
return `<div class="item e-result e-result-off">
<button type="button" class="e-off-icon" data-go="${x.no}" aria-label="查看${esc(x.name)}"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A1.5 1.5 0 0 1 5.5 4H10v16H5.5A1.5 1.5 0 0 1 4 18.5zM20 5.5A1.5 1.5 0 0 0 18.5 4H14v16h4.5A1.5 1.5 0 0 0 20 18.5z"/><path d="M12 4v16"/></svg></button>
<div class="e-result-body"><div class="e-result-title" data-go="${x.no}"><b>${x.name}</b><span class="e-off-tag">未开设 ${esc(major)}</span><i>›</i></div>
<div class="e-off-note">2027 官方目录里这所学校没有 ${esc(major)},分数线与拟招人数不适用</div>
<div class="e-off-more" data-go="${x.no}">看该校其他专业 ›</div></div></div>`;
}
return `<div class="item e-result">'''
sub(OLD_ROW, NEW_ROW, 'row 未开设分支')
# ---------- 3. 标题行 ----------
OLD_HEAD = '<div class="list-count-row"><div class="e-count">共 <b>${onlyMajor && !nOffer ? \'—\' : listTotal}</b> 所院校</div><div class="list-context"><span title="${esc(act.join(\' · \'))}">${act.length ? \'筛选条件:\'+esc(act.join(\' · \')) : \'全部院校\'}</span><button data-reset-list>清空</button></div></div>'
NEW_HEAD = '''${(() => {
const hasM = x => !!(D && D[String(x.no)]);
const offerN = arr.filter(hasM).length;
const offN = arr.length - offerN;
return `<div class="list-count-row">
<div class="list-count-main"><b>${offerN}</b> 所<span>开设 ${esc(mName())}</span></div>
${offN ? `<div class="list-count-sub">另有 ${offN} 所院校在 2027 目录中没有 ${esc(major)}</div>` : ''}
<div class="list-count-right"><div>${offN ? `<label class="list-om"><span>也看没开设的</span><button type="button" data-om="1" role="switch" aria-label="也看没开设本专业的院校" aria-checked="${!onlyMajor}"></button></label>` : ''}</div><div class="list-context"><span title="${esc(act.join(' · '))}">${act.length ? '筛选条件:'+esc(act.join(' · ')) : '全部院校'}</span><button data-reset-list>清空</button></div></div>
</div>`;
})()}'''
sub(OLD_HEAD, NEW_HEAD, '标题行')
# ---------- 4. 分组渲染 + 分隔带 ----------
OLD_MAP = '${shownArr.length? shownArr.map(row).join(\'\')'
NEW_MAP = '''${shownArr.length? (() => {
const hasM = x => !!(D && D[String(x.no)]);
const on = shownArr.filter(hasM), off = shownArr.filter(x => !hasM(x));
const bar = (on.length && off.length) ? `<div class="list-off-bar">以下 ${off.length} 所院校在 2027 目录里没有 ${esc(major)},排在最后</div>` : '';
return on.map(x => row(x, true)).join('') + bar + off.map(x => row(x, false)).join('');
})()'''
sub(OLD_MAP, NEW_MAP, '分组渲染')
io.open(P, 'w', encoding='utf-8').write(s)
print('\n写入完成:%d → %d 字节(+%d)' % (orig_len, len(s), len(s) - orig_len))
+38
View File
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
"""补截图:滚到分隔带与矮卡所在位置,浅色 + 深色。"""
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
OUT = os.path.join(ROOT, '运行暂存', 'ui_round35_20261117')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
for dark in (False, True):
ctx = b.new_context(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg = ctx.new_page()
pg.goto(URL + '#view=list&major=0856&goal=340' + ('&theme=dark' if dark else ''), wait_until='load')
pg.wait_for_timeout(1300)
# 滚到分隔带出现并居中
for i in range(24):
pg.mouse.move(195, 600)
pg.mouse.wheel(0, 6000)
pg.wait_for_timeout(480)
bar = pg.query_selector('.list-off-bar')
if bar and bar.bounding_box() and bar.bounding_box()['y'] > 150:
break
pg.evaluate("""() => {
const b = document.querySelector('.list-off-bar');
if (b) b.scrollIntoView({block: 'start'});
const el = document.getElementById('screen');
if (el) el.scrollTop -= 260;
}""")
pg.wait_for_timeout(600)
name = '06_bar_%s.png' % ('dark' if dark else 'light')
pg.screenshot(path=os.path.join(OUT, name))
print(name, '分隔带:', pg.inner_text('.list-off-bar') if pg.query_selector('.list-off-bar') else '未出现')
ctx.close()
b.close()
+87
View File
@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
"""v35 复审(已更新):默认只看本专业 → 先开开关,再验未开设那一批;320/390 深浅色。"""
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
OUT = os.path.join(ROOT, '运行暂存', 'ui_round35_20261117')
os.makedirs(OUT, exist_ok=True)
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
results = []
def chk(name, cond, detail=''):
results.append((name, bool(cond), detail))
print(('PASS ' if cond else 'FAIL ') + name + (' ' + str(detail) if detail else ''))
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
for w, tag in [(390, '390'), (320, '320')]:
ctx = b.new_context(viewport={'width': w, 'height': 844}, device_scale_factor=2)
pg = ctx.new_page()
errs = []
pg.on('pageerror', lambda e: errs.append(str(e)))
pg.goto(URL + '#view=list&major=0856&goal=340&om=0', wait_until='load')
pg.wait_for_timeout(1400)
head = pg.inner_text('.list-count-row')
print('\n[%s] 标题行:' % tag, head.replace('\n', ' | '))
chk('[%s] 标题主数字是 362 所' % tag, '362' in head)
chk('[%s] 副行提到 545 所' % tag, '545' in head)
chk('[%s] 不再出现「共 907 所院校」' % tag, '共 907' not in head)
chk('[%s] 分差视角与本专业口径一致' % tag, '本专业开设 362 所' in pg.inner_text('body'))
for i in range(20):
pg.mouse.move(w // 2, 600)
pg.mouse.wheel(0, 6000)
pg.wait_for_timeout(500)
if pg.query_selector('.list-off-bar'):
break
bar = pg.query_selector('.list-off-bar')
chk('[%s] 分隔带出现' % tag, bar is not None, pg.inner_text('.list-off-bar') if bar else '')
if bar:
chk('[%s] 分隔带文案含 545' % tag, '545' in pg.inner_text('.list-off-bar'))
offcard = pg.query_selector('.e-result-off')
chk('[%s] 未开设矮卡出现' % tag, offcard is not None)
if offcard:
txt = offcard.inner_text().replace('\n', ' | ')
print(' 矮卡:', txt)
chk('[%s] 矮卡有「未开设」标签' % tag, '未开设 0856' in txt)
chk('[%s] 矮卡有看其他专业入口' % tag, '看该校其他专业' in txt)
chk('[%s] 矮卡不再有三指标' % tag, ('2026 复试线' not in txt) and ('距录取均分' not in txt))
h_off = offcard.bounding_box()['height']
h_on = pg.query_selector('.e-result:not(.e-result-off)').bounding_box()['height']
chk('[%s] 矮卡明显比正常卡矮' % tag, h_off < h_on * 0.85, '%.0f vs %.0f' % (h_off, h_on))
# 关掉开关 → 回到只看本专业
sw = pg.query_selector('.list-om button')
if sw:
sw.click()
pg.wait_for_timeout(900)
after = pg.inner_text('.list-count-row')
chk('[%s] 关掉后不再提「另有」' % tag, '另有' not in after, after.replace('\n', ' | '))
chk('[%s] 关掉后无矮卡' % tag, pg.query_selector('.e-result-off') is None)
pg.goto(URL + '#view=list&major=0856&goal=340&om=0' + ('&theme=dark' if tag == '390' else ''),
wait_until='load')
pg.wait_for_timeout(1200)
name = '05_list_%s%s.png' % (tag, '_dark' if tag == '390' else '')
pg.screenshot(path=os.path.join(OUT, name))
ovf = pg.evaluate("() => document.documentElement.scrollWidth - document.documentElement.clientWidth")
chk('[%s] 无横向溢出' % tag, ovf <= 1, 'overflow=%d' % ovf)
chk('[%s] 页面无 JS 错误' % tag, not errs, errs[:2])
ctx.close()
b.close()
print('\n=== 汇总 ===')
fails = [r for r in results if not r[1]]
print('通过 %d / %d' % (len(results) - len(fails), len(results)))
for n, ok, d in fails:
print(' FAIL', n, d)
+78
View File
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
"""干净 localStorage 下的默认态复审 + 开关往返 + 切专业口径跟随。"""
import os
from playwright.sync_api import sync_playwright
ROOT = r'D:\择校'
URL = 'file:///' + os.path.join(ROOT, 'docs', '择校UI', 'index.html').replace('\\', '/')
OUT = os.path.join(ROOT, '运行暂存', 'ui_round35_20261117')
CHROME = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
results = []
def chk(n, c, d=''):
results.append((n, bool(c), d))
print(('PASS ' if c else 'FAIL ') + n + (' ' + str(d) if d else ''))
with sync_playwright() as p:
b = p.chromium.launch(executable_path=CHROME, headless=True, args=['--allow-file-access-from-files'])
ctx = b.new_context(viewport={'width': 390, 'height': 844}, device_scale_factor=2)
pg = ctx.new_page()
errs = []
pg.on('pageerror', lambda e: errs.append(str(e)))
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1400)
head = pg.inner_text('.list-count-row').replace('\n', ' | ')
print('干净态标题:', head)
cnt = pg.eval_on_selector_all('.e-result', 'e=>e.length')
sw = pg.query_selector('.list-om button')
chk('新用户默认只看本专业(卡片 80,池 362)', cnt == 80, cnt)
chk('默认态不出现「另有」副行', '另有' not in head, head)
chk('默认态开关存在(能切回全部)', sw is not None)
chk('默认态开关是关的', sw.get_attribute('aria-checked') == 'false' if sw else False,
sw.get_attribute('aria-checked') if sw else '无')
chk('默认态无未开设矮卡', pg.query_selector('.e-result-off') is None)
# 打开开关 → 看全部
sw.click()
pg.wait_for_timeout(900)
head2 = pg.inner_text('.list-count-row').replace('\n', ' | ')
chk('打开后出现「另有 545 所」', '545' in head2, head2)
chk('打开后开关为开', pg.query_selector('.list-om button').get_attribute('aria-checked') == 'true')
# 再关闭
pg.query_selector('.list-om button').click()
pg.wait_for_timeout(900)
chk('再关掉又只剩本专业', '另有' not in pg.inner_text('.list-count-row'))
# 切专业:看 0805 口径是否跟着走
pg.goto(URL + '#view=list&major=0805&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
h805 = pg.inner_text('.list-count-row').replace('\n', ' | ')
print('0805 标题:', h805)
chk('切专业后主数字跟着变', '362' not in h805.split('另有')[0], h805.split('另有')[0])
chk('切专业后专业名跟着变', '0805' in h805 or '材料科学与工程' in pg.inner_text('body'))
# 无方向明细的专业(走空态)
pg.goto(URL + '#view=list&major=0301&goal=340', wait_until='load')
pg.wait_for_timeout(1500)
t = pg.inner_text('body')
chk('0301 不崩、有内容', len(t) > 500, len(t))
print('0301 标题:', pg.inner_text('.list-count-row').replace('\n', ' | ') if pg.query_selector('.list-count-row') else '无')
chk('全程无 JS 错误', not errs, errs[:2])
pg.goto(URL + '#view=list&major=0856&goal=340', wait_until='load')
pg.wait_for_timeout(1300)
pg.screenshot(path=os.path.join(OUT, '08_default_390.png'))
ctx.close()
b.close()
print('\n通过 %d / %d' % (sum(1 for r in results if r[1]), len(results)))
for n, ok, d in results:
if not ok:
print(' FAIL', n, d)