mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 22:22:57 +03:00
OmniRoute is an intelligent API gateway that unifies 20+ AI providers behind a single OpenAI-compatible endpoint. Features include intelligent routing with 6 strategies, multi-format translation (OpenAI/Claude/Gemini/Responses API), circuit breakers, semantic caching, combo fallback chains, real-time health monitoring, and a full dashboard with provider management, analytics, and CLI tool integration. Key highlights: - 20+ providers (Claude Code, Codex, Gemini CLI, GitHub Copilot, iFlow, Qwen, Kiro, etc.) - 6 routing strategies (Fill First, Round Robin, P2C, Random, Least Used, Cost Optimized) - Export/Import database backup with full archive support - Translator Playground with 4 modes (Playground, Chat Tester, Test Bench, Live Monitor) - 100% TypeScript across src/ and open-sse/ - Docker support with multi-stage builds - Comprehensive documentation and 9 dashboard screenshots
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { create } from "zustand";
|
|
import { persist } from "zustand/middleware";
|
|
import { THEME_CONFIG } from "@/shared/constants/config";
|
|
|
|
interface ThemeState {
|
|
theme: string;
|
|
setTheme: (theme: string) => void;
|
|
toggleTheme: () => void;
|
|
initTheme: () => void;
|
|
}
|
|
|
|
const useThemeStore = create<ThemeState>()(
|
|
persist(
|
|
(set, get) => ({
|
|
theme: THEME_CONFIG.defaultTheme,
|
|
|
|
setTheme: (theme) => {
|
|
set({ theme });
|
|
applyTheme(theme);
|
|
},
|
|
|
|
toggleTheme: () => {
|
|
const currentTheme = get().theme;
|
|
const newTheme = currentTheme === "dark" ? "light" : "dark";
|
|
set({ theme: newTheme });
|
|
applyTheme(newTheme);
|
|
},
|
|
|
|
initTheme: () => {
|
|
const theme = get().theme;
|
|
applyTheme(theme);
|
|
},
|
|
}),
|
|
{
|
|
name: THEME_CONFIG.storageKey,
|
|
}
|
|
)
|
|
);
|
|
|
|
// Apply theme to document
|
|
function applyTheme(theme: string) {
|
|
if (typeof window === "undefined") return;
|
|
|
|
const root = document.documentElement;
|
|
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
|
|
const effectiveTheme = theme === "system" ? systemTheme : theme;
|
|
|
|
if (effectiveTheme === "dark") {
|
|
root.classList.add("dark");
|
|
} else {
|
|
root.classList.remove("dark");
|
|
}
|
|
}
|
|
|
|
export default useThemeStore;
|