feat(posts): add @mention highlighting and vote segment display
All checks were successful
Admin CI / build-and-push-web (push) Successful in 2m59s

- Parse post content to highlight @mentions with blue styling
- Render vote segments from post data with formatted options display
- Add MessageSegment interface and segments/is_vote fields to Post type
- Update API base URL and branding from Carrot BBS to WithYou
This commit is contained in:
lafay
2026-04-25 13:01:36 +08:00
parent 2d1dc3673a
commit 4d25bf00ba
7 changed files with 34 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react'
import { useState, useEffect } from 'react'
import { Users, FileText, MessageSquare, Clock, TrendingUp, Calendar, CalendarDays, CalendarRange } from 'lucide-react'
import { StatsCard } from '@/components/StatsCard'
import { ActivityChart } from '@/components/ActivityChart'
@@ -78,7 +78,7 @@ export default function Dashboard() {
<div className="space-y-6">
<div>
<h1 className="text-3xl font-bold">Dashboard</h1>
<p className="text-muted-foreground"> Carrot BBS </p>
<p className="text-muted-foreground"> WithYou </p>
</div>
{/* 统计卡片 */}

View File

@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useState } from 'react'
import { useNavigate, useLocation } from 'react-router-dom'
import { useAuthStore } from '@/stores/authStore'
import { Button } from '@/components/ui/button'
@@ -62,7 +62,7 @@ export default function Login() {
<span className="text-2xl font-bold">C</span>
</div>
</div>
<CardTitle className="text-2xl font-bold">Carrot BBS</CardTitle>
<CardTitle className="text-2xl font-bold">WithYou</CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<form onSubmit={handleSubmit}>

View File

@@ -636,8 +636,25 @@ export default function Posts() {
<div className="space-y-4">
<h3 className="text-2xl font-bold text-slate-900 leading-tight">{selectedPost.title}</h3>
<div className="prose prose-slate max-w-none">
<p className="text-slate-700 whitespace-pre-wrap leading-relaxed text-base">{selectedPost.content}</p>
<p className="text-slate-700 whitespace-pre-wrap leading-relaxed text-base">
{selectedPost.content?.split(/@(\S+)/g).map((part, i) =>
i % 2 === 1 ? <span key={i} className="text-blue-600 font-medium">@{part}</span> : part
)}
</p>
</div>
{/* 投票信息(从 segments 解析) */}
{selectedPost.segments?.filter(s => s.type === 'vote').map((seg, i) => (
<div key={i} className="mt-3 p-4 rounded-lg border border-slate-200 bg-slate-50">
<div className="flex items-center gap-2 text-sm font-medium text-slate-700 mb-3">
<span>📊 </span>
</div>
{seg.data?.options?.map((opt: any, j: number) => (
<div key={j} className="py-1.5 text-slate-600">
{j + 1}. {opt.content}
</div>
))}
</div>
))}
</div>
{/* 图片展示 */}