Compare commits

..
19 Commits
Author SHA1 Message Date
KimiSwitch Dev 2f75929fda ci: release 重跑时覆盖同名资产(overwrite: true)
Release / Version consistency (push) Canceled after 0s
Release / Build (macos-latest) (push) Canceled after 0s
Release / Build (ubuntu-latest) (push) Canceled after 0s
Release / Build (windows-latest) (push) Canceled after 0s
2026-08-02 00:38:51 +08:00
KimiSwitch Dev a1c3f06bdf feat(settings): 关于页新增官方网站链接(billowliu2.github.io/KimiSwitch) 2026-08-02 00:37:28 +08:00
KimiSwitch Dev acde6d97c2 merge: Dev_20260801 → main(v0.6.9:仪表盘缓存命中列 + 人民币计价 + 性能优化)
Release / Version consistency (push) Canceled after 0s
Release / Build (macos-latest) (push) Canceled after 0s
Release / Build (ubuntu-latest) (push) Canceled after 0s
Release / Build (windows-latest) (push) Canceled after 0s
2026-08-02 00:18:49 +08:00
KimiSwitch Dev 6cbaea7159 chore: bump v0.6.9 + 官网版本文案/更新日志同步 2026-08-02 00:18:23 +08:00
KimiSwitch Dev f0d5e27bb4 chore: models.dev 价格快照同步 2026-08-02 00:18:22 +08:00
KimiSwitch Dev 38a11666ac feat(dashboard): 最近请求缓存命中列 + 中文模式人民币计价 + 价格解析记忆化
- 最近请求表新增缓存命中率列(缓存读取/总输入)
- useCurrency:中文界面费用按最新 USD→CNY 汇率显示 ¥,英文保持 $(open.er-api.com,缓存 12h,失败兜底 7.2)
- match_price 记忆化缓存:O(记录数×5910) → O(模型种类×5910),扫描从秒级降到百毫秒级
- 仪表盘右上角显示加载耗时/数据量(get_summary 往返埋点);Rust 侧分段计时
2026-08-02 00:18:19 +08:00
KimiSwitch Dev de132ffb3a feat(website): GLM 推广图标换为智谱官方 Z 字标;SEO 关键词补充 Kimi Switch / KimiCode Switch 2026-08-01 20:38:53 +08:00
KimiSwitch Dev a285d192eb feat(website): 首页 Hero 徽标显示 v0.6.8 + 更新日志缓存按版本失效 2026-08-01 20:35:32 +08:00
KimiSwitch Dev 127818a7c3 merge: Dev_20260801 → main(官网 v0.6.8 文案) 2026-08-01 20:32:43 +08:00
KimiSwitch Dev 6bc9e4644e feat(website): 版本号更新到 v0.6.8 + 更新日志内置 v0.6.8 条目
- Nav 下载按钮 / 下载页副标题 / 三平台已发布文案
- 内置更新日志补 v0.6.8(GitHub API 不可达时兜底也能看到最新版本说明)
2026-08-01 20:32:27 +08:00
KimiSwitch Dev dfd41d12c0 merge: Dev_20260801 → main(release.yml 自动发布) 2026-08-01 20:18:32 +08:00
KimiSwitch Dev 615dfb54e0 ci: 去掉 releaseDraft,tag 推送时自动发布 Release
之前 releaseDraft: true 导致每次发版后 release 停在草稿状态,下载直链 404,需手动 PATCH 发布
2026-08-01 20:18:05 +08:00
KimiSwitch Dev 8914b40bec merge: main → Dev_20260801(SEO 升级) 2026-08-01 19:58:47 +08:00
KimiSwitch Dev 4071930aff chore: Cargo.lock 同步 v0.6.8 2026-08-01 19:57:40 +08:00
KimiSwitch Dev 1b5cd0f416 feat(website): SEO 升级 — BrowserRouter + 每页独立 meta
- HashRouter → BrowserRouter(basename /KimiSwitch),GitHub Pages 用 404.html SPA 回退,/features /download /changelog 变为可收录的独立 URL
- 每页独立 title / description / OG / canonical(RouteMeta 随语言切换)
- og:image 改为绝对地址;sitemap 更新为干净路径
2026-08-01 19:56:54 +08:00
KimiSwitch Dev 5788624d12 merge: Dev_20260801 → main(v0.6.8 发布:仪表盘性能优化 + 官网下载页三平台)
Release / Version consistency (push) Canceled after 0s
Release / Build (macos-latest) (push) Canceled after 0s
Release / Build (ubuntu-latest) (push) Canceled after 0s
Release / Build (windows-latest) (push) Canceled after 0s
2026-08-01 19:37:54 +08:00
KimiSwitch Dev beff12a90e chore: bump version to v0.6.8 2026-08-01 19:37:23 +08:00
KimiSwitch Dev 63761e763c feat(website): 下载页支持三平台真实下载链接
- macOS / Linux 由开发中改为已发布,直连 GitHub Releases 资产(.dmg / .deb / .AppImage / .rpm)
- Windows 保留 MSI + 国内镜像双入口
2026-08-01 19:37:21 +08:00
KimiSwitch Dev 1fecb161a9 perf(dashboard): 仪表盘加载提速
- models-dev 快照移出主 bundle(1.35MB→515KB),改为 /models-dev.json 运行时异步加载,就绪后重渲染
- Rust 启动时后台预热价格索引(warm_price_index),首次 get_summary 不再卡
- get_summary 扫描结果 8s TTL 缓存(按 home),切 tab/改范围复用;刷新按钮 refresh=true 强制重扫
2026-08-01 19:37:20 +08:00
33 changed files with 65423 additions and 254 deletions

No files matched your search

