mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 01:21:56 +08:00
更新 Vite 配置中的 API 代理地址,改为使用远程服务器。同时优化 App 组件的背景层逻辑,移除不必要的背景图设置,简化代码结构,提升用户体验。
This commit is contained in:
parent
63b5dd1893
commit
d9995fab5f
47
src/App.tsx
47
src/App.tsx
@ -6,11 +6,9 @@ import { DashCommand } from "./components/DashCommand"
|
||||
import ErrorBoundary from "./components/ErrorBoundary"
|
||||
import Footer from "./components/Footer"
|
||||
import Header, { RefreshToast } from "./components/Header"
|
||||
import { useBackground } from "./hooks/use-background"
|
||||
import { useTheme } from "./hooks/use-theme"
|
||||
import { InjectContext } from "./lib/inject"
|
||||
import { fetchSetting } from "./lib/nezha-api"
|
||||
import { cn } from "./lib/utils"
|
||||
import ErrorPage from "./pages/ErrorPage"
|
||||
import NotFound from "./pages/NotFound"
|
||||
import Server from "./pages/Server"
|
||||
@ -25,7 +23,6 @@ const App: React.FC = () => {
|
||||
})
|
||||
const { setTheme } = useTheme()
|
||||
const [isCustomCodeInjected, setIsCustomCodeInjected] = useState(false)
|
||||
const { backgroundImage: customBackgroundImage } = useBackground()
|
||||
|
||||
useEffect(() => {
|
||||
if (settingData?.data?.config?.custom_code) {
|
||||
@ -57,41 +54,31 @@ const App: React.FC = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
const customMobileBackgroundImage = window.CustomMobileBackgroundImage !== "" ? window.CustomMobileBackgroundImage : undefined
|
||||
|
||||
return (
|
||||
<Router basename={import.meta.env.BASE_URL}>
|
||||
<ErrorBoundary>
|
||||
{/* 固定定位的背景层 */}
|
||||
{customBackgroundImage && (
|
||||
<div className="relative min-h-screen">
|
||||
{/* 固定定位的背景层 */}
|
||||
<div
|
||||
className={cn("fixed inset-0 z-0 bg-cover min-h-lvh bg-no-repeat bg-center dark:brightness-75", {
|
||||
"hidden sm:block": customMobileBackgroundImage,
|
||||
})}
|
||||
style={{ backgroundImage: `url(${customBackgroundImage})` }}
|
||||
className="fixed inset-0 bg-cover bg-no-repeat bg-center dark:brightness-75"
|
||||
style={{
|
||||
backgroundImage: `url(https://random-api.czl.net/pic/normal)`,
|
||||
zIndex: -1
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{customMobileBackgroundImage && (
|
||||
<div
|
||||
className={cn("fixed inset-0 z-0 bg-cover min-h-lvh bg-no-repeat bg-center sm:hidden dark:brightness-75")}
|
||||
style={{ backgroundImage: `url(${customMobileBackgroundImage})` }}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className={cn("flex min-h-screen w-full flex-col", {
|
||||
"bg-background": !customBackgroundImage,
|
||||
})}
|
||||
>
|
||||
<main className="flex z-20 min-h-[calc(100vh-calc(var(--spacing)*8))] flex-1 flex-col gap-2 p-2 md:p-6 md:pt-4">
|
||||
|
||||
<main className="relative flex min-h-screen flex-col gap-2 p-2 md:p-6 md:pt-4 bg-transparent">
|
||||
<RefreshToast />
|
||||
<Header />
|
||||
<DashCommand />
|
||||
<Routes>
|
||||
<Route path="/" element={<Server />} />
|
||||
<Route path="/server/:id" element={<ServerDetail />} />
|
||||
<Route path="/error" element={<ErrorPage />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
<div className="flex-1">
|
||||
<Routes>
|
||||
<Route path="/" element={<Server />} />
|
||||
<Route path="/server/:id" element={<ServerDetail />} />
|
||||
<Route path="/error" element={<ErrorPage />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</div>
|
||||
<Footer />
|
||||
</main>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user