feat: 模型列表按名称排序,同名称按大小升序
This commit is contained in:
@@ -54,14 +54,20 @@ export async function loadModels() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.models.forEach(m => {
|
data.models
|
||||||
const opt = document.createElement('option');
|
.sort((a, b) => {
|
||||||
opt.value = m.name;
|
const nameA = a.name.toLowerCase(), nameB = b.name.toLowerCase();
|
||||||
const diskSize = formatSize(m.size);
|
if (nameA !== nameB) return nameA.localeCompare(nameB);
|
||||||
const label = diskSize ? `${m.name} · ${diskSize}` : m.name;
|
return (a.size || 0) - (b.size || 0);
|
||||||
opt.textContent = label;
|
})
|
||||||
modelSelectEl.appendChild(opt);
|
.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);
|
const currentSession = state.get(KEYS.CURRENT_SESSION);
|
||||||
|
|||||||
Reference in New Issue
Block a user