+1 -1
View File
@@ -86,6 +86,6 @@ jobs:
- **Linux**: `.deb` / `.AppImage` / `.rpm`
Full changelog: see commit history.
releaseDraft: true
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}
overwrite: true
args: ${{ matrix.args }}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "kimiswitch",
"private": true,
"version": "0.6.7",
"version": "0.6.9",
"type": "module",
"scripts": {
"dev": "vite",
+63986
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1958,7 +1958,7 @@ dependencies = [
[[package]]
name = "kimiswitch"
version = "0.6.7"
version = "0.6.8"
dependencies = [
"anyhow",
"chrono",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "kimiswitch"
version = "0.6.7"
version = "0.6.9"
description = "Kimi Switch - model config manager"
authors = ["you"]
edition = "2021"
+80 -2
View File
@@ -530,6 +530,15 @@ fn models_dev_cost_index() -> &'static HashMap<String, ModelsDevCost> {
})
}
/// Warm the compiled-in models.dev price index off the first dashboard open:
/// parsing the ~1.3 MB snapshot costs tens of milliseconds, so build it on a
/// background thread at startup instead of lazily on the first get_summary.
pub fn warm_price_index() {
std::thread::spawn(|| {
let _ = models_dev_cost_index();
});
}
/// Official providers take precedence over resellers when the same model id
/// ships under multiple providers and no provider prefix disambiguates.
const OFFICIAL_PROVIDERS: &[&str] = &[
@@ -601,7 +610,26 @@ fn strip_context_suffix(model_name: &str) -> Option<String> {
})
}
/// Memoized price resolution. `match_price` is called once per usage record
/// during the scan, and the models.dev suffix scan is O(5910) per miss — with
/// thousands of records sharing a handful of model names, memoizing the result
/// turns the whole scan from O(records × 5910) into O(unique_models × 5910).
static MATCH_PRICE_MEMO: OnceLock<Mutex<HashMap<String, (String, f64, f64, f64, bool)>>> =
OnceLock::new();
/// Resolve a model's price, caching per-model results (hits and misses).
fn match_price(model_name: &str) -> (String, f64, f64, f64, bool) {
let key = model_name.to_ascii_lowercase();
let memo = MATCH_PRICE_MEMO.get_or_init(|| Mutex::new(HashMap::new()));
if let Some(hit) = memo.lock().unwrap().get(&key) {
return hit.clone();
}
let result = match_price_inner(model_name);
memo.lock().unwrap().insert(key, result.clone());
result
}
fn match_price_inner(model_name: &str) -> (String, f64, f64, f64, bool) {
let bare = match model_name.rsplit_once('/') {
Some((_, b)) => b,
None => model_name,
@@ -743,6 +771,45 @@ fn scan_usage(home: &Path) -> (Vec<UsageRecord>, ScanMeta) {
})
}
// ---------------------------------------------------------------------------
// Scan cache
// ---------------------------------------------------------------------------
/// Short-TTL cache for the expensive `scan_usage` walk (reads every
/// wire.jsonl under the sessions root and prices every record). Tab switches
/// call get_summary repeatedly; re-walking the whole tree on every switch is
/// the main dashboard lag. Keyed by home, expires after 8s; `refresh=true`
/// bypasses it.
struct SummaryCacheEntry {
home: String,
scanned_at: std::time::Instant,
records: Vec<UsageRecord>,
meta: ScanMeta,
}
static SUMMARY_CACHE: Mutex<Option<SummaryCacheEntry>> = Mutex::new(None);
const SUMMARY_CACHE_TTL: std::time::Duration = std::time::Duration::from_secs(8);
fn scan_usage_cached(home: &Path, refresh: bool) -> (Vec<UsageRecord>, ScanMeta) {
let home_s = home.to_string_lossy().to_string();
let mut cache = SUMMARY_CACHE.lock().unwrap();
let hit = cache
.as_ref()
.is_some_and(|e| !refresh && e.home == home_s && e.scanned_at.elapsed() < SUMMARY_CACHE_TTL);
if hit {
let e = cache.as_ref().unwrap();
return (e.records.clone(), e.meta.clone());
}
let (records, meta) = scan_usage(home);
*cache = Some(SummaryCacheEntry {
home: home_s,
scanned_at: std::time::Instant::now(),
records: records.clone(),
meta: meta.clone(),
});
(records, meta)
}
// ---------------------------------------------------------------------------
// Aggregate
// ---------------------------------------------------------------------------
@@ -1489,13 +1556,15 @@ pub fn get_prices() -> PricesResult {
#[tauri::command]
pub fn get_summary(home_override: Option<String>, range: Option<String>, refresh: Option<bool>) -> SummaryResult {
let _refresh = refresh.unwrap_or(false);
let t0 = std::time::Instant::now();
let refresh = refresh.unwrap_or(false);
let home = resolve_kimi_home(home_override);
let now_ms = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_millis() as u64;
let r = range.unwrap_or_else(|| "30d".into());
let (records, meta) = scan_usage(&home);
let (records, meta) = scan_usage_cached(&home, refresh);
let t1 = std::time::Instant::now();
let stats = aggregate(&records, &r, now_ms);
let all_stats = aggregate(&records, "all", now_ms);
let heatmap = build_heatmap(&records, now_ms);
@@ -1520,6 +1589,15 @@ pub fn get_summary(home_override: Option<String>, range: Option<String>, refresh
name, provider: std::env::var("KIMI_MODEL_PROVIDER").ok(), model: std::env::var("KIMI_MODEL_ID").ok(),
});
let t2 = std::time::Instant::now();
let scan_ms = t1.duration_since(t0).as_secs_f64() * 1000.0;
let aggregate_ms = t2.duration_since(t1).as_secs_f64() * 1000.0;
let total_ms = t2.duration_since(t0).as_secs_f64() * 1000.0;
eprintln!(
"[dashboard] get_summary range={} records={} scan={:.0}ms aggregate={:.0}ms total={:.0}ms",
r, records.len(), scan_ms, aggregate_ms, total_ms
);
SummaryResult {
home: home.to_string_lossy().to_string(),
valid: is_kimi_home(&home),
+2
View File
@@ -27,6 +27,8 @@ pub fn run() {
.plugin(tauri_plugin_opener::init())
.setup(|app| {
println!("[Tauri] Setup started");
// Build the models.dev price index off the first dashboard query.
dashboard::warm_price_index();
let window = app.get_webview_window("main").unwrap();
println!("[Tauri] Window label: {}", window.label());
+5 -2
View File
@@ -1,6 +1,6 @@
{
"productName": "Kimi Switch",
"version": "0.6.7",
"version": "0.6.9",
"identifier": "com.kimiswitch.app",
"build": {
"beforeDevCommand": "npm run dev",
@@ -26,7 +26,10 @@
},
"bundle": {
"active": true,
"targets": ["msi", "nsis"],
"targets": [
"msi",
"nsis"
],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
+10 -2
View File
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useEffect, useMemo, useReducer, useState } from "react";
import { invoke } from "@tauri-apps/api/core";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { useConfig } from "./hooks/useConfig";
@@ -12,7 +12,7 @@ import { UsageConfigModal } from "./components/UsageConfigModal";
import { PresetPickerModal } from "./components/PresetPickerModal";
import { useTranslation } from "./i18n";
import { getDefaultMaxContextSize } from "./lib/model-defaults";
import { getModelRef } from "./lib/models-dev";
import { getModelRef, modelsDevReady, onModelsDevReady } from "./lib/models-dev";
import {
presetToProviderAndModels,
type ProviderPreset,
@@ -121,6 +121,14 @@ export default function App() {
}).catch(() => {});
}, [loading, config, agent]);
// Load the models.dev index in the background (not in the main bundle)
// and re-render once it lands so context/capability columns fill in.
const [, forceModelsDevReady] = useReducer((x: number) => x + 1, 0);
useEffect(() => {
onModelsDevReady(forceModelsDevReady);
void modelsDevReady();
}, []);
const providers = useMemo(
() => (config ? Object.values(config.providers) : []),
[config]
+12
View File
@@ -372,6 +372,18 @@ export function SettingsModal({
<div>{t("appDescription")}</div>
<div className="text-xs text-content-muted">v{appVersion} · MIT License</div>
<div className="pt-2 space-y-1">
<div>
{t("settingsWebsite")}:{" "}
<button
type="button"
onClick={() =>
openExternal("https://billowliu2.github.io/KimiSwitch")
}
className="text-blue-500 hover:text-blue-400 underline bg-transparent p-0 border-0 cursor-pointer"
>
billowliu2.github.io/KimiSwitch
</button>
</div>
<div>
{t("attributionPorted")}{" "}
<button
+4 -2
View File
@@ -1,7 +1,8 @@
import { useMemo, useState } from "react";
import { createPortal } from "react-dom";
import { useTranslation } from "../../i18n";
import { fmtPct, fmtTokens, fmtUsd } from "../../lib/dashboard-format";
import { useCurrency } from "../../hooks/useCurrency";
import { fmtPct, fmtTokens } from "../../lib/dashboard-format";
import type { DailyRow } from "../../types/dashboard";
import { DailyDetailModal } from "./DailyDetailModal";
@@ -43,6 +44,7 @@ function shortModel(model: string): string {
export function DailyBars({ daily, dimension, names, unknownProviderLabel }: DailyBarsProps) {
const { t } = useTranslation();
const { money } = useCurrency();
const [selected, setSelected] = useState<DailyRow | null>(null);
const colorMap = useMemo(() => {
@@ -103,7 +105,7 @@ export function DailyBars({ daily, dimension, names, unknownProviderLabel }: Dai
const tooltipLines = [
d.date,
`${t("totalTokens")}: ${fmtTokens(d.totalTokens)} · ${fmtUsd(d.costUsd)} · ${t("colCacheHit")} ${fmtPct(d.cacheHitRate)}`,
`${t("totalTokens")}: ${fmtTokens(d.totalTokens)} · ${money(d.costUsd)} · ${t("colCacheHit")} ${fmtPct(d.cacheHitRate)}`,
...segments.map((s) => `${displayName(s.key)}: ${fmtTokens(s.tokens)}`),
"",
t("doubleClickHint"),
@@ -1,6 +1,7 @@
import { useEffect } from "react";
import { useTranslation } from "../../i18n";
import { fmtPct, fmtTokens, fmtUsd } from "../../lib/dashboard-format";
import { useCurrency } from "../../hooks/useCurrency";
import { fmtPct, fmtTokens } from "../../lib/dashboard-format";
import type { DailyRow } from "../../types/dashboard";
import { modelColor } from "./DailyBars";
@@ -22,6 +23,7 @@ function shortModel(model: string): string {
export function DailyDetailModal({ day, dimension, colorMap, unknownProviderLabel, onClose }: DailyDetailModalProps) {
const { t } = useTranslation();
const { money } = useCurrency();
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
@@ -106,7 +108,7 @@ export function DailyDetailModal({ day, dimension, colorMap, unknownProviderLabe
{/* Day summary chips */}
<div className="grid grid-cols-2 gap-2 px-5 py-3 sm:grid-cols-4">
<SummaryChip label={t("totalTokens")} value={fmtTokens(day.totalTokens)} tone="default" />
<SummaryChip label={t("cost")} value={fmtUsd(day.costUsd)} tone="orange" />
<SummaryChip label={t("cost")} value={money(day.costUsd)} tone="orange" />
<SummaryChip label={t("requests")} value={Math.round(day.requests).toLocaleString()} tone="blue" />
<SummaryChip label={t("cacheHitRate")} value={fmtPct(day.cacheHitRate)} tone="green" />
</div>
+40 -23
View File
@@ -1,13 +1,20 @@
import { useState, type ReactNode } from "react";
import { useDashboard, type DashboardRange } from "../../hooks/useDashboard";
import { useCurrency } from "../../hooks/useCurrency";
import { useTranslation } from "../../i18n";
import { fmtInt, fmtPct, fmtTime, fmtTokens, fmtUsd } from "../../lib/dashboard-format";
import { fmtInt, fmtPct, fmtTime, fmtTokens } from "../../lib/dashboard-format";
import { DailyBars } from "./DailyBars";
import { Heatmap } from "./Heatmap";
import { TrendLineChart } from "./TrendLineChart";
const RANGES: DashboardRange[] = ["today", "7d", "30d", "all"];
/** Per-request cache hit rate: cached tokens / total input tokens. */
function cacheHitOf(r: { inputOther: number; inputCacheRead: number }): number {
const denom = r.inputOther + r.inputCacheRead;
return denom > 0 ? r.inputCacheRead / denom : 0;
}
function Card({
title,
subtitle,
@@ -44,7 +51,8 @@ function KpiCard({ label, value, sub }: { label: string; value: string; sub?: st
export function DashboardPage() {
const { t } = useTranslation();
const { range, changeRange, data, loading, error, refresh } = useDashboard();
const { money } = useCurrency();
const { range, changeRange, data, loading, error, refresh, loadStats } = useDashboard();
const [showAllModels, setShowAllModels] = useState(false);
const [recentPage, setRecentPage] = useState(1);
const [trendTab, setTrendTab] = useState<"daily" | "model" | "provider">("daily");
@@ -71,7 +79,7 @@ export function DashboardPage() {
<div className="text-red-400 mb-2">{t("dashLoadFailed")}</div>
<div className="text-sm text-content-muted">{error}</div>
<button
onClick={() => refresh()}
onClick={() => refresh(true)}
className="mt-4 px-4 py-2 rounded bg-blue-600 hover:bg-blue-700 text-white text-sm"
>
{t("retry")}
@@ -120,32 +128,39 @@ export function DashboardPage() {
{ label: t("kpiCacheCreation"), value: fmtTokens(totals.inputCacheCreation), sub: fmtInt(totals.inputCacheCreation) },
{ label: t("kpiCacheHit"), value: fmtPct(totals.cacheHitRate) },
{ label: t("totalTokens"), value: fmtTokens(totals.totalTokens), sub: fmtInt(totals.totalTokens) },
{ label: t("kpiCost"), value: fmtUsd(totals.costUsd) },
{ label: t("kpiCost"), value: money(totals.costUsd) },
];
return (
<div className="h-full overflow-auto p-4 space-y-4">
{/* Range tabs + refresh */}
<div className="flex items-center justify-between">
<div className="flex items-center bg-input border border-border rounded p-0.5">
{RANGES.map((r) => (
<button
key={r}
type="button"
onClick={() => changeRange(r)}
className={`px-3 py-1 text-sm rounded transition-colors ${
range === r
? "bg-blue-600 text-white"
: "text-content-muted hover:text-content-primary"
}`}
>
{RANGE_LABELS[r]}
</button>
))}
<div className="flex items-center gap-3">
<div className="flex items-center bg-input border border-border rounded p-0.5">
{RANGES.map((r) => (
<button
key={r}
type="button"
onClick={() => changeRange(r)}
className={`px-3 py-1 text-sm rounded transition-colors ${
range === r
? "bg-blue-600 text-white"
: "text-content-muted hover:text-content-primary"
}`}
>
{RANGE_LABELS[r]}
</button>
))}
</div>
{loadStats && !loading && (
<span className="hidden text-[10px] text-content-muted sm:inline">
{t("loadStats", { ms: loadStats.ms, kb: loadStats.kb })}
</span>
)}
</div>
<button
type="button"
onClick={() => refresh()}
onClick={() => refresh(true)}
disabled={loading}
className="px-3 py-1.5 text-sm border border-border rounded hover:bg-hover-2 text-content-muted hover:text-content-primary disabled:opacity-50"
>
@@ -175,7 +190,7 @@ export function DashboardPage() {
{fmtTokens(tot.totalTokens)}
</div>
<div className="mt-1 text-[11px] text-content-muted">
{fmtInt(tot.requests)} {t("unitTimes")} · {fmtUsd(tot.costUsd)} · {fmtPct(tot.cacheHitRate)}
{fmtInt(tot.requests)} {t("unitTimes")} · {money(tot.costUsd)} · {fmtPct(tot.cacheHitRate)}
</div>
</button>
);
@@ -305,7 +320,7 @@ export function DashboardPage() {
<td className="py-2 pr-3 text-right text-content-muted">{fmtInt(m.requests)}</td>
<td className="py-2 pr-3 text-right text-content-muted">{fmtTokens(m.totalTokens)}</td>
<td className="py-2 pr-3 text-right text-content-muted">{fmtPct(m.cacheHitRate)}</td>
<td className="py-2 text-right text-orange-600 dark:text-orange-400">{fmtUsd(m.costUsd)}</td>
<td className="py-2 text-right text-orange-600 dark:text-orange-400">{money(m.costUsd)}</td>
</tr>
))}
</tbody>
@@ -346,6 +361,7 @@ export function DashboardPage() {
<th className="pb-2 pr-4 font-normal text-right">{t("colInput")}</th>
<th className="pb-2 pr-4 font-normal text-right">{t("colOutput")}</th>
<th className="pb-2 pr-4 font-normal text-right">{t("colCacheRead")}</th>
<th className="pb-2 pr-4 font-normal text-right">{t("colCacheHit")}</th>
<th className="pb-2 font-normal text-right">{t("cost")}</th>
</tr>
</thead>
@@ -359,7 +375,8 @@ export function DashboardPage() {
<td className="py-1.5 pr-4 text-right text-content-muted">{fmtTokens(r.inputOther)}</td>
<td className="py-1.5 pr-4 text-right text-content-muted">{fmtTokens(r.output)}</td>
<td className="py-1.5 pr-4 text-right text-content-muted">{fmtTokens(r.inputCacheRead)}</td>
<td className="py-1.5 text-right text-orange-600 dark:text-orange-400">{fmtUsd(r.costUsd)}</td>
<td className="py-1.5 pr-4 text-right text-content-muted">{fmtPct(cacheHitOf(r))}</td>
<td className="py-1.5 text-right text-orange-600 dark:text-orange-400">{money(r.costUsd)}</td>
</tr>
))}
</tbody>
+4 -2
View File
@@ -1,7 +1,8 @@
import { useEffect, useMemo, useRef, useState, type MouseEvent } from "react";
import { createPortal } from "react-dom";
import { useTranslation } from "../../i18n";
import { fmtPct, fmtTokens, fmtUsd } from "../../lib/dashboard-format";
import { useCurrency } from "../../hooks/useCurrency";
import { fmtPct, fmtTokens } from "../../lib/dashboard-format";
import type { HeatmapCell, HeatmapData } from "../../types/dashboard";
interface HeatmapProps {
@@ -220,6 +221,7 @@ export function Heatmap({ heatmap }: HeatmapProps) {
function HeatmapTooltip({ state }: { state: HoverState }) {
const { t } = useTranslation();
const { money } = useCurrency();
const { cell, x, y } = state;
// Position above the cursor with a small offset; flip below if too close to top.
const offset = 14;
@@ -239,7 +241,7 @@ function HeatmapTooltip({ state }: { state: HoverState }) {
>
<div className="font-medium text-content-primary">{cell.date}</div>
<div className="text-content-muted">
{fmtTokens(cell.totalTokens)} · {fmtUsd(cell.costUsd)} ·{" "}
{fmtTokens(cell.totalTokens)} · {money(cell.costUsd)} ·{" "}
{fmtInt(cell.requests)} {t("requests")}
</div>
<div className="text-content-muted">
+83
View File
@@ -0,0 +1,83 @@
import { useCallback, useEffect, useState } from "react";
import { useTranslation } from "../i18n";
import { fmtUsd } from "../lib/dashboard-format";
/**
* USD → CNY exchange rate for the dashboard.
* Chinese mode shows prices in CNY (latest available rate), English stays in
* USD. The rate is fetched once and cached in localStorage for 12h; any
* failure falls back to a conservative fixed rate so the UI never blocks.
*/
const FALLBACK_RATE = 7.2;
const CACHE_KEY = "kimi-switch-cny-rate";
const CACHE_TTL = 12 * 60 * 60 * 1000; // 12 hours
function readCachedRate(): number | null {
try {
const raw = localStorage.getItem(CACHE_KEY);
if (!raw) return null;
const { ts, rate } = JSON.parse(raw) as { ts: number; rate: number };
if (Date.now() - ts > CACHE_TTL || !(rate > 1)) return null;
return rate;
} catch {
return null;
}
}
function writeCachedRate(rate: number) {
try {
localStorage.setItem(CACHE_KEY, JSON.stringify({ ts: Date.now(), rate }));
} catch {
/* ignore */
}
}
export function useCurrency() {
const { lang } = useTranslation();
const [rate, setRate] = useState<number | null>(null);
useEffect(() => {
let cancelled = false;
(async () => {
const cached = readCachedRate();
if (cached) {
setRate(cached);
return;
}
try {
const res = await fetch("https://open.er-api.com/v6/latest/USD");
if (res.ok) {
const data = (await res.json()) as { rates?: { CNY?: number } };
const cny = Number(data.rates?.CNY);
if (cny > 1) {
if (!cancelled) setRate(cny);
writeCachedRate(cny);
return;
}
}
} catch {
/* network blocked → fallback */
}
if (!cancelled) setRate(FALLBACK_RATE);
})();
return () => {
cancelled = true;
};
}, []);
/** Format a USD cost for display: CNY in Chinese mode, USD otherwise. */
const money = useCallback(
(usd: number): string => {
if (lang !== "zh") return fmtUsd(usd);
const v = (Number(usd) || 0) * (rate ?? FALLBACK_RATE);
if (v === 0) return "¥0.00";
if (v < 0.1) return "¥" + v.toFixed(3);
if (v < 1) return "¥" + v.toFixed(2);
return "¥" + v.toFixed(2);
},
[lang, rate],
);
return { money, cnyRate: rate ?? FALLBACK_RATE };
}
+13 -3
View File
@@ -22,13 +22,23 @@ export function useDashboard() {
const [data, setData] = useState<SummaryResult | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
/** Round-trip timing for the last get_summary call (user-perceived lag). */
const [loadStats, setLoadStats] = useState<{ ms: number; kb: number } | null>(null);
const refresh = useCallback(async () => {
const refresh = useCallback(async (force = false) => {
setLoading(true);
setError(null);
const start = performance.now();
try {
const result = await invoke<SummaryResult>("get_summary", { range });
const result = await invoke<SummaryResult>("get_summary", {
range,
refresh: force,
});
setData(result);
setLoadStats({
ms: Math.round(performance.now() - start),
kb: Math.round(JSON.stringify(result).length / 1024),
});
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
setError(msg);
@@ -50,5 +60,5 @@ export function useDashboard() {
}
}, []);
return { range, changeRange, data, loading, error, refresh };
return { range, changeRange, data, loading, error, refresh, loadStats };
}
+2
View File
@@ -197,6 +197,7 @@ export const enTranslations: Record<TranslationKey, string> = {
scanning: "Scanning…",
refresh: "Refresh",
refreshing: "Refreshing…",
loadStats: "Loaded in {ms} ms · {kb} KB payload",
refreshed: "Refreshed",
cancel: "Cancel",
confirmDeleteTitle: "Delete session forever?",
@@ -260,6 +261,7 @@ export const enTranslations: Record<TranslationKey, string> = {
updateCheckFailed: "Update check failed",
lastChecked: "Last checked",
appDescription: "Windows desktop LLM provider config manager",
settingsWebsite: "Official website",
referenceProject: "Reference project",
// Validation errors
+2
View File
@@ -194,6 +194,7 @@ export const zhTranslations = {
scanning: "扫描中…",
refresh: "刷新",
refreshing: "刷新中…",
loadStats: "加载 {ms} ms · 数据 {kb} KB",
refreshed: "已刷新",
cancel: "取消",
confirmDeleteTitle: "永久删除会话?",
@@ -255,6 +256,7 @@ export const zhTranslations = {
updateCheckFailed: "检查更新失败",
lastChecked: "上次检查",
appDescription: "Windows 桌面端 LLM 供应商配置管理器",
settingsWebsite: "官方网站",
referenceProject: "引用项目",
// Validation errors
+478 -71
View File
@@ -17101,7 +17101,9 @@
"output_limit": 8192,
"reasoning": true,
"tool_call": true,
"structured_output": true
"structured_output": true,
"image": true,
"video": true
},
{
"id": "qwen3.6-27b",
@@ -17175,7 +17177,8 @@
"name": "Abliterated Model Large",
"cost": {
"input": 5,
"output": 5
"output": 5,
"cache_read": 0.5
},
"context": 1000000,
"input_limit": 1000000,
@@ -17189,7 +17192,8 @@
"name": "Abliterated Model",
"cost": {
"input": 3,
"output": 3
"output": 3,
"cache_read": 0.3
},
"context": 150000,
"input_limit": 150000,
@@ -18190,7 +18194,9 @@
"output_limit": 65536,
"reasoning": true,
"tool_call": true,
"structured_output": true
"structured_output": true,
"image": true,
"video": true
},
{
"id": "gpt-5.2-chat-latest",
@@ -19796,6 +19802,22 @@
"structured_output": true,
"image": true
},
{
"id": "kimi-k3-fast",
"name": "Kimi K3",
"cost": {
"input": 4.5,
"output": 22.5,
"cache_read": 0.45
},
"context": 1040384,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "claude-opus-5",
"name": "Claude Opus 5",
@@ -29065,7 +29087,9 @@
"output_limit": 32768,
"reasoning": true,
"tool_call": true,
"structured_output": true
"structured_output": true,
"image": true,
"video": true
},
{
"id": "Qwen/Qwen3-8B",
@@ -29441,7 +29465,8 @@
"name": "zai-org/GLM-5",
"cost": {
"input": 0.95,
"output": 2.55
"output": 2.55,
"cache_read": 0.2
},
"context": 205000,
"output_limit": 205000,
@@ -29467,6 +29492,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
},
"context": 1049000,
@@ -29481,6 +29507,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
},
"context": 205000,
@@ -29495,6 +29522,7 @@
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.24,
"cache_write": 0
},
"context": 200000,
@@ -29824,7 +29852,8 @@
"name": "MiniMaxAI/MiniMax-M2.5",
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03
},
"context": 197000,
"output_limit": 131000,
@@ -29992,7 +30021,8 @@
"name": "moonshotai/Kimi-K2.5",
"cost": {
"input": 0.45,
"output": 2.25
"output": 2.25,
"cache_read": 0.07
},
"context": 262000,
"output_limit": 262000,
@@ -36790,8 +36820,9 @@
"id": "zai-org-glm-4.7-flash",
"name": "GLM 4.7 Flash",
"cost": {
"input": 0.125,
"output": 0.5
"input": 0.06,
"output": 0.4,
"cache_read": 0.01
},
"context": 128000,
"output_limit": 16384,
@@ -36825,6 +36856,20 @@
"structured_output": true,
"image": true
},
{
"id": "deepseek-v4-flash-0731",
"name": "DeepSeek V4 Flash 0731",
"cost": {
"input": 0.175,
"output": 0.35,
"cache_read": 0.035
},
"context": 1000000,
"output_limit": 32768,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "qwen3-235b-a22b-instruct-2507",
"name": "Qwen 3 235B A22B Instruct 2507",
@@ -37751,7 +37796,8 @@
"name": "GLM-5.1",
"cost": {
"input": 1.4,
"output": 4.4
"output": 4.4,
"cache_read": 0.26
},
"context": 202752,
"output_limit": 131072,
@@ -37822,7 +37868,8 @@
"name": "Qwen3.7 Max",
"cost": {
"input": 1.25,
"output": 3.75
"output": 3.75,
"cache_read": 0.125
},
"context": 1000000,
"output_limit": 500000,
@@ -37844,7 +37891,8 @@
"name": "Qwen3.5 397B A17B",
"cost": {
"input": 0.6,
"output": 3.6
"output": 3.6,
"cache_read": 0.35
},
"context": 262144,
"output_limit": 130000,
@@ -40988,6 +41036,21 @@
"reasoning": true,
"tool_call": true,
"image": true
},
{
"id": "moonshotai/Kimi-K3",
"name": "Kimi K3",
"cost": {
"input": 3,
"output": 15,
"cache_read": 0.3
},
"context": 1048576,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true
}
]
},
@@ -41448,7 +41511,9 @@
"name": "MiniMax-M2.1",
"cost": {
"input": 2.1,
"output": 8.4
"output": 8.4,
"cache_read": 2.1,
"cache_write": 8.4
},
"context": 204800,
"output_limit": 131072,
@@ -45670,7 +45735,9 @@
"output_limit": 32000,
"reasoning": true,
"tool_call": true,
"structured_output": true
"structured_output": true,
"image": true,
"video": true
},
{
"id": "nemotron-3-ultra",
@@ -48709,7 +48776,9 @@
"name": "MiniMax-M2.1",
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03,
"cache_write": 0.375
},
"context": 204800,
"output_limit": 131072,
@@ -49621,6 +49690,355 @@
}
]
},
"tensorx": {
"id": "tensorx",
"name": "TensorX",
"models": [
{
"id": "nvidia/nemotron-3-super-120b-a12b",
"name": "Nemotron 3 Super 120B A12B",
"cost": {
"input": 0.3,
"output": 0.9,
"cache_read": 0.075,
"cache_write": 0.375
},
"context": 262144,
"output_limit": 262144,
"reasoning": true,
"tool_call": true
},
{
"id": "qwen/qwen3-coder-30b-a3b-instruct",
"name": "Qwen3-Coder 30B-A3B Instruct",
"cost": {
"input": 0.06,
"output": 0.25,
"cache_read": 0.015,
"cache_write": 0.075
},
"context": 262000,
"output_limit": 65536,
"tool_call": true
},
{
"id": "qwen/qwen3.5-9b",
"name": "Qwen3.5 9B",
"cost": {
"input": 0.15,
"output": 0.2,
"cache_read": 0.0375,
"cache_write": 0.1875
},
"context": 262144,
"output_limit": 65536,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "qwen/qwen3-vl-235b-a22b-instruct",
"name": "Qwen3 VL 235B-A22B Instruct",
"cost": {
"input": 0.21,
"output": 1.9,
"cache_read": 0.0525,
"cache_write": 0.2625
},
"context": 131000,
"output_limit": 131072,
"tool_call": true,
"image": true
},
{
"id": "qwen/qwen3-235b-a22b-2507",
"name": "Qwen3 235B-A22B-2507",
"cost": {
"input": 0.072,
"output": 0.464,
"cache_read": 0.018,
"cache_write": 0.09
},
"context": 131000,
"output_limit": 262144,
"tool_call": true
},
{
"id": "qwen/qwen3.5-122b-a10b",
"name": "Qwen3.5 122B-A10B",
"cost": {
"input": 0.5,
"output": 3.5,
"cache_read": 0.125,
"cache_write": 0.625
},
"context": 262144,
"output_limit": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "minimax/minimax-m3",
"name": "MiniMax-M3",
"cost": {
"input": 0.4,
"output": 2,
"cache_read": 0.1
},
"context": 1048576,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"image": true,
"video": true
},
{
"id": "minimax/minimax-m2.5",
"name": "MiniMax-M2.5",
"cost": {
"input": 0.3,
"output": 1.2,
"cache_read": 0.075,
"cache_write": 0.375
},
"context": 196608,
"output_limit": 65536,
"reasoning": true,
"tool_call": true
},
{
"id": "deepseek/deepseek-v4-flash",
"name": "DeepSeek V4 Flash",
"cost": {
"input": 0.15,
"output": 0.3,
"cache_read": 0.0375,
"cache_write": 0.1875
},
"context": 1048576,
"output_limit": 384000,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "deepseek/deepseek-v4-pro",
"name": "DeepSeek V4 Pro",
"cost": {
"input": 1.75,
"output": 3.5,
"cache_read": 0.4375,
"cache_write": 2.185
},
"context": 1048576,
"output_limit": 384000,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "deepseek/deepseek-r1-0528",
"name": "DeepSeek R1-0528",
"cost": {
"input": 0.66,
"output": 2.6,
"cache_read": 0.165,
"cache_write": 0.825
},
"context": 164000,
"output_limit": 8192,
"reasoning": true,
"tool_call": true
},
{
"id": "deepseek/deepseek-v3.2",
"name": "DeepSeek V3.2",
"cost": {
"input": 0.3,
"output": 0.5,
"cache_read": 0.075,
"cache_write": 0.375
},
"context": 163840,
"output_limit": 163840,
"reasoning": true,
"tool_call": true
},
{
"id": "deepseek/deepseek-chat-v3.1",
"name": "DeepSeek Chat V3.1",
"cost": {
"input": 0.2,
"output": 0.8,
"cache_read": 0.05,
"cache_write": 0.25
},
"context": 164000,
"output_limit": 163840,
"reasoning": true,
"tool_call": true
},
{
"id": "z-ai/glm-5",
"name": "GLM-5",
"cost": {
"input": 1,
"output": 3.2,
"cache_read": 0.25,
"cache_write": 1.25
},
"context": 202752,
"output_limit": 202752,
"reasoning": true,
"tool_call": true
},
{
"id": "z-ai/glm-5.1",
"name": "GLM-5.1",
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.35,
"cache_write": 1.75
},
"context": 202752,
"output_limit": 202752,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "z-ai/glm-5.2",
"name": "GLM-5.2",
"cost": {
"input": 1.5,
"output": 4.5,
"cache_read": 0.375
},
"context": 1048576,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "z-ai/glm-4.7",
"name": "GLM-4.7",
"cost": {
"input": 0.6,
"output": 2.2,
"cache_read": 0.15,
"cache_write": 0.75
},
"context": 200000,
"output_limit": 200000,
"reasoning": true,
"tool_call": true,
"image": true
},
{
"id": "z-ai/glm-5-turbo",
"name": "GLM-5-Turbo",
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.3,
"cache_write": 1.5
},
"context": 202752,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "z-ai/glm-5v-turbo",
"name": "GLM-5V-Turbo",
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.3,
"cache_write": 1.5
},
"context": 202752,
"output_limit": 131072,
"reasoning": true,
"tool_call": true,
"image": true,
"video": true
},
{
"id": "moonshotai/kimi-k2.5",
"name": "Kimi K2.5",
"cost": {
"input": 0.5,
"output": 2.8,
"cache_read": 0.125,
"cache_write": 0.625
},
"context": 262144,
"output_limit": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "moonshotai/kimi-k2.6",
"name": "Kimi K2.6",
"cost": {
"input": 1,
"output": 4,
"cache_read": 0.25,
"cache_write": 1.25
},
"context": 262144,
"output_limit": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "moonshotai/kimi-k2.7-code",
"name": "Kimi K2.7 Code",
"cost": {
"input": 1.25,
"output": 4.5,
"cache_read": 0.3125
},
"context": 262144,
"output_limit": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "openai/gpt-oss-120b",
"name": "GPT OSS 120B",
"cost": {
"input": 0.04,
"output": 0.2,
"cache_read": 0.01,
"cache_write": 0.05
},
"context": 131072,
"output_limit": 32768,
"reasoning": true,
"tool_call": true,
"structured_output": true
}
]
},
"llama": {
"id": "llama",
"name": "Llama",
@@ -58117,7 +58535,8 @@
"cache_read": 0.03
},
"context": 32768,
"output_limit": 65536
"output_limit": 65536,
"image": true
},
{
"id": "google/imagen-4.0-generate-001",
@@ -58133,7 +58552,8 @@
"cache_read": 0.2
},
"context": 65536,
"output_limit": 32768
"output_limit": 32768,
"image": true
},
{
"id": "google/gemini-3.1-pro-preview",
@@ -58150,6 +58570,10 @@
"structured_output": true,
"image": true
},
{
"id": "google/veo-3.1-lite-generate-001",
"name": "Veo 3.1 Lite Generate"
},
{
"id": "google/gemini-2.5-flash-lite",
"name": "Gemini 2.5 Flash Lite",
@@ -58868,7 +59292,8 @@
},
"context": 128000,
"output_limit": 128000,
"tool_call": true
"tool_call": true,
"image": true
},
{
"id": "mistral/mistral-small",
@@ -59198,6 +59623,19 @@
"tool_call": true,
"structured_output": true
},
{
"id": "deepseek/deepseek-v4-flash-0731",
"name": "DeepSeek V4 Flash 0731",
"cost": {
"input": 0.13,
"output": 0.26,
"cache_read": 0.028
},
"context": 1000000,
"output_limit": 384000,
"reasoning": true,
"tool_call": true
},
{
"id": "deepseek/deepseek-v3",
"name": "DeepSeek V3 0324",
@@ -59714,7 +60152,8 @@
"context": 256000,
"output_limit": 80000,
"reasoning": true,
"tool_call": true
"tool_call": true,
"image": true
},
{
"id": "kwaipilot/kat-coder-air-v2.5",
@@ -59727,7 +60166,8 @@
"context": 256000,
"output_limit": 80000,
"reasoning": true,
"tool_call": true
"tool_call": true,
"image": true
},
{
"id": "xiaomi/mimo-v2.5",
@@ -60018,7 +60458,8 @@
"name": "Sonar Reasoning Pro",
"context": 127000,
"output_limit": 8000,
"reasoning": true
"reasoning": true,
"image": true
},
{
"id": "moonshotai/kimi-k2.5",
@@ -61102,7 +61543,8 @@
"context": 262114,
"output_limit": 262114,
"reasoning": true,
"tool_call": true
"tool_call": true,
"image": true
},
{
"id": "stepfun/step-3.7-flash",
@@ -68833,7 +69275,9 @@
"name": "MiniMax-M2.1",
"cost": {
"input": 0,
"output": 0
"output": 0,
"cache_read": 0,
"cache_write": 0
},
"context": 204800,
"output_limit": 131072,
@@ -68910,6 +69354,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
},
"context": 1049000,
@@ -68973,6 +69418,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
},
"context": 205000,
@@ -69064,7 +69510,8 @@
"name": "Pro/moonshotai/Kimi-K2.5",
"cost": {
"input": 0.45,
"output": 2.25
"output": 2.25,
"cache_read": 0.07
},
"context": 262000,
"output_limit": 262000,
@@ -72114,20 +72561,6 @@
"structured_output": true,
"image": true
},
{
"id": "zai-org/GLM-5-TEE",
"name": "GLM 5 TEE",
"cost": {
"input": 0.95,
"output": 2.55,
"cache_read": 0.475
},
"context": 202752,
"output_limit": 65535,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "zai-org/GLM-5.1-TEE",
"name": "GLM 5.1 TEE",
@@ -72225,20 +72658,6 @@
"structured_output": true,
"image": true
},
{
"id": "MiniMaxAI/MiniMax-M2.5-TEE",
"name": "MiniMax M2.5 TEE",
"cost": {
"input": 0.15,
"output": 1.2,
"cache_read": 0.075
},
"context": 196608,
"output_limit": 65536,
"reasoning": true,
"tool_call": true,
"structured_output": true
},
{
"id": "deepseek-ai/DeepSeek-V3.2-TEE",
"name": "DeepSeek V3.2 TEE",
@@ -72269,22 +72688,6 @@
"image": true,
"video": true
},
{
"id": "moonshotai/Kimi-K2.5-TEE",
"name": "Kimi K2.5 TEE",
"cost": {
"input": 0.44,
"output": 2,
"cache_read": 0.22
},
"context": 262144,
"output_limit": 65535,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true
},
{
"id": "moonshotai/Kimi-K3-TEE",
"name": "Kimi K3 TEE",
@@ -77090,7 +77493,9 @@
"name": "MiniMax-M2.1",
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03,
"cache_write": 0.375
},
"context": 204800,
"output_limit": 131072,
@@ -77719,7 +78124,9 @@
"name": "MiniMax-M2.1",
"cost": {
"input": 0,
"output": 0
"output": 0,
"cache_read": 0,
"cache_write": 0
},
"context": 204800,
"output_limit": 131072,
+407 -55
View File
@@ -13610,6 +13610,8 @@
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0,
"output": 0
@@ -13674,7 +13676,8 @@
"structured_output": true,
"cost": {
"input": 5,
"output": 5
"output": 5,
"cache_read": 0.5
}
},
"abliteration-ai/abliterated-model": {
@@ -13685,7 +13688,8 @@
"image": true,
"cost": {
"input": 3,
"output": 3
"output": 3,
"cache_read": 0.3
}
},
"alibaba-coding-plan-cn/qwen3.7-plus": {
@@ -14520,6 +14524,8 @@
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.1,
"output": 0.15
@@ -15883,6 +15889,20 @@
"cache_read": 0.2
}
},
"llmgateway/kimi-k3-fast": {
"name": "Kimi K3",
"context": 1040384,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 4.5,
"output": 22.5,
"cache_read": 0.45
}
},
"llmgateway/claude-opus-5": {
"name": "Claude Opus 5",
"context": 1000000,
@@ -23525,6 +23545,8 @@
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.3,
"output": 0.3,
@@ -23853,7 +23875,8 @@
"structured_output": true,
"cost": {
"input": 0.95,
"output": 2.55
"output": 2.55,
"cache_read": 0.2
}
},
"siliconflow/zai-org/GLM-4.5-Air": {
@@ -23875,6 +23898,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
}
},
@@ -23887,6 +23911,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
}
},
@@ -23899,6 +23924,7 @@
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.24,
"cache_write": 0
}
},
@@ -24174,7 +24200,8 @@
"tool_call": true,
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03
}
},
"siliconflow/inclusionAI/Ling-flash-2.0": {
@@ -24319,7 +24346,8 @@
"image": true,
"cost": {
"input": 0.45,
"output": 2.25
"output": 2.25,
"cache_read": 0.07
}
},
"siliconflow/openai/gpt-oss-20b": {
@@ -29988,8 +30016,9 @@
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.125,
"output": 0.5
"input": 0.06,
"output": 0.4,
"cache_read": 0.01
}
},
"venice/llama-3.2-3b": {
@@ -30013,6 +30042,18 @@
"output": 225
}
},
"venice/deepseek-v4-flash-0731": {
"name": "DeepSeek V4 Flash 0731",
"context": 1000000,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.175,
"output": 0.35,
"cache_read": 0.035
}
},
"venice/qwen3-235b-a22b-instruct-2507": {
"name": "Qwen 3 235B A22B Instruct 2507",
"context": 128000,
@@ -30792,7 +30833,8 @@
"structured_output": true,
"cost": {
"input": 1.4,
"output": 4.4
"output": 4.4,
"cache_read": 0.26
}
},
"togetherai/pearl-ai/gemma-4-31b-it": {
@@ -30849,7 +30891,8 @@
"tool_call": true,
"cost": {
"input": 1.25,
"output": 3.75
"output": 3.75,
"cache_read": 0.125
}
},
"togetherai/Qwen/Qwen3-235B-A22B-Instruct-2507-tput": {
@@ -30869,7 +30912,8 @@
"image": true,
"cost": {
"input": 0.6,
"output": 3.6
"output": 3.6,
"cache_read": 0.35
}
},
"togetherai/Qwen/Qwen3.6-Plus": {
@@ -33439,6 +33483,19 @@
"cache_read": 0.27
}
},
"modal/moonshotai/Kimi-K3": {
"name": "Kimi K3",
"context": 1048576,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"cost": {
"input": 3,
"output": 15,
"cache_read": 0.3
}
},
"qihang-ai/gemini-2.5-flash": {
"name": "Gemini 2.5 Flash",
"context": 1048576,
@@ -33814,7 +33871,9 @@
"tool_call": true,
"cost": {
"input": 2.1,
"output": 8.4
"output": 8.4,
"cache_read": 2.1,
"cache_write": 8.4
}
},
"moark/GLM-4.7": {
@@ -37298,6 +37357,8 @@
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.16,
"output": 0.48
@@ -39859,7 +39920,9 @@
"tool_call": true,
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03,
"cache_write": 0.375
}
},
"minimax/MiniMax-M2.5": {
@@ -40611,6 +40674,303 @@
"cache_read": 0.11
}
},
"tensorx/nvidia/nemotron-3-super-120b-a12b": {
"name": "Nemotron 3 Super 120B A12B",
"context": 262144,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.3,
"output": 0.9,
"cache_read": 0.075,
"cache_write": 0.375
}
},
"tensorx/qwen/qwen3-coder-30b-a3b-instruct": {
"name": "Qwen3-Coder 30B-A3B Instruct",
"context": 262000,
"tool_call": true,
"cost": {
"input": 0.06,
"output": 0.25,
"cache_read": 0.015,
"cache_write": 0.075
}
},
"tensorx/qwen/qwen3.5-9b": {
"name": "Qwen3.5 9B",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.15,
"output": 0.2,
"cache_read": 0.0375,
"cache_write": 0.1875
}
},
"tensorx/qwen/qwen3-vl-235b-a22b-instruct": {
"name": "Qwen3 VL 235B-A22B Instruct",
"context": 131000,
"tool_call": true,
"image": true,
"cost": {
"input": 0.21,
"output": 1.9,
"cache_read": 0.0525,
"cache_write": 0.2625
}
},
"tensorx/qwen/qwen3-235b-a22b-2507": {
"name": "Qwen3 235B-A22B-2507",
"context": 131000,
"tool_call": true,
"cost": {
"input": 0.072,
"output": 0.464,
"cache_read": 0.018,
"cache_write": 0.09
}
},
"tensorx/qwen/qwen3.5-122b-a10b": {
"name": "Qwen3.5 122B-A10B",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.5,
"output": 3.5,
"cache_read": 0.125,
"cache_write": 0.625
}
},
"tensorx/minimax/minimax-m3": {
"name": "MiniMax-M3",
"context": 1048576,
"reasoning": true,
"tool_call": true,
"image": true,
"video": true,
"cost": {
"input": 0.4,
"output": 2,
"cache_read": 0.1
}
},
"tensorx/minimax/minimax-m2.5": {
"name": "MiniMax-M2.5",
"context": 196608,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.3,
"output": 1.2,
"cache_read": 0.075,
"cache_write": 0.375
}
},
"tensorx/deepseek/deepseek-v4-flash": {
"name": "DeepSeek V4 Flash",
"context": 1048576,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.15,
"output": 0.3,
"cache_read": 0.0375,
"cache_write": 0.1875
}
},
"tensorx/deepseek/deepseek-v4-pro": {
"name": "DeepSeek V4 Pro",
"context": 1048576,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 1.75,
"output": 3.5,
"cache_read": 0.4375,
"cache_write": 2.185
}
},
"tensorx/deepseek/deepseek-r1-0528": {
"name": "DeepSeek R1-0528",
"context": 164000,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.66,
"output": 2.6,
"cache_read": 0.165,
"cache_write": 0.825
}
},
"tensorx/deepseek/deepseek-v3.2": {
"name": "DeepSeek V3.2",
"context": 163840,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.3,
"output": 0.5,
"cache_read": 0.075,
"cache_write": 0.375
}
},
"tensorx/deepseek/deepseek-chat-v3.1": {
"name": "DeepSeek Chat V3.1",
"context": 164000,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.2,
"output": 0.8,
"cache_read": 0.05,
"cache_write": 0.25
}
},
"tensorx/z-ai/glm-5": {
"name": "GLM-5",
"context": 202752,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 1,
"output": 3.2,
"cache_read": 0.25,
"cache_write": 1.25
}
},
"tensorx/z-ai/glm-5.1": {
"name": "GLM-5.1",
"context": 202752,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.35,
"cache_write": 1.75
}
},
"tensorx/z-ai/glm-5.2": {
"name": "GLM-5.2",
"context": 1048576,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 1.5,
"output": 4.5,
"cache_read": 0.375
}
},
"tensorx/z-ai/glm-4.7": {
"name": "GLM-4.7",
"context": 200000,
"reasoning": true,
"tool_call": true,
"image": true,
"cost": {
"input": 0.6,
"output": 2.2,
"cache_read": 0.15,
"cache_write": 0.75
}
},
"tensorx/z-ai/glm-5-turbo": {
"name": "GLM-5-Turbo",
"context": 202752,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.3,
"cache_write": 1.5
}
},
"tensorx/z-ai/glm-5v-turbo": {
"name": "GLM-5V-Turbo",
"context": 202752,
"reasoning": true,
"tool_call": true,
"image": true,
"video": true,
"cost": {
"input": 1.2,
"output": 4,
"cache_read": 0.3,
"cache_write": 1.5
}
},
"tensorx/moonshotai/kimi-k2.5": {
"name": "Kimi K2.5",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.5,
"output": 2.8,
"cache_read": 0.125,
"cache_write": 0.625
}
},
"tensorx/moonshotai/kimi-k2.6": {
"name": "Kimi K2.6",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 1,
"output": 4,
"cache_read": 0.25,
"cache_write": 1.25
}
},
"tensorx/moonshotai/kimi-k2.7-code": {
"name": "Kimi K2.7 Code",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 1.25,
"output": 4.5,
"cache_read": 0.3125
}
},
"tensorx/openai/gpt-oss-120b": {
"name": "GPT OSS 120B",
"context": 131072,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.04,
"output": 0.2,
"cache_read": 0.01,
"cache_write": 0.05
}
},
"llama/cerebras-llama-4-maverick-17b-128e-instruct": {
"name": "Cerebras-Llama-4-Maverick-17B-128E-Instruct",
"context": 128000,
@@ -47689,6 +48049,7 @@
"vercel/google/gemini-2.5-flash-image": {
"name": "Nano Banana (Gemini 2.5 Flash Image)",
"context": 32768,
"image": true,
"cost": {
"input": 0.3,
"output": 2.5,
@@ -47702,6 +48063,7 @@
"vercel/google/gemini-3-pro-image": {
"name": "Nano Banana Pro",
"context": 65536,
"image": true,
"cost": {
"input": 2,
"output": 12,
@@ -47721,6 +48083,9 @@
"cache_read": 0.2
}
},
"vercel/google/veo-3.1-lite-generate-001": {
"name": "Veo 3.1 Lite Generate"
},
"vercel/google/gemini-2.5-flash-lite": {
"name": "Gemini 2.5 Flash Lite",
"context": 1048576,
@@ -48298,6 +48663,7 @@
"name": "Mistral Nemo",
"context": 128000,
"tool_call": true,
"image": true,
"cost": {
"input": 0.15,
"output": 0.15
@@ -48578,6 +48944,17 @@
"cache_read": 0.0036
}
},
"vercel/deepseek/deepseek-v4-flash-0731": {
"name": "DeepSeek V4 Flash 0731",
"context": 1000000,
"reasoning": true,
"tool_call": true,
"cost": {
"input": 0.13,
"output": 0.26,
"cache_read": 0.028
}
},
"vercel/deepseek/deepseek-v3": {
"name": "DeepSeek V3 0324",
"context": 163840,
@@ -49002,6 +49379,7 @@
"context": 256000,
"reasoning": true,
"tool_call": true,
"image": true,
"cost": {
"input": 0.74,
"output": 2.96,
@@ -49013,6 +49391,7 @@
"context": 256000,
"reasoning": true,
"tool_call": true,
"image": true,
"cost": {
"input": 0.15,
"output": 0.6,
@@ -49266,7 +49645,8 @@
"vercel/perplexity/sonar-reasoning-pro": {
"name": "Sonar Reasoning Pro",
"context": 127000,
"reasoning": true
"reasoning": true,
"image": true
},
"vercel/moonshotai/kimi-k2.5": {
"name": "Kimi K2.5",
@@ -50157,6 +50537,7 @@
"context": 262114,
"reasoning": true,
"tool_call": true,
"image": true,
"cost": {
"input": 0.09,
"output": 0.3,
@@ -56667,7 +57048,9 @@
"tool_call": true,
"cost": {
"input": 0,
"output": 0
"output": 0,
"cache_read": 0,
"cache_write": 0
}
},
"minimax-coding-plan/MiniMax-M2.5": {
@@ -56729,6 +57112,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
}
},
@@ -56782,6 +57166,7 @@
"cost": {
"input": 1.4,
"output": 4.4,
"cache_read": 0.26,
"cache_write": 0
}
},
@@ -56860,7 +57245,8 @@
"image": true,
"cost": {
"input": 0.45,
"output": 2.25
"output": 2.25,
"cache_read": 0.07
}
},
"siliconflow-cn/Qwen/Qwen3.5-27B": {
@@ -59386,18 +59772,6 @@
"cache_read": 0.06
}
},
"chutes/zai-org/GLM-5-TEE": {
"name": "GLM 5 TEE",
"context": 202752,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.95,
"output": 2.55,
"cache_read": 0.475
}
},
"chutes/zai-org/GLM-5.1-TEE": {
"name": "GLM 5.1 TEE",
"context": 202752,
@@ -59481,18 +59855,6 @@
"cache_read": 0.225
}
},
"chutes/MiniMaxAI/MiniMax-M2.5-TEE": {
"name": "MiniMax M2.5 TEE",
"context": 196608,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"cost": {
"input": 0.15,
"output": 1.2,
"cache_read": 0.075
}
},
"chutes/deepseek-ai/DeepSeek-V3.2-TEE": {
"name": "DeepSeek V3.2 TEE",
"context": 131072,
@@ -59519,20 +59881,6 @@
"cache_read": 0.33
}
},
"chutes/moonshotai/Kimi-K2.5-TEE": {
"name": "Kimi K2.5 TEE",
"context": 262144,
"reasoning": true,
"tool_call": true,
"structured_output": true,
"image": true,
"video": true,
"cost": {
"input": 0.44,
"output": 2,
"cache_read": 0.22
}
},
"chutes/moonshotai/Kimi-K3-TEE": {
"name": "Kimi K3 TEE",
"context": 1048576,
@@ -63413,7 +63761,9 @@
"tool_call": true,
"cost": {
"input": 0.3,
"output": 1.2
"output": 1.2,
"cache_read": 0.03,
"cache_write": 0.375
}
},
"minimax-cn/MiniMax-M2.5": {
@@ -63930,7 +64280,9 @@
"tool_call": true,
"cost": {
"input": 0,
"output": 0
"output": 0,
"cache_read": 0,
"cache_write": 0
}
},
"minimax-cn-coding-plan/MiniMax-M2.5": {
+57 -15
View File
@@ -1,9 +1,15 @@
import snapshot from "./models-dev.json";
/**
* Compact per-model reference data from models.dev
* (see scripts/fetch-models-dev.mjs).
*
* The snapshot (~1.3 MB JSON) is NOT bundled into the main chunk anymore:
* parsing a 1.3 MB JSON literal at startup blocks first paint. It is served
* as a static asset (`/models-dev.json`) and loaded once in the background.
* `getModelRef` stays synchronous and returns undefined until the index is
* ready — callers already fall back to defaults — and `modelsDevReady()`
* lets the app re-render once the index arrives.
*/
export interface ModelCost {
input?: number;
output?: number;
@@ -23,22 +29,58 @@ export interface ModelRef {
cost?: ModelCost;
}
const raw = snapshot as Record<string, unknown>;
let byLowerKey: Record<string, ModelRef> | null = null;
let readyListeners: Array<() => void> = [];
// Drop the "last_updated" metadata key; the rest is "<provider>/<model>".
const data: Record<string, ModelRef> = {};
for (const [key, value] of Object.entries(raw)) {
if (key !== "last_updated" && value && typeof value === "object") {
data[key] = value as ModelRef;
function buildIndex(raw: Record<string, unknown>) {
const data: Record<string, ModelRef> = {};
for (const [key, value] of Object.entries(raw)) {
if (key !== "last_updated" && value && typeof value === "object") {
data[key] = value as ModelRef;
}
}
// models.dev keys are "<lab>/<model>" and may be mixed-case (e.g.
// "minimax/MiniMax-M3"), while provider APIs return bare model ids
// (e.g. "kimi-k2.5"). Index lowercase for tolerant matching.
const lower: Record<string, ModelRef> = {};
for (const [key, value] of Object.entries(data)) {
lower[key.toLowerCase()] = value;
}
return lower;
}
// models.dev keys are "<lab>/<model>" and may be mixed-case (e.g.
// "minimax/MiniMax-M3"), while provider APIs return bare model ids
// (e.g. "kimi-k2.5"). Index lowercase for tolerant matching.
const byLowerKey: Record<string, ModelRef> = {};
for (const [key, value] of Object.entries(data)) {
byLowerKey[key.toLowerCase()] = value;
let loadPromise: Promise<void> | null = null;
export function modelsDevReady(): Promise<void> {
if (!loadPromise) {
loadPromise = fetch(`${import.meta.env.BASE_URL}models-dev.json`)
.then((r) => {
if (!r.ok) throw new Error(`models-dev.json HTTP ${r.status}`);
return r.json() as Promise<Record<string, unknown>>;
})
.then((raw) => {
byLowerKey = buildIndex(raw);
const listeners = readyListeners;
readyListeners = [];
for (const cb of listeners) cb();
})
.catch((err) => {
// A failed load is permanent for this session: fall back to defaults.
byLowerKey = {};
loadPromise = null; // allow one retry next time
console.warn("models-dev.json load failed:", err);
});
}
return loadPromise;
}
/** Register a callback invoked once the models.dev index is ready. */
export function onModelsDevReady(cb: () => void): void {
if (byLowerKey) {
cb();
return;
}
readyListeners.push(cb);
}
/**
@@ -49,7 +91,7 @@ for (const [key, value] of Object.entries(data)) {
*/
export function getModelRef(modelId: string): ModelRef | undefined {
const id = modelId.trim().toLowerCase();
if (!id) return undefined;
if (!id || !byLowerKey) return undefined;
const exact = byLowerKey[id];
if (exact) return exact;
const suffix = `/${id}`;
+4 -4
View File
@@ -13,7 +13,7 @@
/>
<meta
name="keywords"
content="KimiSwitch, KimiCodeSwitch, SwitchKimi, Kimi Code Switch, Kimi 切换, LLM 供应商管理, AI 供应商切换, 多 LLM 管理, Kimi 用量监控, 智谱 GLM, MiniMax, DeepSeek, OpenRouter, 基元律动, 用量查询, 账单监控, Token 套餐, Claude, GPT, Windows LLM 桌面工具"
content="Kimi Switch, KimiSwitch, KimiCode Switch, KimiCodeSwitch, SwitchKimi, Kimi Code Switch, Kimi 切换, LLM 供应商管理, AI 供应商切换, 多 LLM 管理, Kimi 用量监控, 智谱 GLM, MiniMax, DeepSeek, OpenRouter, 基元律动, 用量查询, 账单监控, Token 套餐, Claude, GPT, Windows LLM 桌面工具"
/>
<!-- Open Graph -->
@@ -24,7 +24,7 @@
content="一键切换 Kimi / 智谱 GLM / MiniMax / DeepSeek 等供应商,用量与账单一目了然,开源 MIT。"
/>
<meta property="og:url" content="https://billowliu2.github.io/KimiSwitch/" />
<meta property="og:image" content="%BASE_URL%og.png" />
<meta property="og:image" content="https://billowliu2.github.io/KimiSwitch/og.png" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
@@ -33,7 +33,7 @@
name="twitter:description"
content="一键切换 Kimi / 智谱 GLM / MiniMax / DeepSeek 等供应商,用量与账单一目了然,开源 MIT。"
/>
<meta name="twitter:image" content="%BASE_URL%og.png" />
<meta name="twitter:image" content="https://billowliu2.github.io/KimiSwitch/og.png" />
<!-- Canonical -->
<link rel="canonical" href="https://billowliu2.github.io/KimiSwitch/" />
@@ -46,7 +46,7 @@
{
"@type": "SoftwareApplication",
"name": "Kimi Switch",
"alternateName": ["KimiSwitch", "KimiCodeSwitch"],
"alternateName": ["KimiSwitch", "KimiCodeSwitch", "Kimi Switch", "KimiCode Switch"],
"url": "https://billowliu2.github.io/KimiSwitch/",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Windows 10, Windows 11",
+18
View File
@@ -16,6 +16,7 @@
"react-router-dom": "^7.18.2"
},
"devDependencies": {
"@types/node": "^26.1.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
@@ -1299,6 +1300,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
"version": "26.1.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.2.tgz",
"integrity": "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~8.3.0"
}
},
"node_modules/@types/prop-types": {
"version": "15.7.15",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
@@ -2723,6 +2734,13 @@
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
"dev": true,
"license": "MIT"
},
"node_modules/update-browserslist-db": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
+1
View File
@@ -17,6 +17,7 @@
"react-router-dom": "^7.18.2"
},
"devDependencies": {
"@types/node": "^26.1.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#0F62FE"><path d="M12 2L4 6v6c0 5 3.5 8.5 8 10 4.5-1.5 8-5 8-10V6l-8-4zm0 4l4 2v4c0 3-1.5 5-4 6-2.5-1-4-3-4-6V8l4-2z"/></svg>

Before

Width:  |  Height:  |  Size: 192 B

+3 -13
View File
@@ -6,27 +6,17 @@
<priority>1.0</priority>
</url>
<url>
<loc>https://billowliu2.github.io/KimiSwitch/#/features</loc>
<loc>https://billowliu2.github.io/KimiSwitch/features</loc>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://billowliu2.github.io/KimiSwitch/#/showcase</loc>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://billowliu2.github.io/KimiSwitch/#/performance</loc>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://billowliu2.github.io/KimiSwitch/#/changelog</loc>
<loc>https://billowliu2.github.io/KimiSwitch/changelog</loc>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://billowliu2.github.io/KimiSwitch/#/download</loc>
<loc>https://billowliu2.github.io/KimiSwitch/download</loc>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
+46
View File
@@ -8,6 +8,10 @@ import Download from "./sections/Download";
import Privacy from "./sections/Privacy";
import CTA from "./sections/CTA";
import Footer from "./components/Footer";
import { useLang, type Dict } from "./i18n";
const SITE_URL = "https://billowliu2.github.io/KimiSwitch";
type SeoKey = keyof Dict["seo"];
function ScrollToTop() {
const { pathname } = useLocation();
@@ -17,6 +21,47 @@ function ScrollToTop() {
return null;
}
/** Update per-page title / description / OG / canonical for SEO. */
function RouteMeta() {
const { pathname } = useLocation();
const { t } = useLang();
useEffect(() => {
const page = pathname.replace(/\/+$/, "");
const seoKey: SeoKey =
page === "/features" || page === "/changelog" || page === "/download"
? (page.slice(1) as SeoKey)
: "home";
const m = t.seo[seoKey];
const url = `${SITE_URL}${page === "" ? "/" : page}`;
document.title = m.title;
setMeta("name", "description", m.description);
setMeta("property", "og:title", m.title);
setMeta("property", "og:description", m.description);
setMeta("property", "og:url", url);
setMeta("name", "twitter:title", m.title);
setMeta("name", "twitter:description", m.description);
const canon = document.querySelector('link[rel="canonical"]');
if (canon) canon.setAttribute("href", url);
}, [pathname, t]);
return null;
}
function setMeta(attr: "name" | "property", key: string, content: string) {
let el = document.head.querySelector<HTMLMetaElement>(
`meta[${attr}="${key}"]`,
);
if (!el) {
el = document.createElement("meta");
el.setAttribute(attr, key);
document.head.appendChild(el);
}
el.setAttribute("content", content);
}
const homePage = (
<>
<Hero />
@@ -30,6 +75,7 @@ export default function App() {
<Nav />
<main className="flex-1">
<ScrollToTop />
<RouteMeta />
<Routes>
<Route path="/" element={homePage} />
<Route
+1 -1
View File
@@ -5,7 +5,7 @@ import { asset } from "../lib/asset";
/** Map recommendLink.name → logo file in public/logos (only when we have one). */
const logoFor: Record<string, string> = {
"Kimi": "logos/kimi.svg",
"智谱 GLM": "logos/glm.svg",
"智谱 GLM": "logos/zhipu.svg",
"DeepSeek": "logos/deepseek.svg",
"OpenCodeGo": "logos/opencode.svg",
"MiniMax": "logos/minimax.svg",
+89 -15
View File
@@ -16,10 +16,10 @@ const zh = {
performance: "性能",
changelog: "更新日志",
download: "下载",
downloadBtn: "下载 v0.6.7",
downloadBtn: "下载 v0.6.9",
},
hero: {
badge: "开源 MIT · Windows 10 / 11",
badge: "v0.6.9 · 开源 MIT · Windows / macOS / Linux",
titleBefore: "统一管理你的",
titleAccent: "AI 供应商",
titleAfter: "",
@@ -141,11 +141,22 @@ const zh = {
fallbackNote: "内置版本记录",
entries: [
{
version: "v0.6.7",
version: "v0.6.9",
date: "2026-08-01",
items: [
"应用内置 Kimi 设备授权登录(等同 kimi login),浏览器授权即用,过期自动续期",
"外链打开统一走 Rust 命令,修复部分链接无法跳转",
"最近请求新增缓存命中率列,每次请求命中一目了然",
"中文模式费用按最新汇率换算人民币(¥)显示,英文模式保持美元",
"仪表盘性能再优化:价格解析记忆化缓存,扫描从秒级降到百毫秒级;右上角新增加载耗时/数据量跟踪",
],
},
{
version: "v0.6.8",
date: "2026-08-01",
items: [
"仪表盘加载提速:models.dev 快照移出主 bundle,异步加载不阻塞首帧",
"Rust 价格索引启动时后台预热;get_summary 扫描结果 8 秒缓存",
"k3-256k 按 k3 牌价计费",
"官网更新:Kimi 风格重设计、中英文切换、更新日志同步 GitHub Releases、三平台下载",
],
},
{
@@ -234,16 +245,16 @@ const zh = {
},
download: {
title: "下载 Kimi Switch",
subtitle: "当前版本 v0.6.7 · Windows 10 / 11 主推,macOS 与 Linux 路线图上。",
subtitle: "当前版本 v0.6.9 · Windows / macOS / Linux 三平台已发布",
autoUpdate: "应用内置自动检测更新,新版本发布后在设置页一键升级。",
ready: "已发布",
wip: "开发中",
githubBtn: "GitHub 下载",
mirrorBtn: "镜像下载",
items: [
{ id: "windows", name: "Windows", ready: true, note: ".msi 与 .exe 安装包,系统托盘常驻" },
{ id: "macos", name: "macOS", ready: false, note: "GitHub Actions 已能构建 .dmg,待官方适配" },
{ id: "linux", name: "Linux", ready: false, note: ".AppImage / .deb / .rpm 构建中" },
{ id: "windows", name: "Windows", ready: true, note: ".msi 安装包,系统托盘常驻" },
{ id: "macos", name: "macOS", ready: true, note: ".dmg 安装包(Apple Silicon),未签名需右键打开" },
{ id: "linux", name: "Linux", ready: true, note: ".deb / .AppImage / .rpm 三格式" },
],
},
cta: {
@@ -252,6 +263,28 @@ const zh = {
download: "免费下载",
source: "GitHub 源码",
},
seo: {
home: {
title: "Kimi Switch — 多 LLM 供应商统一管理 · 用量监控 · 账单一目了然",
description:
"Kimi Switch / KimiCodeSwitch — Windows 桌面端多 LLM 供应商统一管理器,一键切换 Kimi / 智谱 GLM / MiniMax / DeepSeek / OpenRouter / 基元律动,用量账单实时监控,开源 MIT。",
},
features: {
title: "核心功能 - Kimi Switch",
description:
"Kimi Switch 核心功能:多供应商管理、用量与账单监控、Kimi 一键授权登录、智能模型发现与自动更新,22 个预设开箱即用。",
},
changelog: {
title: "更新日志 - Kimi Switch",
description:
"Kimi Switch 更新日志:每个版本的重要变更记录,同步自 GitHub Releases。",
},
download: {
title: "下载 - Kimi Switch",
description:
"下载 Kimi Switch:Windows .msi、macOS .dmg、Linux .deb / .AppImage / .rpm,免费开源 MIT。",
},
},
footer: {
recommend: "推荐供应商",
mirror: "国内镜像",
@@ -280,10 +313,10 @@ const en: Dict = {
performance: "Performance",
changelog: "Changelog",
download: "Download",
downloadBtn: "Download v0.6.7",
downloadBtn: "Download v0.6.9",
},
hero: {
badge: "Open source MIT · Windows 10 / 11",
badge: "v0.6.9 · Open source MIT · Windows / macOS / Linux",
titleBefore: "One app for all your ",
titleAccent: "AI providers",
titleAfter: "",
@@ -404,6 +437,25 @@ const en: Dict = {
syncedNote: "Synced from GitHub Releases",
fallbackNote: "Built-in release notes",
entries: [
{
version: "v0.6.9",
date: "2026-08-01",
items: [
"Recent requests gain a cache-hit-rate column, per request at a glance",
"Chinese UI now shows costs in CNY (latest exchange rate); English keeps USD",
"Dashboard speedup: memoized price resolution drops the scan from seconds to milliseconds; load time / payload tracking in the top-right corner",
],
},
{
version: "v0.6.8",
date: "2026-08-01",
items: [
"Dashboard speedup: models.dev snapshot moved out of the main bundle, async load without blocking first paint",
"Rust price index warmed in the background at startup; get_summary scan cached for 8s",
"k3-256k billed at the k3 list price",
"Website refresh: Kimi-style redesign, zh/en switch, changelog synced from GitHub Releases, downloads for all three platforms",
],
},
{
version: "v0.6.7",
date: "2026-08-01",
@@ -498,16 +550,16 @@ const en: Dict = {
},
download: {
title: "Download Kimi Switch",
subtitle: "Current version v0.6.7 · Windows 10 / 11 first, macOS and Linux on the roadmap.",
subtitle: "Current version v0.6.9 · Windows, macOS and Linux now released",
autoUpdate: "Built-in update detection: upgrade in one click from Settings when a new version ships.",
ready: "Available",
wip: "In development",
githubBtn: "Download from GitHub",
mirrorBtn: "China mirror",
items: [
{ id: "windows", name: "Windows", ready: true, note: ".msi and .exe installers, lives in the system tray" },
{ id: "macos", name: "macOS", ready: false, note: "GitHub Actions already builds .dmg, official support pending" },
{ id: "linux", name: "Linux", ready: false, note: ".AppImage / .deb / .rpm builds in progress" },
{ id: "windows", name: "Windows", ready: true, note: ".msi installer, lives in the system tray" },
{ id: "macos", name: "macOS", ready: true, note: ".dmg installer (Apple Silicon), unsigned - right-click to open" },
{ id: "linux", name: "Linux", ready: true, note: ".deb / .AppImage / .rpm" },
],
},
cta: {
@@ -516,6 +568,28 @@ const en: Dict = {
download: "Free Download",
source: "GitHub Source",
},
seo: {
home: {
title: "Kimi Switch — Unified Management for AI Providers · Usage & Billing",
description:
"Kimi Switch / KimiCodeSwitch — a Windows desktop manager for multiple LLM providers. Switch between Kimi, Zhipu GLM, MiniMax, DeepSeek, OpenRouter and TokenRhythm in one click, with usage and billing at a glance. Open source MIT.",
},
features: {
title: "Core Features - Kimi Switch",
description:
"Kimi Switch core features: multi-provider management, usage & billing, one-click Kimi login, smart model discovery and auto updates. 22 presets out of the box.",
},
changelog: {
title: "Changelog - Kimi Switch",
description:
"Kimi Switch changelog: notable changes in every release, synced from GitHub Releases.",
},
download: {
title: "Download - Kimi Switch",
description:
"Download Kimi Switch: Windows .msi, macOS .dmg, Linux .deb / .AppImage / .rpm. Free and open source under MIT.",
},
},
footer: {
recommend: "Recommended Providers",
mirror: "China mirror",
+3 -3
View File
@@ -1,16 +1,16 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { HashRouter } from "react-router-dom";
import { BrowserRouter } from "react-router-dom";
import { LangProvider } from "./i18n";
import App from "./App";
import "./index.css";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<HashRouter>
<BrowserRouter basename="/KimiSwitch">
<LangProvider>
<App />
</LangProvider>
</HashRouter>
</BrowserRouter>
</StrictMode>,
);
+12 -7
View File
@@ -10,9 +10,14 @@ interface ChangelogEntry {
const API_URL =
"https://api.github.com/repos/billowliu2/KimiSwitch/releases?per_page=20";
const CACHE_KEY = "kimi-switch-changelog";
const CACHE_TTL = 60 * 60 * 1000; // 1 hour
/** Cache key is versioned by the newest embedded release so redeploys
* invalidate stale caches in the browser immediately. */
function cacheKey(embedded: ChangelogEntry[]) {
return `kimi-switch-changelog-${embedded[0]?.version ?? "v1"}`;
}
/** Parse a GitHub release body into bullet items. */
function parseBody(body: string): string[] {
return body
@@ -36,9 +41,9 @@ async function fetchReleases(): Promise<ChangelogEntry[]> {
}));
}
function readCache(): ChangelogEntry[] | null {
function readCache(embedded: ChangelogEntry[]): ChangelogEntry[] | null {
try {
const raw = localStorage.getItem(CACHE_KEY);
const raw = localStorage.getItem(cacheKey(embedded));
if (!raw) return null;
const { ts, data } = JSON.parse(raw) as { ts: number; data: ChangelogEntry[] };
if (Date.now() - ts > CACHE_TTL) return null;
@@ -48,10 +53,10 @@ function readCache(): ChangelogEntry[] | null {
}
}
function writeCache(data: ChangelogEntry[]) {
function writeCache(data: ChangelogEntry[], embedded: ChangelogEntry[]) {
try {
localStorage.setItem(
CACHE_KEY,
cacheKey(embedded),
JSON.stringify({ ts: Date.now(), data }),
);
} catch {
@@ -67,7 +72,7 @@ export default function Changelog() {
useEffect(() => {
let cancelled = false;
const cached = readCache();
const cached = readCache(embedded);
if (cached) {
setRemote(cached);
setSynced(true);
@@ -78,7 +83,7 @@ export default function Changelog() {
if (cancelled) return;
setRemote(data);
setSynced(true);
writeCache(data);
writeCache(data, embedded);
})
.catch(() => {
/* 网络不通时使用内置列表兜底 */
+31 -24
View File
@@ -8,8 +8,27 @@ const icons: Record<string, Icon> = {
linux: LinuxLogo,
};
const GITHUB_RELEASES = "https://github.com/billowliu2/KimiSwitch/releases";
const VERSION = "0.6.9";
const GITHUB = "https://github.com/billowliu2/KimiSwitch";
const MIRROR_RELEASES = "https://git.codingplan.site/admin/KimiCodeSwitch/releases";
const dl = (file: string) => `${GITHUB}/releases/download/v${VERSION}/${file}`;
/** Per-platform download assets for the current release (names match the CI
* release workflow, e.g. Kimi.Switch_0.6.9_x64_en-US.msi). */
const assets: Record<string, { label: string; href: string }[]> = {
windows: [
{ label: "MSI", href: dl("Kimi.Switch_0.6.9_x64_en-US.msi") },
{ label: "镜像", href: MIRROR_RELEASES },
],
macos: [
{ label: "Apple Silicon (.dmg)", href: dl("Kimi.Switch_0.6.9_aarch64.dmg") },
],
linux: [
{ label: ".deb", href: dl("Kimi.Switch_0.6.9_amd64.deb") },
{ label: ".AppImage", href: dl("Kimi.Switch_0.6.9_amd64.AppImage") },
{ label: ".rpm", href: dl("Kimi.Switch-0.6.9-1.x86_64.rpm") },
],
};
export default function Download() {
const { t } = useLang();
@@ -22,44 +41,32 @@ export default function Download() {
<div className="grid grid-cols-1 gap-4 md:grid-cols-3">
{t.download.items.map((p) => {
const Icon = icons[p.id] ?? WindowsLogo;
const links = assets[p.id] ?? [];
return (
<div key={p.id} className="card flex flex-col">
<div className="mb-3 flex items-center justify-between">
<div className="flex h-10 w-10 items-center justify-center rounded-xl border border-primary/25 bg-primary/10 text-primary">
<Icon className="h-5 w-5" weight="duotone" />
</div>
<span
className={`rounded-full px-2.5 py-0.5 text-xs font-medium ${
p.ready
? "bg-primary/10 text-primary border border-primary/25"
: "bg-muted text-muted-foreground border border-border"
}`}
>
{p.ready ? t.download.ready : t.download.wip}
<span className="rounded-full border border-primary/25 bg-primary/10 px-2.5 py-0.5 text-xs font-medium text-primary">
{t.download.ready}
</span>
</div>
<h3 className="mb-2 text-lg font-semibold">{p.name}</h3>
<p className="text-sm text-muted-foreground">{p.note}</p>
{p.ready && (
<div className="mt-4 flex flex-wrap gap-2">
<div className="mt-4 flex flex-wrap gap-2">
{links.map((l) => (
<a
href={GITHUB_RELEASES}
key={l.label}
href={l.href}
target="_blank"
rel="noreferrer"
className="btn-primary text-xs"
className={l.label === "镜像" ? "btn-ghost text-xs" : "btn-primary text-xs"}
>
{t.download.githubBtn}
{l.label}
</a>
<a
href={MIRROR_RELEASES}
target="_blank"
rel="noreferrer"
className="btn-ghost text-xs"
>
{t.download.mirrorBtn}
</a>
</div>
)}
))}
</div>
</div>
);
})}
+22 -3
View File
@@ -1,11 +1,30 @@
import { defineConfig } from "vite";
import { defineConfig, type Plugin } from "vite";
import react from "@vitejs/plugin-react";
import { copyFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
/**
* GitHub Pages SPA fallback: any deep path (e.g. /KimiSwitch/features) is
* served by 404.html; duplicating the built index.html there lets the
* BrowserRouter boot and render the right route. This keeps every page
* indexable as a real URL instead of a `#/` fragment.
*/
function generate404(): Plugin {
return {
name: "generate-404",
apply: "build",
closeBundle() {
const dist = fileURLToPath(new URL("./dist", import.meta.url));
copyFileSync(`${dist}/index.html`, `${dist}/404.html`);
},
};
}
// GitHub Pages subpath: billowliu2.github.io/KimiSwitch/
export default defineConfig({
base: "/KimiSwitch/",
plugins: [react()],
plugins: [react(), generate404()],
resolve: {
alias: { "@": "/src" },
},
});
});