feat: 模型列表按名称排序,同名称按大小升序

This commit is contained in:
developer
2026-04-04 22:09:15 +08:00
parent dcb66df200
commit e435f0f1a0
+14 -8
View File
@@ -54,14 +54,20 @@ export async function loadModels() {
return;
}
data.models.forEach(m => {
const opt = document.createElement('option');
opt.value = m.name;
const diskSize = formatSize(m.size);
const label = diskSize ? `${m.name} · ${diskSize}` : m.name;
opt.textContent = label;
modelSelectEl.appendChild(opt);
});
data.models
.sort((a, b) => {
const nameA = a.name.toLowerCase(), nameB = b.name.toLowerCase();
if (nameA !== nameB) return nameA.localeCompare(nameB);
return (a.size || 0) - (b.size || 0);
})
.forEach(m => {
const opt = document.createElement('option');
opt.value = m.name;
const diskSize = formatSize(m.size);
const label = diskSize ? `${m.name} · ${diskSize}` : m.name;
opt.textContent = label;
modelSelectEl.appendChild(opt);
});
// 恢复上次选择的模型
const currentSession = state.get(KEYS.CURRENT_SESSION);