mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-31 19:22:15 +08:00
feat(providers): group presets into sponsors and non-sponsors
- Original sort mode now shows official > prime partner > sponsors (preset file order, aligned with the README sponsor table) > non-sponsors sorted by display name - Physically reorder sponsor entries in all 8 preset files to match the README sponsor table order; add group marker comments - Drop stale section comments in openclaw/hermes preset files - Update ProviderPresetSelector tests for the new ordering
This commit is contained in:
@@ -87,10 +87,16 @@ export function sortPresetEntries(
|
||||
sortMode: PresetSortMode,
|
||||
t: PresetTranslator,
|
||||
): PresetEntry[] {
|
||||
const byDisplayName = (a: PresetEntry, b: PresetEntry) =>
|
||||
getPresetDisplayName(a.preset, t).localeCompare(
|
||||
getPresetDisplayName(b.preset, t),
|
||||
);
|
||||
|
||||
if (sortMode === PresetSortMode.Original) {
|
||||
// 置顶优先级:官方分类 > 尊享合作伙伴(Kimi)> 其余原顺序。
|
||||
// 用分区拼接而非排序,确保每组内部各自的相对顺序都不变;
|
||||
// 排他条件保证「既是官方又是 prime」的预设只归入官方组、不被重复。
|
||||
// 置顶优先级:官方分类 > 尊享合作伙伴(Kimi)> 其余赞助商 > 非赞助商。
|
||||
// 前三组用分区拼接而非排序,保持各自在预设文件里的相对顺序
|
||||
// (赞助商的文件顺序与 README 赞助商表对齐);非赞助商按显示名排序。
|
||||
// 排他条件保证同时命中多组的预设只归入最前面的组、不被重复。
|
||||
const official = entries.filter(
|
||||
(entry) => entry.preset.category === "official",
|
||||
);
|
||||
@@ -98,18 +104,24 @@ export function sortPresetEntries(
|
||||
(entry) =>
|
||||
entry.preset.category !== "official" && entry.preset.primePartner,
|
||||
);
|
||||
const rest = entries.filter(
|
||||
const partner = entries.filter(
|
||||
(entry) =>
|
||||
entry.preset.category !== "official" && !entry.preset.primePartner,
|
||||
entry.preset.category !== "official" &&
|
||||
!entry.preset.primePartner &&
|
||||
entry.preset.isPartner,
|
||||
);
|
||||
return [...official, ...prime, ...rest];
|
||||
const rest = entries
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.preset.category !== "official" &&
|
||||
!entry.preset.primePartner &&
|
||||
!entry.preset.isPartner,
|
||||
)
|
||||
.sort(byDisplayName);
|
||||
return [...official, ...prime, ...partner, ...rest];
|
||||
}
|
||||
|
||||
return [...entries].sort((a, b) =>
|
||||
getPresetDisplayName(a.preset, t).localeCompare(
|
||||
getPresetDisplayName(b.preset, t),
|
||||
),
|
||||
);
|
||||
return [...entries].sort(byDisplayName);
|
||||
}
|
||||
|
||||
export interface PresetVisibilityOptions {
|
||||
|
||||
Reference in New Issue
Block a user