mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 03:32:25 +08:00
fix(ui): integrate usage dashboard and fix type errors
Add usage dashboard tab to settings page. Fix UsageScriptModal TypeScript type annotations.
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|||||||
import { Play, Wand2, Eye, EyeOff, Save } from "lucide-react";
|
import { Play, Wand2, Eye, EyeOff, Save } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Provider, UsageScript } from "@/types";
|
import { Provider, UsageScript, UsageData } from "@/types";
|
||||||
import { usageApi, type AppId } from "@/lib/api";
|
import { usageApi, type AppId } from "@/lib/api";
|
||||||
import JsonEditor from "./JsonEditor";
|
import JsonEditor from "./JsonEditor";
|
||||||
import * as prettier from "prettier/standalone";
|
import * as prettier from "prettier/standalone";
|
||||||
@@ -220,7 +220,7 @@ const UsageScriptModal: React.FC<UsageScriptModalProps> = ({
|
|||||||
);
|
);
|
||||||
if (result.success && result.data && result.data.length > 0) {
|
if (result.success && result.data && result.data.length > 0) {
|
||||||
const summary = result.data
|
const summary = result.data
|
||||||
.map((plan) => {
|
.map((plan: UsageData) => {
|
||||||
const planInfo = plan.planName ? `[${plan.planName}]` : "";
|
const planInfo = plan.planName ? `[${plan.planName}]` : "";
|
||||||
return `${planInfo} ${t("usage.remaining")} ${plan.remaining} ${plan.unit}`;
|
return `${planInfo} ${t("usage.remaining")} ${plan.remaining} ${plan.unit}`;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { DirectorySettings } from "@/components/settings/DirectorySettings";
|
|||||||
import { ImportExportSection } from "@/components/settings/ImportExportSection";
|
import { ImportExportSection } from "@/components/settings/ImportExportSection";
|
||||||
import { AboutSection } from "@/components/settings/AboutSection";
|
import { AboutSection } from "@/components/settings/AboutSection";
|
||||||
import { ProxyPanel } from "@/components/proxy";
|
import { ProxyPanel } from "@/components/proxy";
|
||||||
|
import { PricingConfigPanel } from "@/components/usage/PricingConfigPanel";
|
||||||
|
import { UsageDashboard } from "@/components/usage/UsageDashboard";
|
||||||
import { useSettings } from "@/hooks/useSettings";
|
import { useSettings } from "@/hooks/useSettings";
|
||||||
import { useImportExport } from "@/hooks/useImportExport";
|
import { useImportExport } from "@/hooks/useImportExport";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -163,13 +165,16 @@ export function SettingsPage({
|
|||||||
onValueChange={setActiveTab}
|
onValueChange={setActiveTab}
|
||||||
className="flex flex-col h-full"
|
className="flex flex-col h-full"
|
||||||
>
|
>
|
||||||
<TabsList className="grid w-full grid-cols-3 mb-6 glass rounded-xl">
|
<TabsList className="grid w-full grid-cols-4 mb-6 glass rounded-xl">
|
||||||
<TabsTrigger value="general">
|
<TabsTrigger value="general">
|
||||||
{t("settings.tabGeneral")}
|
{t("settings.tabGeneral")}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger value="advanced">
|
<TabsTrigger value="advanced">
|
||||||
{t("settings.tabAdvanced")}
|
{t("settings.tabAdvanced")}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="usage">
|
||||||
|
{t("usage.title", "使用统计")}
|
||||||
|
</TabsTrigger>
|
||||||
<TabsTrigger value="about">{t("common.about")}</TabsTrigger>
|
<TabsTrigger value="about">{t("common.about")}</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
@@ -210,6 +215,9 @@ export function SettingsPage({
|
|||||||
{/* 代理服务面板 */}
|
{/* 代理服务面板 */}
|
||||||
<ProxyPanel />
|
<ProxyPanel />
|
||||||
|
|
||||||
|
{/* 模型定价配置 */}
|
||||||
|
<PricingConfigPanel />
|
||||||
|
|
||||||
<ImportExportSection
|
<ImportExportSection
|
||||||
status={importStatus}
|
status={importStatus}
|
||||||
selectedFile={selectedFile}
|
selectedFile={selectedFile}
|
||||||
@@ -247,6 +255,10 @@ export function SettingsPage({
|
|||||||
<TabsContent value="about" className="mt-0">
|
<TabsContent value="about" className="mt-0">
|
||||||
<AboutSection isPortable={isPortable} />
|
<AboutSection isPortable={isPortable} />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="usage" className="mt-0">
|
||||||
|
<UsageDashboard />
|
||||||
|
</TabsContent>
|
||||||
</div>
|
</div>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user