fix: repair monitor sidebar and alert rendering

This commit is contained in:
zhi
2026-03-11 17:26:37 +00:00
parent d574258c8e
commit ddcbd28967
2 changed files with 15 additions and 17 deletions

View File

@@ -1,7 +1,7 @@
import { useState, useEffect } from react
import { Link, useLocation } from react-router-dom
import api from @/services/api
import type { User } from @/types
import { useState, useEffect } from 'react'
import { Link, useLocation } from 'react-router-dom'
import api from '@/services/api'
import type { User } from '@/types'
interface Props {
user: User | null
@@ -17,11 +17,11 @@ export default function Sidebar({ user, onLogout }: Props) {
setUnreadCount(0)
return
}
api.get<{ count: number }>(/notifications/count)
api.get<{ count: number }>('/notifications/count')
.then(({ data }) => setUnreadCount(data.count))
.catch(() => {})
const timer = setInterval(() => {
api.get<{ count: number }>(/notifications/count)
api.get<{ count: number }>('/notifications/count')
.then(({ data }) => setUnreadCount(data.count))
.catch(() => {})
}, 30000)
@@ -29,14 +29,14 @@ export default function Sidebar({ user, onLogout }: Props) {
}, [user])
const links = user ? [
{ to: /, icon: 📊, label: },
{ to: /issues, icon: 📋, label: Issues },
{ to: /projects, icon: 📁, label: },
{ to: /milestones, icon: 🏁, label: },
{ to: /notifications, icon: 🔔, label: `${unreadCount > 0 ? ` (${unreadCount})` : }` },
{ to: /monitor, icon: 📡, label: Monitor },
{ to: '/', icon: '📊', label: '仪表盘' },
{ to: '/issues', icon: '📋', label: 'Issues' },
{ to: '/projects', icon: '📁', label: '项目' },
{ to: '/milestones', icon: '🏁', label: '里程碑' },
{ to: '/notifications', icon: '🔔', label: '通知' + (unreadCount > 0 ? ' (' + unreadCount + ')' : '') },
{ to: '/monitor', icon: '📡', label: 'Monitor' },
] : [
{ to: /monitor, icon: 📡, label: Monitor },
{ to: '/monitor', icon: '📡', label: 'Monitor' },
]
return (
@@ -46,7 +46,7 @@ export default function Sidebar({ user, onLogout }: Props) {
</div>
<ul className="nav-links">
{links.map((l) => (
<li key={l.to} className={pathname === l.to || (l.to !== / && pathname.startsWith(l.to)) ? active : }>
<li key={l.to} className={pathname === l.to || (l.to !== '/' && pathname.startsWith(l.to)) ? 'active' : ''}>
<Link to={l.to}>{l.icon} {l.label}</Link>
</li>
))}

View File

@@ -144,9 +144,7 @@ export default function MonitorPage() {
const createChallenge = async (id: number) => {
const r = await api.post<{ identifier: string; challenge_uuid: string; expires_at: string }>('/monitor/admin/servers/' + id + '/challenge')
alert('identifier=' + r.data.identifier + '
challenge_uuid=' + r.data.challenge_uuid + '
expires_at=' + r.data.expires_at)
alert('identifier=' + r.data.identifier + '\nchallenge_uuid=' + r.data.challenge_uuid + '\nexpires_at=' + r.data.expires_at)
}
if (loading) return <div className='loading'>Monitor loading...</div>