mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
feat(providers): order preset selector — official first, prime partner next
In the default (Original) sort mode, float official-category presets to the very top, followed by prime partners (Kimi), then the rest in their original array order. Implemented as a three-way partition+concat so each group keeps its internal order and no preset is listed twice.
This commit is contained in:
@@ -88,7 +88,21 @@ export function sortPresetEntries(
|
||||
t: PresetTranslator,
|
||||
): PresetEntry[] {
|
||||
if (sortMode === PresetSortMode.Original) {
|
||||
return [...entries];
|
||||
// 置顶优先级:官方分类 > 尊享合作伙伴(Kimi)> 其余原顺序。
|
||||
// 用分区拼接而非排序,确保每组内部各自的相对顺序都不变;
|
||||
// 排他条件保证「既是官方又是 prime」的预设只归入官方组、不被重复。
|
||||
const official = entries.filter(
|
||||
(entry) => entry.preset.category === "official",
|
||||
);
|
||||
const prime = entries.filter(
|
||||
(entry) =>
|
||||
entry.preset.category !== "official" && entry.preset.primePartner,
|
||||
);
|
||||
const rest = entries.filter(
|
||||
(entry) =>
|
||||
entry.preset.category !== "official" && !entry.preset.primePartner,
|
||||
);
|
||||
return [...official, ...prime, ...rest];
|
||||
}
|
||||
|
||||
return [...entries].sort((a, b) =>
|
||||
|
||||
Reference in New Issue
Block a user