pull/227/merge
rtm516 2026-10-30 21:14:03 +00:00 committed by GitHub
commit 0663fdeec6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 38 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { Container, Group, Image } from '@mantine/core'
import { Container, Group, Image, Text } from '@mantine/core'
import classes from '@/styles/Header.module.css'
import { pageConfig } from '@/uptime.config'
import { PageConfigLink } from '@/types/config'
@ -20,25 +20,36 @@ export default function Header({ style }: { style?: React.CSSProperties }) {
)
}
const links = [{ label: t('Incidents'), link: '/incidents' }, ...(pageConfig.links || [])]
const links = [
...(pageConfig.incidents !== false ? [{ label: t('Incidents'), link: '/incidents' }] : []),
...(pageConfig.links || []),
]
const logoHref = location.pathname == '/' ? pageConfig.logoLink ?? 'https://github.com/lyc8503/UptimeFlare' : '/'
return (
<header className={classes.header} style={style}>
<Container size="md" className={classes.inner}>
<div>
<Group gap="xs" wrap="nowrap">
<a
href={location.pathname == '/' ? 'https://github.com/lyc8503/UptimeFlare' : '/'}
href={logoHref}
target={location.pathname == '/' ? '_blank' : undefined}
style={{ display: 'flex', alignItems: 'center' }}
>
<Image
src={pageConfig.logo ?? '/logo.svg'}
h={56}
w={{ base: 140, sm: 190 }}
p={2}
fit="contain"
alt="logo"
/>
</a>
</div>
{pageConfig.showTitle && pageConfig.title && (
<Text fw={600} size="lg" lineClamp={1}>
{pageConfig.title}
</Text>
)}
</Group>
<Group gap={5} visibleFrom="sm">
{links?.map(linkToElement)}

View File

@ -134,7 +134,11 @@ export default function IncidentsPage({ monitors }: { monitors: MonitorTarget[]
}
export async function getServerSideProps() {
const { workerConfig } = await import('@/uptime.config')
const { workerConfig, pageConfig } = await import('@/uptime.config')
// If the incidents feature is disabled, don't expose this page
if (pageConfig.incidents === false) {
return { redirect: { destination: '/', permanent: false } }
}
// Only present these values to client
const monitors: MonitorTarget[] = workerConfig.monitors.map((monitor) => ({
id: monitor.id,

View File

@ -79,11 +79,11 @@ export async function getServerSideProps() {
id: monitor.id,
name: monitor.name,
// @ts-ignore
tooltip: monitor?.tooltip,
tooltip: monitor?.tooltip ?? null,
// @ts-ignore
statusPageLink: monitor?.statusPageLink,
statusPageLink: monitor?.statusPageLink ?? null,
// @ts-ignore
hideLatencyChart: monitor?.hideLatencyChart,
hideLatencyChart: monitor?.hideLatencyChart ?? null,
}
})

View File

@ -6,6 +6,9 @@ export type PageConfig = {
group?: PageConfigGroup
favicon?: string
logo?: string
logoLink?: string
showTitle?: boolean
incidents?: boolean
maintenances?: {
upcomingColor?: string
}

View File

@ -20,6 +20,14 @@ const pageConfig: PageConfig = {
// favicon: 'https://example.com/favicon.ico',
// [OPTIONAL] Set the path to your logo, default to '/logo.svg' if not specified
// logo: 'https://example.com/logo.svg',
// [OPTIONAL] Custom link opened when clicking the header logo (from the home page),
// default to 'https://github.com/lyc8503/UptimeFlare' if not specified
// logoLink: 'https://example.com',
// [OPTIONAL] Show the `title` text next to the logo in the header, default to false
// showTitle: true,
// [OPTIONAL] Set to false to disable the incidents feature entirely
// (hides the "Incidents" header tab and makes the /incidents page redirect home), default to true
// incidents: false,
// [OPTIONAL] Maintenance related settings
maintenances: {
// [OPTIONAL] The color of upcoming maintenance alerts, default to 'gray'

View File

@ -7,6 +7,8 @@ import {
} from '../../types/config'
export async function getFromStore(env: Env, key: string): Promise<string | null> {
// No D1 binding outside the Cloudflare runtime (e.g. plain `next dev`); return empty state instead of throwing
if (!env?.UPTIMEFLARE_D1) return null
const stmt = env.UPTIMEFLARE_D1.prepare('SELECT value FROM uptimeflare WHERE key = ?')
const result = await stmt.bind(key).first<{ value: string }>()
return result?.value || null