Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat(league): Meta tab with client-recommended runes and champion tiers
tonhowtfb641f79d2ee9
diff --git a/src-tauri/omniget-core/src/models/settings.rs b/src-tauri/omniget-core/src/models/settings.rsindex 0bf2cc3d..cbe79ee2 100644--- a/src-tauri/omniget-core/src/models/settings.rs+++ b/src-tauri/omniget-core/src/models/settings.rs@@ -46,6 +46,8 @@ pub struct LeagueSettings {#[serde(default)]pub auto_lock: bool,#[serde(default)]+ pub auto_runes: bool,+ #[serde(default)]pub pick_champions: Vec<i64>,#[serde(default)]pub ban_champions: Vec<i64>,diff --git a/src-tauri/src/commands/league/mod.rs b/src-tauri/src/commands/league/mod.rsindex 3fc1ffb1..406f9b14 100644--- a/src-tauri/src/commands/league/mod.rs+++ b/src-tauri/src/commands/league/mod.rs@@ -735,6 +735,7 @@ pub async fn league_player_report(puuid: String) -> Result<Value, String> {),).await;+ let mut history_ids: Vec<i64> = Vec::new();let (stats, private_profile) = match history {Ok(h) => {let games: Vec<Value> = h@@ -743,11 +744,44 @@ pub async fn league_player_report(puuid: String) -> Result<Value, String> {.and_then(Value::as_array).cloned().unwrap_or_default();+ history_ids = games+ .iter()+ .filter_map(|g| g.get("gameId").and_then(Value::as_i64))+ .collect();(compute_history_stats(&games, &puuid), games.is_empty())}Err(_) => (json!({ "games": 0, "insights": [] }), true),};+ // Impact needs team totals, which only the full game detail carries, so it+ // is computed over a small sample instead of the whole history.+ let recent_ids: Vec<i64> = history_ids.into_iter().take(5).collect();+ let mut impact_tasks = Vec::new();+ for game_id in recent_ids {+ let task_client = client.clone();+ let task_puuid = puuid.clone();+ impact_tasks.push(tauri::async_runtime::spawn(async move {+ let detail = lcu_get_raw(+ &task_client,+ &format!("/lol-match-history/v1/games/{}", game_id),+ )+ .await+ .ok()?;+ impact_from_detail(&detail, &task_puuid)+ }));+ }+ let mut impacts: Vec<f64> = Vec::new();+ for task in impact_tasks {+ if let Ok(Some(score)) = task.await {+ impacts.push(score);+ }+ }+ let impact = if impacts.is_empty() {+ Value::Null+ } else {+ json!(((impacts.iter().sum::<f64>() / impacts.len() as f64) * 10.0).round() / 10.0)+ };+let mastery = lcu_get_raw(&client,&format!("/lol-champion-mastery/v1/{}/champion-mastery", puuid),@@ -776,6 +810,8 @@ pub async fn league_player_report(puuid: String) -> Result<Value, String> {"flex": flex,"stats": stats,"mastery": mastery,+ "impact": impact,+ "impactGames": impacts.len(),"privateProfile": private_profile,}))}@@ -1133,6 +1169,63 @@ pub async fn league_live_metrics() -> Result<Value, String> {}))}+/// Computes the composite impact score for one player in one finished game.+fn impact_from_detail(detail: &Value, puuid: &str) -> Option<f64> {+ let identities = detail.get("participantIdentities")?.as_array()?;+ let participants = detail.get("participants")?.as_array()?;+ let pid = identities+ .iter()+ .find(|i| {+ i.get("player")+ .and_then(|p| p.get("puuid"))+ .and_then(Value::as_str)+ == Some(puuid)+ })+ .and_then(|i| i.get("participantId").and_then(Value::as_i64))?;+ let me = participants+ .iter()+ .find(|p| p.get("participantId").and_then(Value::as_i64) == Some(pid))?;+ let team_id = me.get("teamId").and_then(Value::as_i64)?;+ let team: Vec<&Value> = participants+ .iter()+ .filter(|p| p.get("teamId").and_then(Value::as_i64) == Some(team_id))+ .collect();+ if team.is_empty() {+ return None;+ }++ let stat = |p: &Value, key: &str| -> f64 {+ p.get("stats")+ .and_then(|s| s.get(key))+ .and_then(Value::as_f64)+ .unwrap_or(0.0)+ };+ let sum = |key: &str| -> f64 { team.iter().map(|p| stat(p, key)).sum() };+ let count = |p: &Value, key: &str| -> u32 { stat(p, key).max(0.0) as u32 };++ let input = stats::ImpactInput {+ kills: count(me, "kills"),+ deaths: count(me, "deaths"),+ assists: count(me, "assists"),+ team_kills: sum("kills").max(0.0) as u32,+ damage_to_champions: stat(me, "totalDamageDealtToChampions"),+ team_damage: sum("totalDamageDealtToChampions"),+ damage_taken: stat(me, "totalDamageTaken"),+ team_damage_taken: sum("totalDamageTaken"),+ gold: stat(me, "goldEarned"),+ team_gold: sum("goldEarned"),+ cs: stat(me, "totalMinionsKilled") + stat(me, "neutralMinionsKilled"),+ vision_score: stat(me, "visionScore"),+ team_vision: sum("visionScore"),+ duration_seconds: detail+ .get("gameDuration")+ .and_then(Value::as_f64)+ .unwrap_or(0.0),+ team_size: team.len(),+ };+ Some(stats::impact_score(&input))+}+/// Aggregates a player's champion records the way a profile page shows them.fn champion_records_from_history(games: &[Value]) -> Vec<analysis::ChampionRecord> {let mut map: std::collections::HashMap<i64, analysis::ChampionRecord> =@@ -1744,6 +1837,139 @@ pub async fn league_send_chat(message: String) -> Result<(), String> {Ok(())}+/// Rune and summoner-spell setups the game client itself recommends.+///+/// This is the client's own recommendation engine, so it always matches the+/// installed patch and comes localized — no scraping involved.+#[tauri::command]+pub async fn league_rune_recommendations(+ champion_id: i64,+ position: Option<String>,+) -> Result<Value, String> {+ ensure_enabled()?;+ let client = get_client().await?;+ let pos = position+ .map(|p| p.to_ascii_uppercase())+ .filter(|p| !p.is_empty())+ .unwrap_or_else(|| "NONE".to_string());+ let path = format!(+ "/lol-perks/v1/recommended-pages/champion/{}/position/{}/map/11",+ champion_id, pos+ );+ let pages = lcu_get_raw(&client, &path).await?;++ let list: Vec<Value> = pages+ .as_array()+ .map(|arr| {+ arr.iter()+ .map(|p| {+ let perks: Vec<i64> = p+ .get("perks")+ .and_then(Value::as_array)+ .map(|a| a.iter().filter_map(|x| x.get("id").and_then(Value::as_i64)).collect())+ .unwrap_or_default();+ json!({+ "recommendationId": p.get("recommendationId"),+ "keystoneId": p.get("keystone").and_then(|k| k.get("id")),+ "keystoneName": p.get("keystone").and_then(|k| k.get("name")),+ "primaryStyleId": p.get("primaryPerkStyleId"),+ "subStyleId": p.get("secondaryPerkStyleId"),+ "selectedPerkIds": perks,+ "summonerSpellIds": p.get("summonerSpellIds"),+ "primaryAttribute": p.get("primaryRecommendationAttribute"),+ "secondaryAttribute": p.get("secondaryRecommendationAttribute"),+ "isDefault": p.get("isDefaultPosition"),+ })+ })+ .collect()+ })+ .unwrap_or_default();++ Ok(json!({ "championId": champion_id, "position": pos, "pages": list }))+}++/// Champion tier rankings, per position, from op.gg's public champion API.+///+/// The response is passed through with only the fields the UI needs; the+/// numeric `tier` (1 = best) is what op.gg renders as S+/S/A and friends.+#[tauri::command]+pub async fn league_champion_tiers(+ region: Option<String>,+ tier: Option<String>,+) -> Result<Value, String> {+ ensure_enabled()?;+ let region = region.unwrap_or_else(|| "br".to_string());+ let bracket = tier.unwrap_or_else(|| "emerald_plus".to_string());+ if !region.chars().all(|c| c.is_ascii_alphanumeric())+ || !bracket.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')+ {+ return Err("invalid region or tier".to_string());+ }+ let url = format!(+ "https://lol-api-champion.op.gg/api/{}/champions/ranked?tier={}",+ region, bracket+ );+ let http = reqwest::Client::builder()+ .timeout(std::time::Duration::from_secs(20))+ .user_agent("OmniGet")+ .build()+ .map_err(|e| e.to_string())?;+ let resp = http+ .get(&url)+ .send()+ .await+ .map_err(|e| format!("tier list unavailable: {}", e))?;+ if !resp.status().is_success() {+ return Err(format!("tier list returned {}", resp.status().as_u16()));+ }+ let body = resp+ .json::<Value>()+ .await+ .map_err(|e| format!("invalid tier list response: {}", e))?;++ let entries: Vec<Value> = body+ .get("data")+ .and_then(Value::as_array)+ .map(|arr| {+ arr.iter()+ .filter_map(|c| {+ let id = c.get("id").and_then(Value::as_i64)?;+ let positions: Vec<Value> = c+ .get("positions")+ .and_then(Value::as_array)+ .map(|ps| {+ ps.iter()+ .filter_map(|p| {+ let stats = p.get("stats")?;+ Some(json!({+ "position": p.get("name"),+ "tier": stats.get("tier_data").and_then(|t| t.get("tier")),+ "rank": stats.get("tier_data").and_then(|t| t.get("rank")),+ "winRate": stats.get("win_rate"),+ "pickRate": stats.get("pick_rate"),+ "banRate": stats.get("ban_rate"),+ "roleRate": stats.get("role_rate"),+ "games": stats.get("play"),+ }))+ })+ .collect()+ })+ .unwrap_or_default();+ if positions.is_empty() {+ return None;+ }+ Some(json!({ "championId": id, "positions": positions }))+ })+ .collect()+ })+ .unwrap_or_default();++ if entries.is_empty() {+ return Err("tier list returned no champions".to_string());+ }+ Ok(json!({ "region": region, "bracket": bracket, "champions": entries }))+}+#[tauri::command]pub async fn league_auto_accept_set(enabled: bool) -> Result<(), String> {ensure_enabled()?;diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 6c08dd3b..ea1c5080 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -731,6 +731,8 @@ pub fn run() {commands::league::league_jungle_report,commands::league::league_apply_runes,commands::league::league_send_chat,+ commands::league::league_rune_recommendations,+ commands::league::league_champion_tiers,commands::bilibili_auth::bilibili_qr_generate,commands::bilibili_auth::bilibili_qr_poll,commands::bilibili_auth::bilibili_captcha_challenge,diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.jsonindex 97118a79..017a4435 100644--- a/src/lib/i18n/el.json+++ b/src/lib/i18n/el.json@@ -37,6 +37,23 @@"nav_downloads": "Μετάβαση στις Λήψεις"},"league": {+ "tab_meta": "Μέτα",+ "runes_title": "Runes",+ "runes_desc": "Σελίδες runes και summoner spells που προτείνει ο ίδιος ο client του παιχνιδιού για τον ήρωα που κλείδωσες, πάντα στο τρέχον patch.",+ "runes_auto": "Αυτόματη εφαρμογή runes",+ "runes_auto_desc": "Όταν κλειδώνεις ήρωα, η πρώτη προτεινόμενη σελίδα δημιουργείται και επιλέγεται.",+ "runes_apply": "Εφαρμογή",+ "runes_default": "προεπιλογή",+ "runes_spells": "Spells",+ "runes_empty": "Κλείδωσε έναν ήρωα στην επιλογή για να δεις προτεινόμενες σελίδες.",+ "tiers_title": "Tiers ηρώων",+ "tiers_desc": "Κατάταξη ανά ρόλο με ποσοστά νίκης, επιλογής και ban. Δεδομένα από op.gg.",+ "tiers_position": "Θέση",+ "tiers_pick": "επιλογή",+ "tiers_ban": "ban",+ "tiers_empty": "Η λίστα tier δεν είναι διαθέσιμη τώρα.",+ "impact_label": "Επίδραση",+ "impact_hint": "Σύνθεση KDA, συμμετοχής σε kills, ζημιάς, ζημιάς που δέχτηκε, χρυσού, vision και CS, σε κλίμακα 0-10","tab_search": "Αναζήτηση","search_title": "Εύρεση παίκτη","search_placeholder": "Riot ID, π.χ. Faker#KR1",diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.jsonindex a7fffb57..303b2922 100644--- a/src/lib/i18n/en.json+++ b/src/lib/i18n/en.json@@ -37,6 +37,23 @@"nav_downloads": "Go to Downloads"},"league": {+ "tab_meta": "Meta",+ "runes_title": "Runes",+ "runes_desc": "Rune pages and summoner spells recommended by the game client itself for the champion you locked, so they always match the current patch.",+ "runes_auto": "Apply runes automatically",+ "runes_auto_desc": "When you lock a champion, the first recommended page is created and selected for you.",+ "runes_apply": "Apply",+ "runes_default": "default",+ "runes_spells": "Spells",+ "runes_empty": "Lock a champion in champion select to see recommended pages.",+ "tiers_title": "Champion tiers",+ "tiers_desc": "Ranking by role, with win, pick and ban rates. Data from op.gg.",+ "tiers_position": "Position",+ "tiers_pick": "pick",+ "tiers_ban": "ban",+ "tiers_empty": "Tier list unavailable right now.",+ "impact_label": "Impact",+ "impact_hint": "Composite of KDA, kill participation, damage, damage taken, gold, vision and CS share, scored 0-10","tab_search": "Search","search_title": "Find a player","search_placeholder": "Riot ID, e.g. Faker#KR1",diff --git a/src/lib/i18n/es.json b/src/lib/i18n/es.jsonindex f9a9777c..3f2ac6b7 100644--- a/src/lib/i18n/es.json+++ b/src/lib/i18n/es.json@@ -37,6 +37,23 @@"nav_downloads": "Ir a Descargas"},"league": {+ "tab_meta": "Meta",+ "runes_title": "Runas",+ "runes_desc": "Páginas de runas y hechizos recomendados por el propio cliente del juego para el campeón que bloqueaste, siempre del parche actual.",+ "runes_auto": "Aplicar runas automáticamente",+ "runes_auto_desc": "Al bloquear un campeón, se crea y selecciona la primera página recomendada.",+ "runes_apply": "Aplicar",+ "runes_default": "predeterminada",+ "runes_spells": "Hechizos",+ "runes_empty": "Bloquea un campeón en la selección para ver las páginas recomendadas.",+ "tiers_title": "Tiers de campeones",+ "tiers_desc": "Ranking por rol, con tasas de victoria, elección y baneo. Datos de op.gg.",+ "tiers_position": "Posición",+ "tiers_pick": "elección",+ "tiers_ban": "baneo",+ "tiers_empty": "Lista de tiers no disponible ahora.",+ "impact_label": "Impacto",+ "impact_hint": "Compuesto de KDA, participación en asesinatos, daño, daño recibido, oro, visión y CS, en escala 0-10","tab_search": "Buscar","search_title": "Buscar jugador","search_placeholder": "Riot ID, p. ej. Faker#KR1",diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.jsonindex a341d3f3..3b043ba6 100644--- a/src/lib/i18n/fr.json+++ b/src/lib/i18n/fr.json@@ -37,6 +37,23 @@"nav_downloads": "Aller aux Téléchargements"},"league": {+ "tab_meta": "Méta",+ "runes_title": "Runes",+ "runes_desc": "Pages de runes et sorts recommandés par le client du jeu lui-même pour le champion verrouillé, toujours au patch actuel.",+ "runes_auto": "Appliquer les runes automatiquement",+ "runes_auto_desc": "Au verrouillage d'un champion, la première page recommandée est créée et sélectionnée.",+ "runes_apply": "Appliquer",+ "runes_default": "par défaut",+ "runes_spells": "Sorts",+ "runes_empty": "Verrouillez un champion en sélection pour voir les pages recommandées.",+ "tiers_title": "Tiers des champions",+ "tiers_desc": "Classement par rôle, avec taux de victoire, de sélection et de bannissement. Données op.gg.",+ "tiers_position": "Position",+ "tiers_pick": "sélection",+ "tiers_ban": "ban",+ "tiers_empty": "Liste de tiers indisponible pour le moment.",+ "impact_label": "Impact",+ "impact_hint": "Composite de KDA, participation aux kills, dégâts, dégâts subis, or, vision et CS, noté de 0 à 10","tab_search": "Rechercher","search_title": "Trouver un joueur","search_placeholder": "Riot ID, ex. Faker#KR1",diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.jsonindex aef0391d..4a92e1a7 100644--- a/src/lib/i18n/it.json+++ b/src/lib/i18n/it.json@@ -37,6 +37,23 @@"nav_downloads": "Vai ai Download"},"league": {+ "tab_meta": "Meta",+ "runes_title": "Rune",+ "runes_desc": "Pagine rune e incantesimi consigliati dal client del gioco per il campione bloccato, sempre alla patch corrente.",+ "runes_auto": "Applica rune automaticamente",+ "runes_auto_desc": "Quando blocchi un campione, la prima pagina consigliata viene creata e selezionata.",+ "runes_apply": "Applica",+ "runes_default": "predefinita",+ "runes_spells": "Incantesimi",+ "runes_empty": "Blocca un campione nella selezione per vedere le pagine consigliate.",+ "tiers_title": "Tier dei campioni",+ "tiers_desc": "Classifica per ruolo, con percentuali di vittoria, scelta e ban. Dati da op.gg.",+ "tiers_position": "Posizione",+ "tiers_pick": "scelta",+ "tiers_ban": "ban",+ "tiers_empty": "Tier list non disponibile al momento.",+ "impact_label": "Impatto",+ "impact_hint": "Composto di KDA, partecipazione alle uccisioni, danni, danni subiti, oro, visione e CS, su scala 0-10","tab_search": "Cerca","search_title": "Trova giocatore","search_placeholder": "Riot ID, es. Faker#KR1",diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.jsonindex 0512741f..d3f5b09d 100644--- a/src/lib/i18n/ja.json+++ b/src/lib/i18n/ja.json@@ -37,6 +37,23 @@"nav_downloads": "ダウンロードへ移動"},"league": {+ "tab_meta": "メタ",+ "runes_title": "ルーン",+ "runes_desc": "ロックしたチャンピオン向けにゲームクライアント自身が推奨するルーンページとサモナースペル。常に現行パッチ準拠です。",+ "runes_auto": "ルーンを自動適用",+ "runes_auto_desc": "チャンピオンをロックすると、最初の推奨ページが作成され選択されます。",+ "runes_apply": "適用",+ "runes_default": "既定",+ "runes_spells": "スペル",+ "runes_empty": "チャンピオン選択でロックすると推奨ページが表示されます。",+ "tiers_title": "チャンピオンティア",+ "tiers_desc": "ロール別ランキング(勝率・ピック率・バン率)。データ提供: op.gg。",+ "tiers_position": "ポジション",+ "tiers_pick": "ピック",+ "tiers_ban": "バン",+ "tiers_empty": "ティアリストは現在利用できません。",+ "impact_label": "インパクト",+ "impact_hint": "KDA・キル関与・与ダメージ・被ダメージ・ゴールド・視界・CSの合成指標(0〜10)","tab_search": "検索","search_title": "プレイヤー検索","search_placeholder": "Riot ID(例: Faker#KR1)",diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.tsindex f153a5c2..22628d55 100644--- a/src/lib/i18n/keys.ts+++ b/src/lib/i18n/keys.ts@@ -408,6 +408,8 @@ export type TranslationKeys =| 'league.gold_unavailable'| 'league.history_empty'| 'league.history_title'+ | 'league.impact_hint'+ | 'league.impact_label'| 'league.jungle_empty'| 'league.jungle_gank3'| 'league.jungle_invade'@@ -449,6 +451,14 @@ export type TranslationKeys =| 'league.role_middle'| 'league.role_top'| 'league.role_utility'+ | 'league.runes_apply'+ | 'league.runes_auto'+ | 'league.runes_auto_desc'+ | 'league.runes_default'+ | 'league.runes_desc'+ | 'league.runes_empty'+ | 'league.runes_spells'+ | 'league.runes_title'| 'league.scout_allies'| 'league.scout_enemies'| 'league.scout_enemies_hidden'@@ -481,6 +491,7 @@ export type TranslationKeys =| 'league.tab_goals'| 'league.tab_history'| 'league.tab_live'+ | 'league.tab_meta'| 'league.tab_overview'| 'league.tab_search'| 'league.tag_cold_streak'@@ -490,6 +501,12 @@ export type TranslationKeys =| 'league.tag_low_kda'| 'league.tag_low_winrate'| 'league.tag_one_trick'+ | 'league.tiers_ban'+ | 'league.tiers_desc'+ | 'league.tiers_empty'+ | 'league.tiers_pick'+ | 'league.tiers_position'+ | 'league.tiers_title'| 'league.unranked'| 'league.victory'| 'league.win_allies'diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.jsonindex f7d75a0a..7fc21ec1 100644--- a/src/lib/i18n/pt.json+++ b/src/lib/i18n/pt.json@@ -37,6 +37,23 @@"nav_downloads": "Ir para Downloads"},"league": {+ "tab_meta": "Meta",+ "runes_title": "Runas",+ "runes_desc": "Páginas de runas e feitiços recomendados pelo próprio cliente do jogo para o campeão que você travou, sempre no patch atual.",+ "runes_auto": "Aplicar runas automaticamente",+ "runes_auto_desc": "Ao travar um campeão, a primeira página recomendada é criada e selecionada para você.",+ "runes_apply": "Aplicar",+ "runes_default": "padrão",+ "runes_spells": "Feitiços",+ "runes_empty": "Trave um campeão na seleção para ver as páginas recomendadas.",+ "tiers_title": "Tiers de campeões",+ "tiers_desc": "Ranking por função, com taxas de vitória, escolha e banimento. Dados do op.gg.",+ "tiers_position": "Posição",+ "tiers_pick": "escolha",+ "tiers_ban": "ban",+ "tiers_empty": "Tier list indisponível no momento.",+ "impact_label": "Impacto",+ "impact_hint": "Composto de KDA, participação em abates, dano, dano recebido, ouro, visão e CS, numa escala de 0 a 10","tab_search": "Buscar","search_title": "Procurar jogador","search_placeholder": "Riot ID, ex.: Faker#KR1",diff --git a/src/lib/i18n/ru.json b/src/lib/i18n/ru.jsonindex 02bc56dc..774773c6 100644--- a/src/lib/i18n/ru.json+++ b/src/lib/i18n/ru.json@@ -37,6 +37,23 @@"nav_downloads": "Перейти к загрузкам"},"league": {+ "tab_meta": "Мета",+ "runes_title": "Руны",+ "runes_desc": "Страницы рун и заклинания, рекомендованные самим клиентом игры для выбранного чемпиона — всегда для текущего патча.",+ "runes_auto": "Применять руны автоматически",+ "runes_auto_desc": "При выборе чемпиона первая рекомендованная страница создаётся и активируется автоматически.",+ "runes_apply": "Применить",+ "runes_default": "по умолчанию",+ "runes_spells": "Заклинания",+ "runes_empty": "Выберите чемпиона, чтобы увидеть рекомендованные страницы.",+ "tiers_title": "Тиры чемпионов",+ "tiers_desc": "Рейтинг по ролям с процентами побед, выборов и банов. Данные op.gg.",+ "tiers_position": "Позиция",+ "tiers_pick": "выбор",+ "tiers_ban": "бан",+ "tiers_empty": "Тир-лист сейчас недоступен.",+ "impact_label": "Влияние",+ "impact_hint": "Composite: KDA, участие в убийствах, урон, полученный урон, золото, обзор и CS по шкале 0-10","tab_search": "Поиск","search_title": "Найти игрока","search_placeholder": "Riot ID, напр. Faker#KR1",diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.jsonindex 5c30088a..6c96835c 100644--- a/src/lib/i18n/zh-TW.json+++ b/src/lib/i18n/zh-TW.json@@ -37,6 +37,23 @@"nav_downloads": "前往下載"},"league": {+ "tab_meta": "版本",+ "runes_title": "符文",+ "runes_desc": "由遊戲客戶端本身為你鎖定的英雄推薦的符文頁與召喚師技能,始終對應目前版本。",+ "runes_auto": "自動套用符文",+ "runes_auto_desc": "鎖定英雄後,自動建立並選取第一個推薦符文頁。",+ "runes_apply": "套用",+ "runes_default": "預設",+ "runes_spells": "召喚師技能",+ "runes_empty": "在英雄選擇中鎖定英雄即可查看推薦符文頁。",+ "tiers_title": "英雄強度榜",+ "tiers_desc": "依位置排名,含勝率、選用率與禁用率。資料來自 op.gg。",+ "tiers_position": "位置",+ "tiers_pick": "選用",+ "tiers_ban": "禁用",+ "tiers_empty": "強度榜暫時無法使用。",+ "impact_label": "影響力",+ "impact_hint": "由 KDA、參團率、輸出、承傷、經濟、視野與補兵合成的 0-10 分指標","tab_search": "搜尋","search_title": "尋找玩家","search_placeholder": "Riot ID,例如 Faker#KR1",diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.jsonindex 11a677a1..f2b7941c 100644--- a/src/lib/i18n/zh.json+++ b/src/lib/i18n/zh.json@@ -37,6 +37,23 @@"nav_downloads": "前往下载"},"league": {+ "tab_meta": "版本",+ "runes_title": "符文",+ "runes_desc": "由游戏客户端本身为你锁定的英雄推荐的符文页与召唤师技能,始终对应当前版本。",+ "runes_auto": "自动应用符文",+ "runes_auto_desc": "锁定英雄后,自动创建并选中第一个推荐符文页。",+ "runes_apply": "应用",+ "runes_default": "默认",+ "runes_spells": "召唤师技能",+ "runes_empty": "在英雄选择中锁定英雄即可查看推荐符文页。",+ "tiers_title": "英雄强度榜",+ "tiers_desc": "按位置排名,含胜率、登场率与禁用率。数据来自 op.gg。",+ "tiers_position": "位置",+ "tiers_pick": "登场",+ "tiers_ban": "禁用",+ "tiers_empty": "强度榜暂时不可用。",+ "impact_label": "影响力",+ "impact_hint": "由 KDA、参团率、输出、承伤、经济、视野和补刀合成的 0-10 分指标","tab_search": "搜索","search_title": "查找玩家","search_placeholder": "Riot ID,例如 Faker#KR1",diff --git a/src/lib/stores/settings-store.svelte.ts b/src/lib/stores/settings-store.svelte.tsindex 77664a0b..df1d2452 100644--- a/src/lib/stores/settings-store.svelte.ts+++ b/src/lib/stores/settings-store.svelte.ts@@ -96,6 +96,7 @@ export type AppSettings = {auto_pick?: boolean;auto_ban?: boolean;auto_lock?: boolean;+ auto_runes?: boolean;pick_champions?: number[];ban_champions?: number[];};diff --git a/src/routes/league/+page.svelte b/src/routes/league/+page.svelteindex 93197a49..d480b572 100644--- a/src/routes/league/+page.svelte+++ b/src/routes/league/+page.svelte@@ -99,7 +99,7 @@];}- const TAB_IDS = ["overview", "analysis", "search", "live", "goals", "automation", "history"] as const;+ const TAB_IDS = ["overview", "analysis", "meta", "search", "live", "goals", "automation", "history"] as const;type Tab = (typeof TAB_IDS)[number];let tab = $state<Tab>("overview");@@ -296,6 +296,168 @@}}+ const TIER_POSITIONS = ["TOP", "JUNGLE", "MID", "ADC", "SUPPORT"] as const;+ let tierPosition = $state<string>("JUNGLE");+ let tiers = $state<any>(null);+ let tiersLoading = $state(false);+ let tiersError = $state("");++ let runePages = $state<any[]>([]);+ let runeApplying = $state(false);+ let runeError = $state("");+ let appliedRuneIndex = $state<number | null>(null);+ let lastRuneChampion = 0;++ let perkMeta = $state<Record<number, string>>({});+ let spellMeta = $state<Record<number, string>>({});++ // Champion the local player has locked in (or hovered) during champ select.+ let champSelectChampionId = $derived.by(() => {+ const cell = champSelect?.localPlayerCellId;+ if (cell === undefined || cell === null) return 0;+ const me = (champSelect?.myTeam ?? []).find((m: any) => m.cellId === cell);+ return me?.championId ?? 0;+ });++ let myAssignedPosition = $derived.by(() => {+ const cell = champSelect?.localPlayerCellId;+ const me = (champSelect?.myTeam ?? []).find((m: any) => m.cellId === cell);+ return (me?.assignedPosition ?? "").toUpperCase();+ });++ function perkName(id: number): string {+ return perkMeta[id] ?? String(id);+ }++ function spellName(id: number): string {+ return spellMeta[id] ?? String(id);+ }++ // op.gg encodes tiers as 1 = best; the labels mirror what their site shows.+ function tierLabel(tier: number): string {+ if (tier <= 1) return "S+";+ if (tier === 2) return "S";+ if (tier === 3) return "A";+ if (tier === 4) return "B";+ if (tier === 5) return "C";+ return "D";+ }++ let tierRows = $derived.by(() => {+ const wanted = tierPosition;+ const rows: any[] = [];+ for (const champ of tiers?.champions ?? []) {+ const entry = (champ.positions ?? []).find((p: any) => (p.position ?? "").toUpperCase() === wanted);+ if (!entry || entry.tier === null || entry.tier === undefined) continue;+ rows.push({+ championId: champ.championId,+ tier: entry.tier,+ rank: entry.rank ?? 999,+ winRate: Math.round((entry.winRate ?? 0) * 1000) / 10,+ pickRate: Math.round((entry.pickRate ?? 0) * 1000) / 10,+ banRate: Math.round((entry.banRate ?? 0) * 1000) / 10,+ });+ }+ rows.sort((a, b) => a.tier - b.tier || a.rank - b.rank);+ return rows.slice(0, 40);+ });++ async function loadTiers() {+ if (tiersLoading) return;+ tiersLoading = true;+ tiersError = "";+ try {+ tiers = await invoke<any>("league_champion_tiers", {+ region: (status.region ?? "br").toLowerCase(),+ });+ } catch (e: any) {+ tiers = null;+ tiersError = typeof e === "string" ? e : (e?.message ?? String(e));+ } finally {+ tiersLoading = false;+ }+ }++ async function loadPerkMeta() {+ try {+ const perks = await invoke<any[]>("league_get", { path: "/lol-perks/v1/perks" });+ const map: Record<number, string> = {};+ for (const p of perks ?? []) map[p.id] = p.name;+ perkMeta = map;+ } catch {+ perkMeta = {};+ }+ try {+ const spells = await invoke<any[]>("league_get", {+ path: "/lol-game-data/assets/v1/summoner-spells.json",+ });+ const map: Record<number, string> = {};+ for (const s of spells ?? []) map[s.id] = s.name;+ spellMeta = map;+ } catch {+ spellMeta = {};+ }+ }++ async function loadRunes(championId: number) {+ if (championId <= 0) {+ runePages = [];+ return;+ }+ runeError = "";+ try {+ const result = await invoke<any>("league_rune_recommendations", {+ championId,+ position: myAssignedPosition || null,+ });+ runePages = result?.pages ?? [];+ appliedRuneIndex = null;+ } catch (e: any) {+ runePages = [];+ runeError = typeof e === "string" ? e : (e?.message ?? String(e));+ }+ }++ async function applyRunePage(index: number) {+ const page = runePages[index];+ if (!page || runeApplying) return;+ runeApplying = true;+ runeError = "";+ try {+ const champName = championById.get(champSelectChampionId)?.name ?? "";+ await invoke("league_apply_runes", {+ name: `${champName} ${page.keystoneName ?? ""}`.trim(),+ primaryStyleId: page.primaryStyleId,+ subStyleId: page.subStyleId,+ selectedPerkIds: page.selectedPerkIds,+ spell1: page.summonerSpellIds?.[0] ?? null,+ spell2: page.summonerSpellIds?.[1] ?? null,+ });+ appliedRuneIndex = index;+ } catch (e: any) {+ runeError = typeof e === "string" ? e : (e?.message ?? String(e));+ } finally {+ runeApplying = false;+ }+ }++ // Load recommendations when the locked champion changes; apply the first one+ // automatically only when the user asked for it.+ $effect(() => {+ const champ = champSelectChampionId;+ if (champ > 0 && champ !== lastRuneChampion) {+ lastRuneChampion = champ;+ loadRunes(champ).then(() => {+ if (settings?.league?.auto_runes && runePages.length > 0) {+ applyRunePage(0);+ }+ });+ } else if (champ === 0 && lastRuneChampion !== 0) {+ lastRuneChampion = 0;+ runePages = [];+ }+ });+const PHASE_KEYS: Record<string, string> = {Lobby: "league.phase_lobby",Matchmaking: "league.phase_matchmaking",@@ -477,7 +639,7 @@}}- function toggleLeagueFlag(field: "auto_pick" | "auto_ban" | "auto_lock") {+ function toggleLeagueFlag(field: "auto_pick" | "auto_ban" | "auto_lock" | "auto_runes") {const current = (settings?.league as any)?.[field] ?? false;updateSettings({ league: { [field]: !current } });}@@ -551,6 +713,7 @@if (!enabled) return;loadNotes();loadGoals();+ loadPerkMeta();invoke<boolean>("league_auto_accept_get").then((v) => { autoAccept = v; }).catch(() => {});@@ -804,7 +967,9 @@{#if r?.stats?.games > 0}<div class="scout-stats"><span class="scout-wr" class:good={r.stats.winrate >= 55} class:bad={r.stats.winrate <= 45}>{r.stats.winrate}% WR</span>- <span class="scout-kda">{r.stats.kda} KDA</span>+ <span class="scout-kda">+ {r.stats.kda} KDA{#if r.impact !== null && r.impact !== undefined} · <span class="impact" title={$t("league.impact_hint") as string}>{r.impact}</span>{/if}+ </span></div>{:else if r?.privateProfile}<span class="scout-private">{$t("league.scout_private")}</span>@@ -841,6 +1006,104 @@{/if}{/if}+ {#if tab === "meta"}+ <section class="card">+ <div class="card-head">+ <h3>{$t("league.runes_title")}</h3>+ {#if champSelectChampionId > 0}+ <span class="phase-tag">{championById.get(champSelectChampionId)?.name ?? champSelectChampionId}</span>+ {/if}+ </div>+ <p class="win-disclaimer">{$t("league.runes_desc")}</p>+ <div class="action-row">+ <div class="action-col">+ <span class="action-label">{$t("league.runes_auto")}</span>+ <span class="action-hint">{$t("league.runes_auto_desc")}</span>+ </div>+ <button+ class="toggle"+ class:on={settings?.league?.auto_runes}+ onclick={() => toggleLeagueFlag("auto_runes")}+ role="switch"+ aria-checked={settings?.league?.auto_runes ?? false}+ aria-label={$t("league.runes_auto") as string}+ >+ <span class="toggle-knob"></span>+ </button>+ </div>+ {#if runeError}+ <p class="action-error" role="alert">{runeError}</p>+ {/if}+ {#if runePages.length > 0}+ <div class="rune-list">+ {#each runePages as page, i (page.recommendationId ?? i)}+ <div class="rune-card" class:applied={appliedRuneIndex === i}>+ <div class="rune-head">+ <span class="rune-keystone">{page.keystoneName ?? page.keystoneId}</span>+ {#if page.isDefault}+ <span class="scout-tag">{$t("league.runes_default")}</span>+ {/if}+ </div>+ <div class="rune-perks">+ {#each page.selectedPerkIds as perkId (perkId)}+ <img+ class="perk-icon"+ src={`${CDRAGON}/perk-images/styles/${perkId}.png`}+ alt=""+ title={perkName(perkId)}+ loading="lazy"+ onerror={(e) => { (e.currentTarget as HTMLImageElement).style.visibility = "hidden"; }}+ />+ {/each}+ </div>+ <div class="rune-foot">+ <span class="dim">{$t("league.runes_spells")}: {(page.summonerSpellIds ?? []).map(spellName).join(" + ")}</span>+ <button class="button" onclick={() => applyRunePage(i)} disabled={runeApplying}>+ {$t("league.runes_apply")}+ </button>+ </div>+ </div>+ {/each}+ </div>+ {:else}+ <p class="empty-hint">{$t("league.runes_empty")}</p>+ {/if}+ </section>++ <section class="card">+ <div class="card-head">+ <h3>{$t("league.tiers_title")}</h3>+ <div class="tier-controls">+ <select class="select-role" bind:value={tierPosition} aria-label={$t("league.tiers_position") as string}>+ {#each TIER_POSITIONS as pos (pos)}+ <option value={pos}>{$t(`league.role_${pos.toLowerCase()}`)}</option>+ {/each}+ </select>+ <button class="button" onclick={loadTiers} disabled={tiersLoading}>{$t("league.refresh")}</button>+ </div>+ </div>+ <p class="win-disclaimer">{$t("league.tiers_desc")}</p>+ {#if tiersError}+ <p class="action-error" role="alert">{tiersError}</p>+ {:else if tierRows.length > 0}+ <div class="champ-table">+ {#each tierRows as row (row.championId)}+ <div class="champ-row">+ <span class={`tier-badge tier-${row.tier}`}>{tierLabel(row.tier)}</span>+ <img class="champ-icon tiny" src={`${CDRAGON}/champion-icons/${row.championId}.png`} alt="" loading="lazy" />+ <span class="champ-row-name">{championById.get(row.championId)?.name ?? row.championId}</span>+ <span class="champ-row-wr" class:good={row.winRate >= 52} class:bad={row.winRate <= 48}>{row.winRate}%</span>+ <span class="champ-row-games dim">{$t("league.tiers_pick")} {row.pickRate}%</span>+ <span class="champ-row-kda dim">{$t("league.tiers_ban")} {row.banRate}%</span>+ </div>+ {/each}+ </div>+ {:else}+ <p class="empty-hint">{tiersLoading ? $t("league.searching_player") : $t("league.tiers_empty")}</p>+ {/if}+ </section>+ {/if}+{#if tab === "search"}<section class="card"><div class="card-head">@@ -901,6 +1164,12 @@<span class="stat-value">{r.stats.streak?.length ?? 0}</span><span class="stat-label">{r.stats.streak?.win ? $t("league.tag_hot_streak") : $t("league.tag_cold_streak")}</span></div>+ {#if r.impact !== null && r.impact !== undefined}+ <div class="stat-cell">+ <span class="stat-value">{r.impact}<span class="dim">/10</span></span>+ <span class="stat-label">{$t("league.impact_label")} ({r.impactGames})</span>+ </div>+ {/if}</div>{#if r.stats.insights?.length}<div class="scout-champs">@@ -2038,6 +2307,98 @@min-width: 180px;}+ .impact {+ color: var(--accent);+ font-weight: 600;+ }++ .rune-list {+ display: flex;+ flex-direction: column;+ gap: 8px;+ margin-top: 10px;+ }++ .rune-card {+ display: flex;+ flex-direction: column;+ gap: 7px;+ padding: 9px 11px;+ background: var(--button);+ border: 1px solid var(--input-border);+ border-radius: calc(var(--border-radius) - 2px);+ }++ .rune-card.applied {+ border-color: var(--accent);+ }++ .rune-head {+ display: flex;+ align-items: center;+ gap: 8px;+ }++ .rune-keystone {+ font-size: 13px;+ font-weight: 600;+ }++ .rune-perks {+ display: flex;+ gap: 5px;+ flex-wrap: wrap;+ }++ .perk-icon {+ width: 26px;+ height: 26px;+ border-radius: 50%;+ background: var(--surface);+ }++ .rune-foot {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 10px;+ font-size: 12px;+ flex-wrap: wrap;+ }++ .tier-controls {+ display: flex;+ gap: 6px;+ align-items: center;+ }++ .tier-badge {+ flex-shrink: 0;+ min-width: 30px;+ text-align: center;+ padding: 2px 6px;+ border-radius: 4px;+ font-size: 11px;+ font-weight: 700;+ background: var(--surface);+ border: 1px solid var(--border);+ }++ .tier-badge.tier-1 {+ color: var(--on-accent);+ background: var(--accent);+ border-color: transparent;+ }++ .tier-badge.tier-2 {+ color: var(--success);+ border-color: var(--success);+ }++ .tier-badge.tier-3 {+ color: var(--text);+ }+.scout-teams {display: grid;grid-template-columns: 1fr 1fr;