diff --git a/apps/ui/src/App.tsx b/apps/ui/src/App.tsx index cb85f4b..6324cb3 100644 --- a/apps/ui/src/App.tsx +++ b/apps/ui/src/App.tsx @@ -485,29 +485,29 @@ const App = () => { const handleDashboardApply = useCallback( async (override?: DashboardQuery) => { - const actionKey = buildActionKey("dashboard:filter"); - if (isActionPending(actionKey)) { - return; - } - const nextQuery = override ?? dashboardQuery; - startAction(actionKey); - try { - await loadDashboard(nextQuery); - pushNotice("success", "筛选已更新"); - } catch (error) { - pushNotice("error", (error as Error).message); - } finally { - endAction(actionKey); - } - }, - [ - dashboardQuery, - endAction, - isActionPending, - loadDashboard, - pushNotice, - startAction, - ], + const actionKey = buildActionKey("dashboard:filter"); + if (isActionPending(actionKey)) { + return; + } + const nextQuery = override ?? dashboardQuery; + startAction(actionKey); + try { + await loadDashboard(nextQuery); + pushNotice("success", "筛选已更新"); + } catch (error) { + pushNotice("error", (error as Error).message); + } finally { + endAction(actionKey); + } + }, + [ + dashboardQuery, + endAction, + isActionPending, + loadDashboard, + pushNotice, + startAction, + ], ); const loadSites = useCallback(async () => { @@ -667,16 +667,14 @@ const App = () => { proxy_upstream_timeout_ms: String( runtimeSettings?.upstream_timeout_ms ?? 30000, ), - proxy_stream_usage_mode: - runtimeSettings?.stream_usage_mode ?? "full", + proxy_stream_usage_mode: runtimeSettings?.stream_usage_mode ?? "full", proxy_stream_usage_max_bytes: String( runtimeSettings?.stream_usage_max_bytes ?? 0, ), proxy_stream_usage_max_parsers: String( runtimeSettings?.stream_usage_max_parsers ?? 0, ), - proxy_usage_queue_enabled: - runtimeSettings?.usage_queue_enabled ?? true, + proxy_usage_queue_enabled: runtimeSettings?.usage_queue_enabled ?? true, usage_queue_daily_limit: String( runtimeSettings?.usage_queue_daily_limit ?? 10000, ), @@ -1303,17 +1301,16 @@ const App = () => { settingsForm.model_failure_cooldown_minutes, ); const upstreamTimeoutMs = Number(settingsForm.proxy_upstream_timeout_ms); - const streamUsageMode = - settingsForm.proxy_stream_usage_mode.trim().toLowerCase(); + const streamUsageMode = settingsForm.proxy_stream_usage_mode + .trim() + .toLowerCase(); const streamUsageMaxBytes = Number( settingsForm.proxy_stream_usage_max_bytes, ); const streamUsageMaxParsers = Number( settingsForm.proxy_stream_usage_max_parsers, ); - const usageQueueDailyLimit = Number( - settingsForm.usage_queue_daily_limit, - ); + const usageQueueDailyLimit = Number(settingsForm.usage_queue_daily_limit); const usageQueueDirectRatio = Number( settingsForm.usage_queue_direct_write_ratio, ); @@ -1327,9 +1324,7 @@ const App = () => { const cacheCallTokensTtl = Number( settingsForm.cache_ttl_call_tokens_seconds, ); - const cacheSettingsTtl = Number( - settingsForm.cache_ttl_settings_seconds, - ); + const cacheSettingsTtl = Number(settingsForm.cache_ttl_settings_seconds); if ( Number.isNaN(retention) || retention < 1 || diff --git a/apps/ui/src/components/ui/area-chart.tsx b/apps/ui/src/components/ui/area-chart.tsx index a6e1872..9d14c36 100644 --- a/apps/ui/src/components/ui/area-chart.tsx +++ b/apps/ui/src/components/ui/area-chart.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo, useRef, useState } from "hono/jsx/dom"; -import { cx, type ClassName } from "./utils"; +import { type ClassName, cx } from "./utils"; export type AreaChartPoint = { label: string; @@ -111,7 +111,10 @@ export const AreaChart = ({ } const maxValue = Math.max(...data.map((item) => item.value), 1); const drawableWidth = Math.max(1, viewBoxWidth - paddingX * 2); - const drawableHeight = Math.max(1, viewBoxHeight - paddingTop - paddingBottom); + const drawableHeight = Math.max( + 1, + viewBoxHeight - paddingTop - paddingBottom, + ); return data.map((item, index) => { const x = data.length === 1 @@ -143,7 +146,8 @@ export const AreaChart = ({ const horizontalGridLines = useMemo( () => [0.2, 0.4, 0.6, 0.8].map( - (step) => paddingTop + step * (viewBoxHeight - paddingTop - paddingBottom), + (step) => + paddingTop + step * (viewBoxHeight - paddingTop - paddingBottom), ), [paddingBottom, paddingTop, viewBoxHeight], ); diff --git a/apps/ui/src/components/ui/column-picker.tsx b/apps/ui/src/components/ui/column-picker.tsx index 0360c59..54faf68 100644 --- a/apps/ui/src/components/ui/column-picker.tsx +++ b/apps/ui/src/components/ui/column-picker.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo, useState } from "hono/jsx/dom"; import { Button } from "./button"; import { Popover, PopoverContent } from "./popover"; -import { cx, type ClassName } from "./utils"; +import { type ClassName, cx } from "./utils"; export type ColumnOption = { id: string; @@ -77,7 +77,10 @@ export const ColumnPicker = ({ {label} - +
显示列
diff --git a/apps/ui/src/components/ui/dialog.tsx b/apps/ui/src/components/ui/dialog.tsx index 4820d61..5872197 100644 --- a/apps/ui/src/components/ui/dialog.tsx +++ b/apps/ui/src/components/ui/dialog.tsx @@ -1,4 +1,5 @@ import type { JSX } from "hono/jsx"; +import { createPortal } from "hono/jsx/dom"; import { cx } from "./utils"; export type DialogProps = { @@ -7,22 +8,32 @@ export type DialogProps = { children?: unknown; }; -export const Dialog = ({ open, onClose, children }: DialogProps) => { +export const Dialog = ({ + open, + onClose, + children, +}: DialogProps): JSX.Element | null => { if (!open) { return null; } + if (typeof document === "undefined") { + return null; + } return ( -
-
+ <> + {createPortal( +
+
, + document.body, + )} + ); }; @@ -32,7 +43,7 @@ export const DialogContent = ({ }: JSX.IntrinsicElements["div"]) => ( -