Commit 12121653 authored by 王蔡翾's avatar 王蔡翾
Browse files

初始化

parents
Pipeline #438 failed with stages
in 0 seconds
/** 共享静态资源路径:集中定义,避免打包时重复内联同一张图片 */
export const BEE_IMG = '/bee-briefcase.png'
export const AVATAR_IMG = '/avatar-user.png'
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import type {
CompanyProfile, ResearchConversation, ScheduleTask, SearchBatch, SearchConditions,
WatchRecord, WatchStatus,
} from '../types'
import { emptyProfile, demoProfile, HISTORY_STATUSES } from '../types'
import { PROJECTS } from '../data/projects'
import type { Project } from '../types'
// ---------- 本地持久化 ----------
const LS_KEY = 'ruzhou-store-v1'
interface Persisted {
profile: CompanyProfile
watch: WatchRecord[]
tasks: ScheduleTask[]
research: ResearchConversation[]
batches: SearchBatch[]
customTags: string[]
customProjects: Project[]
}
/** 旧版状态名 → 新状态名(状态体系细化后的数据迁移) */
const STATUS_MIGRATION: Record<string, WatchStatus> = {
已提交: '已提交投标文件',
已结束: '未中标',
}
const migrateStatus = (s: WatchStatus): WatchStatus => STATUS_MIGRATION[s] ?? s
function loadPersisted(): Persisted {
try {
const raw = localStorage.getItem(LS_KEY)
if (raw) {
const parsed = JSON.parse(raw)
const savedProfile = { ...emptyProfile, ...parsed.profile }
return {
// 从未填写过档案时载入演示档案,便于直接演示匹配度打分;填过则尊重用户数据
profile: savedProfile.companyName.trim() ? savedProfile : { ...demoProfile },
watch: (parsed.watch ?? []).map((w: WatchRecord) => ({
...w,
tags: w.tags ?? [],
status: migrateStatus(w.status),
history: (w.history ?? []).map(h => ({ ...h, status: migrateStatus(h.status) })),
})),
tasks: parsed.tasks ?? [],
research: parsed.research ?? [],
batches: parsed.batches ?? [],
customTags: parsed.customTags ?? [],
customProjects: parsed.customProjects ?? [],
}
}
} catch { /* ignore */ }
return { profile: { ...demoProfile }, watch: [], tasks: [], research: [], batches: [], customTags: [], customProjects: [] }
}
export function nowStr(): string {
const d = new Date()
const p = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
}
export function uid(prefix: string): string {
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`
}
// ---------- 检索逻辑(严格按用户条件执行,不做二次过滤/重排) ----------
export function runSearch(conditions: SearchConditions): string[] {
const kw = conditions.keyword.trim().toLowerCase()
const region = conditions.region.trim()
const min = conditions.budgetMin.trim() === '' ? null : Number(conditions.budgetMin)
const max = conditions.budgetMax.trim() === '' ? null : Number(conditions.budgetMax)
const now = new Date()
const rangeDays = conditions.publishRange === '7d' ? 7 : conditions.publishRange === '30d' ? 30 : conditions.publishRange === '90d' ? 90 : null
return PROJECTS.filter(p => {
if (kw) {
const hay = [p.name, p.purchaser, p.region, ...p.keywords].join(' ').toLowerCase()
// 多个关键词用空格分隔,需全部命中
const terms = kw.split(/\s+/)
if (!terms.every(t => hay.includes(t))) return false
}
if (region && !p.region.includes(region)) return false
if (min !== null || max !== null) {
// 预算条件仅在用户明确设置时生效;未披露预算的项目无法判断,按不命中处理
if (p.budget === null) return false
if (min !== null && p.budget < min) return false
if (max !== null && p.budget > max) return false
}
if (rangeDays !== null) {
const pub = new Date(p.publishDate)
if ((now.getTime() - pub.getTime()) / 86400000 > rangeDays) return false
}
return true
}).map(p => p.id)
}
export function conditionsText(c: SearchConditions): string {
const parts: string[] = []
if (c.keyword.trim()) parts.push(`关键词「${c.keyword.trim()}」`)
if (c.region.trim()) parts.push(`地区「${c.region.trim()}」`)
if (c.budgetMin.trim() || c.budgetMax.trim()) {
parts.push(`预算 ${c.budgetMin.trim() || '不限'} ~ ${c.budgetMax.trim() || '不限'} 万元`)
}
const rangeMap = { '7d': '近 7 天', '30d': '近 30 天', '90d': '近 90 天', all: '全部时间' }
parts.push(`发布于${rangeMap[c.publishRange]}`)
return parts.join(' · ')
}
// ---------- Context ----------
interface Store {
profile: CompanyProfile
saveProfile: (p: CompanyProfile) => void
watch: WatchRecord[]
addWatch: (projectId: string) => void
removeWatch: (projectId: string) => void
setWatchStatus: (projectId: string, status: WatchStatus) => void
setWatchNote: (projectId: string, note: string) => void
isWatched: (projectId: string) => boolean
toggleWatchTag: (projectId: string, tag: string) => void
customTags: string[]
addCustomTag: (tag: string) => void
removeCustomTag: (tag: string) => void
customProjects: Project[]
addCustomProject: (p: Project) => void
findProject: (id: string) => Project | undefined
tasks: ScheduleTask[]
saveTask: (t: ScheduleTask) => void
deleteTask: (id: string) => void
runTaskNow: (id: string) => void
research: ResearchConversation[]
saveConversation: (c: ResearchConversation) => void
deleteConversation: (id: string) => void
batches: SearchBatch[]
addBatch: (b: SearchBatch) => void
}
const StoreContext = createContext<Store | null>(null)
export function StoreProvider({ children }: { children: React.ReactNode }) {
const [state, setState] = useState<Persisted>(loadPersisted)
useEffect(() => {
try { localStorage.setItem(LS_KEY, JSON.stringify(state)) } catch { /* ignore */ }
}, [state])
const saveProfile = useCallback((p: CompanyProfile) => {
setState(s => ({
...s,
profile: { ...p, version: s.profile.version + 1, updatedAt: nowStr() },
}))
}, [])
const addWatch = useCallback((projectId: string) => {
setState(s => {
// 同一个项目只保留一条关注记录,不因重复来源产生多条
if (s.watch.some(w => w.projectId === projectId)) return s
const rec: WatchRecord = {
projectId, status: '已关注', note: '', tags: [], createdAt: nowStr(),
history: [{ status: '已关注', time: nowStr(), note: '' }],
}
return { ...s, watch: [rec, ...s.watch] }
})
}, [])
const removeWatch = useCallback((projectId: string) => {
setState(s => ({ ...s, watch: s.watch.filter(w => w.projectId !== projectId) }))
}, [])
const setWatchStatus = useCallback((projectId: string, status: WatchStatus) => {
setState(s => ({
...s,
watch: s.watch.map(w => w.projectId === projectId && w.status !== status
? { ...w, status, history: [...w.history, { status, time: nowStr(), note: w.note }] }
: w),
}))
}, [])
const setWatchNote = useCallback((projectId: string, note: string) => {
setState(s => ({ ...s, watch: s.watch.map(w => w.projectId === projectId ? { ...w, note } : w) }))
}, [])
const toggleWatchTag = useCallback((projectId: string, tag: string) => {
setState(s => ({
...s,
watch: s.watch.map(w => {
if (w.projectId !== projectId) return w
const has = w.tags.includes(tag)
return { ...w, tags: has ? w.tags.filter(t => t !== tag) : [...w.tags, tag] }
}),
}))
}, [])
const addCustomTag = useCallback((tag: string) => {
setState(s => s.customTags.includes(tag) ? s : { ...s, customTags: [...s.customTags, tag] })
}, [])
const removeCustomTag = useCallback((tag: string) => {
setState(s => ({
...s,
customTags: s.customTags.filter(t => t !== tag),
// 删除标签时同步从各项目上去掉,避免残留失效标签
watch: s.watch.map(w => w.tags.includes(tag) ? { ...w, tags: w.tags.filter(t => t !== tag) } : w),
}))
}, [])
const addCustomProject = useCallback((p: Project) => {
setState(s => {
if (s.customProjects.some(x => x.id === p.id) || PROJECTS.some(x => x.id === p.id)) return s
const rec: WatchRecord = {
projectId: p.id, status: '已关注', note: '', tags: [], createdAt: nowStr(),
history: [{ status: '已关注', time: nowStr(), note: '' }],
}
const watch = s.watch.some(w => w.projectId === p.id) ? s.watch : [rec, ...s.watch]
return { ...s, customProjects: [p, ...s.customProjects], watch }
})
}, [])
const saveTask = useCallback((t: ScheduleTask) => {
setState(s => {
const idx = s.tasks.findIndex(x => x.id === t.id)
if (idx >= 0) {
// 编辑不覆盖过去运行记录
const next = [...s.tasks]
next[idx] = { ...t, runs: s.tasks[idx].runs }
return { ...s, tasks: next }
}
return { ...s, tasks: [...s.tasks, t] }
})
}, [])
const deleteTask = useCallback((id: string) => {
setState(s => ({ ...s, tasks: s.tasks.filter(t => t.id !== id) }))
}, [])
const runTaskNow = useCallback((id: string) => {
setState(s => ({
...s,
tasks: s.tasks.map(t => {
if (t.id !== id) return t
const ids = runSearch(t.conditions)
return { ...t, runs: [{ time: nowStr(), status: 'success' as const, count: ids.length }, ...t.runs] }
}),
}))
}, [])
const saveConversation = useCallback((c: ResearchConversation) => {
setState(s => {
const idx = s.research.findIndex(x => x.id === c.id)
if (idx >= 0) {
const next = [...s.research]
next[idx] = c
return { ...s, research: next }
}
return { ...s, research: [c, ...s.research] }
})
}, [])
const deleteConversation = useCallback((id: string) => {
setState(s => ({ ...s, research: s.research.filter(c => c.id !== id) }))
}, [])
const addBatch = useCallback((b: SearchBatch) => {
setState(s => ({ ...s, batches: [b, ...s.batches].slice(0, 30) }))
}, [])
const value = useMemo<Store>(() => ({
profile: state.profile,
saveProfile,
watch: state.watch,
addWatch, removeWatch, setWatchStatus, setWatchNote,
isWatched: (pid: string) => state.watch.some(w => w.projectId === pid),
toggleWatchTag,
customTags: state.customTags,
addCustomTag,
removeCustomTag,
customProjects: state.customProjects,
addCustomProject,
findProject: (id: string) => state.customProjects.find(p => p.id === id) ?? PROJECTS.find(p => p.id === id),
tasks: state.tasks,
saveTask, deleteTask, runTaskNow,
research: state.research,
saveConversation, deleteConversation,
batches: state.batches,
addBatch,
}), [state, saveProfile, addWatch, removeWatch, setWatchStatus, setWatchNote, toggleWatchTag, addCustomTag, removeCustomTag, addCustomProject, saveTask, deleteTask, runTaskNow, saveConversation, deleteConversation, addBatch])
return <StoreContext.Provider value={value}>{children}</StoreContext.Provider>
}
export function useStore(): Store {
const ctx = useContext(StoreContext)
if (!ctx) throw new Error('useStore must be used within StoreProvider')
return ctx
}
export function isHistoryStatus(s: WatchStatus): boolean {
return (HISTORY_STATUSES as string[]).includes(s)
}
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
)
import { useEffect, useMemo, useRef, useState } from 'react'
import { useNavigate } from 'react-router'
import {
Search, Sparkles, Building2, ChevronLeft, ChevronRight, ExternalLink, Star,
ArrowRight, Layers, SlidersHorizontal, X,
} from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
import type { AiPanelState, MatchWeights, Project, ScheduleTask, SearchConditions } from '../types'
import { RESULT_STATUSES } from '../types'
import { useStore, runSearch, conditionsText, uid, nowStr } from '../lib/store'
import { BEE_IMG } from '../lib/assets'
import { matchScore, timeDigest, keyRequirement } from '../lib/ai'
import { ScheduleTasks } from '../components/ScheduleTasks'
import { PrimaryButton, GhostButton } from '../components/ui-ext/AiButton'
import { cn } from '@/lib/utils'
const PAGE_SIZE = 8
const defaultConditions: SearchConditions = { keyword: '', region: '', budgetMin: '', budgetMax: '', publishRange: '30d' }
const inputCls =
'rounded-ctrl border border-line-soft bg-white px-3 py-2 text-sm text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10'
const WEIGHT_FIELDS = ['business', 'region', 'amount', 'track'] as const
/** 匹配度维度:名称固定,不开放自定义 */
const DIM_NAMES: Record<(typeof WEIGHT_FIELDS)[number], string> = {
business: '业务贴合',
region: '服务地区',
amount: '金额匹配',
track: '业绩与资质',
}
export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (s: AiPanelState) => void }) {
const { profile, saveProfile, addBatch, tasks, watch, findProject } = useStore()
const navigate = useNavigate()
const [conditions, setConditions] = useState<SearchConditions>(defaultConditions)
const [executed, setExecuted] = useState<SearchConditions | null>(null)
const [resultIds, setResultIds] = useState<string[] | null>(null)
const [showSchedule, setShowSchedule] = useState(false)
const [showWeights, setShowWeights] = useState(false)
const [weightDraft, setWeightDraft] = useState<MatchWeights>(profile.matchWeights)
const doSearch = () => {
const ids = runSearch(conditions)
// 档案已完善时,结果按匹配度由高到低排序
if (profile.completed) {
ids.sort((a, b) =>
(matchScore(findProject(b)!, profile)?.score ?? -1) - (matchScore(findProject(a)!, profile)?.score ?? -1))
}
const batch = { id: uid('batch'), conditions: { ...conditions }, executedAt: nowStr(), projectIds: ids, total: ids.length }
addBatch(batch)
setExecuted({ ...conditions })
setResultIds(ids)
}
const total = resultIds?.length ?? 0
const dirty = executed !== null && JSON.stringify(conditions) !== JSON.stringify(executed)
// 有执行记录的检索方案:结果用与手动检索一致的整表展示,多方案可切换
const ranTasks = useMemo(
() => tasks.filter(t => t.runs.length > 0)
.sort((a, b) => (b.runs[0]?.time ?? '').localeCompare(a.runs[0]?.time ?? '')),
[tasks],
)
const watchPreview = useMemo(
() => watch.map(w => findProject(w.projectId)).filter(Boolean).slice(0, 6) as Project[],
[watch, findProject],
)
// 顶部问候条:按时段问候 + 日期 + 临近报名截止的关注项目数
const hour = new Date().getHours()
const greeting = hour < 6 ? '夜深了' : hour < 9 ? '早上好' : hour < 12 ? '上午好' : hour < 14 ? '中午好' : hour < 18 ? '下午好' : '晚上好'
const today = new Date()
const dateStr = `${today.getMonth() + 1}月${today.getDate()}日 星期${'日一二三四五六'[today.getDay()]}`
const dueSoon = useMemo(() => {
const now = Date.now()
return watch.filter(w => {
const p = findProject(w.projectId)
if (!p?.regDeadline) return false
const t = new Date(p.regDeadline).getTime()
return t >= now && t - now <= 7 * 86400000
}).length
}, [watch, findProject])
// 问候条动态:不做数据罗列,直接给判断——优先提示各方案结果里的高匹配项目;
// 未配置方案时展示关注与结果进度
const insight = useMemo(() => {
const hits = ranTasks
.map(t => ({
name: t.name,
count: runSearch(t.conditions)
.filter(id => (matchScore(findProject(id)!, profile)?.score ?? 0) >= 90).length,
}))
.filter(h => h.count > 0)
if (hits.length > 0) {
return (
<>
{hits.map((h, i) => (
<span key={h.name}>{i > 0 && '、'}「{h.name}」有 <b className="font-num text-[#FDE68A]">{h.count}</b> 个</span>
))}
{' '}匹配度超过 90 分的项目,建议优先查看
</>
)
}
if (ranTasks.length > 0) {
return <>各检索方案暂无 90 分以上的高匹配项目,可在结果区切换标签查看明细</>
}
if (tasks.length > 0) {
return <>已保存 <b className="font-num text-[#FDE68A]">{tasks.length}</b> 个检索方案,执行后这里会提示高匹配项目</>
}
const resultCount = watch.filter(w => (RESULT_STATUSES as string[]).includes(w.status)).length
return (
<>
重点关注 <b className="font-num text-[#FDE68A]">{watch.length}</b> 个项目,
<b className="font-num text-[#FCA5A5]"> {dueSoon}</b> 个临近报名截止,
已有结果 <b className="font-num text-[#FDE68A]">{resultCount}</b> 个
</>
)
}, [ranTasks, tasks.length, watch, dueSoon, profile, findProject])
return (
<div className="mx-auto max-w-[1120px] px-4 py-4 sm:px-5 sm:py-5 xl:px-6">
{/* 档案已完善:顶部问候条(小巧思:GIF 小助手 + 一句话关键动态) */}
{profile.completed && (
<div className="relative overflow-hidden rounded-card p-6 shadow-card fade-up"
style={{ background: 'linear-gradient(115deg, #1D19DC 0%, #2E54E8 52%, #3F8BF0 100%)' }}>
{/* 装饰圆环与光斑,与品牌视觉一致 */}
<div className="pointer-events-none absolute -top-24 right-40 h-52 w-52 rounded-full border border-white/15" />
<div className="pointer-events-none absolute -top-12 right-52 h-28 w-28 rounded-full border border-white/10" />
<div className="pointer-events-none absolute -bottom-16 right-72 h-32 w-32 rounded-full bg-white/5" />
<div className="relative flex items-center gap-5">
<img src={BEE_IMG} alt="如昼小助手"
className="bee-float h-24 w-24 shrink-0 object-contain drop-shadow-[0_8px_16px_rgba(30,27,75,0.35)]" />
<div className="shrink-0">
<h2 className="text-[22px] font-bold tracking-wide text-white">
{greeting},{profile.companyName.replace(/(有限责任公司|有限公司)$/, '') || '朋友'}
</h2>
<p className="mt-1 text-xs tracking-[0.15em] text-[#BFDBFE]">{dateStr}</p>
</div>
<div className="mx-1 h-12 w-px shrink-0 bg-white/20" />
<div className="min-w-0">
<span className="mb-1.5 inline-flex items-center gap-1 rounded-full bg-white/15 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-[#DBEAFE]">
<Sparkles size={11} /> AI 洞察
</span>
<p className="text-[13.5px] leading-relaxed text-[#DBEAFE]">{insight}</p>
</div>
</div>
</div>
)}
{/* 公司档案:仅在未完善时展示引导栏;已完善则不再占位 */}
{!profile.completed && (
<div className="flex items-center gap-4 rounded-card border-brand-gradient bg-white p-5 shadow-card fade-up">
<div className="flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl"
style={{ background: 'linear-gradient(135deg, #6366F1 0%, #818CF8 100%)' }}>
<Building2 size={22} className="text-white" />
</div>
<div className="flex-1">
<h2 className="text-[15px] font-bold">让 AI 像投标专员一样帮你筛项目</h2>
<p className="mt-0.5 text-[13px] text-ink-400">
花 2 分钟填好资质、代表业绩和常做区域,之后每条项目都会自动给出贴合度打分和「先看哪条」的建议——不用再一条条读公告。
</p>
</div>
<PrimaryButton onClick={() => navigate('/profile')}>
立即完善档案 <ArrowRight size={14} />
</PrimaryButton>
</div>
)}
{/* 检索区 */}
<section className="mt-4 rounded-card border border-line-soft bg-white p-5 shadow-card">
<div className="mb-3 flex items-center gap-2">
<Search size={16} className="text-brand-500" />
<h2 className="text-[15px] font-bold">项目检索</h2>
<span className="flex-1" />
<GhostButton onClick={() => {
setWeightDraft({ ...profile.matchWeights })
setShowWeights(true)
}} className="!px-3 !py-1.5 text-xs">
<SlidersHorizontal size={14} /> 匹配度权重
</GhostButton>
<GhostButton onClick={() => setShowSchedule(true)} className="!px-3 !py-1.5 text-xs">
<Layers size={14} /> 检索方案
</GhostButton>
</div>
<div className="grid grid-cols-12 gap-2.5">
<input value={conditions.keyword} onChange={e => setConditions(c => ({ ...c, keyword: e.target.value }))}
onKeyDown={e => { if (e.key === 'Enter') doSearch() }}
placeholder="关键词(空格分隔多个,如:智慧水务 监测)"
className={cn(inputCls, 'col-span-4')} />
<input value={conditions.region} onChange={e => setConditions(c => ({ ...c, region: e.target.value }))}
onKeyDown={e => { if (e.key === 'Enter') doSearch() }}
placeholder="地区(如:浙江)"
className={cn(inputCls, 'col-span-2')} />
<div className="col-span-3 flex items-center gap-1.5">
<input type="number" min={0} value={conditions.budgetMin} onChange={e => setConditions(c => ({ ...c, budgetMin: e.target.value }))}
placeholder="预算下限" className={cn(inputCls, 'w-full font-num')} />
<span className="text-ink-400">~</span>
<input type="number" min={0} value={conditions.budgetMax} onChange={e => setConditions(c => ({ ...c, budgetMax: e.target.value }))}
placeholder="上限(万元)" className={cn(inputCls, 'w-full font-num')} />
</div>
<select value={conditions.publishRange} onChange={e => setConditions(c => ({ ...c, publishRange: e.target.value as SearchConditions['publishRange'] }))}
className={cn(inputCls, 'col-span-2')}>
<option value="7d">发布于近 7 天</option>
<option value="30d">发布于近 30 天</option>
<option value="90d">发布于近 90 天</option>
<option value="all">全部时间</option>
</select>
<PrimaryButton onClick={doSearch} className="col-span-1 !px-2">
<Search size={15} /> 检索
</PrimaryButton>
</div>
{dirty && (
<div className="mt-2 text-xs text-warn-500">
检索条件已修改但尚未重新执行,下方结果仍对应上一次执行的条件({conditionsText(executed!)})。
</div>
)}
</section>
{/* 检索方案:方案列表收进弹窗,不在首页占位 */}
<ScheduleTasks currentConditions={conditions} open={showSchedule} onClose={() => setShowSchedule(false)} />
{/* 结果区:设置了检索方案时,结果区以标签页呈现(当前检索 + 各方案结果),随时切换 */}
{ranTasks.length > 0 ? (
<TaskResultsSection tasks={ranTasks} currentConditions={conditions}
manual={resultIds !== null && executed !== null ? { ids: resultIds, executed } : null}
onOpenPanel={onOpenPanel} />
) : resultIds === null ? (
watchPreview.length > 0 ? (
<section className="mt-4 overflow-hidden rounded-card border border-line-soft bg-white shadow-card fade-up">
<div className="flex flex-wrap items-center gap-2 border-b border-line-soft px-5 py-3">
<Star size={15} className="text-brand-500" />
<h2 className="text-[15px] font-bold">你重点关注的项目</h2>
<span className="text-xs text-ink-400">共 <span className="font-num">{watch.length}</span> 条,展示前 <span className="font-num">{watchPreview.length}</span> 条</span>
<span className="flex-1" />
<span className="text-xs text-ink-400">在上方设置条件点击「检索」,发现更多商机</span>
</div>
<ul className="divide-y divide-line-soft/70">
{watchPreview.map(p => <ProjectPreviewRow key={p.id} p={p} onOpenPanel={onOpenPanel} />)}
</ul>
</section>
) : (
<section className="mt-4 flex flex-col items-center justify-center rounded-card border border-dashed border-line-soft bg-white py-16 shadow-card">
<div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-brand-50">
<Search size={24} className="text-brand-500" />
</div>
<p className="mt-4 text-sm font-medium text-ink-900">设置检索条件后点击「检索」</p>
<p className="mt-1 text-xs text-ink-400">结果按匹配度由高到低排列,点击任意一行查看 AI 分析</p>
</section>
)
) : total === 0 ? (
<section className="mt-4 flex flex-col items-center justify-center rounded-card border border-line-soft bg-white py-16 shadow-card">
<div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-[rgba(245,158,11,.1)]">
<Search size={24} className="text-warn-500" />
</div>
<p className="mt-4 text-sm font-medium text-ink-900">没有符合条件的项目</p>
<p className="mt-1 text-[13px] text-ink-400">可调整关键词、地区、预算或发布时间范围后重新检索(系统不会自动放宽你的条件)</p>
</section>
) : (
<>
<section className="mt-4 overflow-hidden rounded-card border border-line-soft bg-white shadow-card">
<div className="flex flex-wrap items-center gap-3 border-b border-line-soft px-5 py-3">
<h2 className="text-[15px] font-bold">全部结果</h2>
<span className="rounded-full bg-brand-50 px-2.5 py-0.5 text-xs font-num font-bold text-brand-500">共 {total} 条</span>
<span className="text-xs text-ink-400">
{conditionsText(executed!)}{profile.completed ? ' · 按匹配度由高到低排序' : ''}
</span>
</div>
{/* 与检索方案结果共用同一张结果表格 */}
<ResultTable key={resultIds.join(',')} ids={resultIds} onOpenPanel={onOpenPanel} />
</section>
</>
)}
{/* 匹配度权重配置 */}
<AnimatePresence>
{showWeights && (
<motion.div className="fixed inset-0 z-50 flex items-center justify-center bg-ink-900/20 backdrop-blur-sm"
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }}
onClick={e => { if (e.target === e.currentTarget) setShowWeights(false) }}>
<motion.div className="w-[400px] max-w-[92vw] rounded-card border border-line-soft bg-white p-5 shadow-card-hover"
initial={{ scale: 0.96, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.96, opacity: 0 }} transition={{ duration: 0.18 }}>
<div className="flex items-center justify-between">
<h3 className="text-[16px] font-bold">匹配度权重</h3>
<button onClick={() => setShowWeights(false)} className="rounded-full p-1.5 text-ink-400 hover:bg-[#F4F7FB]"><X size={16} /></button>
</div>
<p className="mt-1 text-[13px] text-ink-400">拖动滑块调整各维度权重;合计不为 100 时按比例折算。</p>
<div className="mt-3 space-y-2.5">
{WEIGHT_FIELDS.map(k => (
<div key={k} className="flex items-center gap-3">
<span className="w-20 shrink-0 text-[13px] font-medium text-ink-900">{DIM_NAMES[k]}</span>
<input type="range" min={0} max={100} step={5} value={weightDraft[k]}
onChange={e => setWeightDraft(d => ({ ...d, [k]: Number(e.target.value) }))}
className="flex-1 accent-brand-500" />
<span className="w-12 text-right font-num text-[13px] text-ink-900">{weightDraft[k]}%</span>
</div>
))}
</div>
{(() => {
const sum = weightDraft.business + weightDraft.region + weightDraft.amount + weightDraft.track
return sum !== 100 ? (
<p className="mt-2 text-xs text-warn-500">当前合计 <span className="font-num">{sum}</span>%,保存后按比例折算为 100% 参与计分</p>
) : null
})()}
<div className="mt-4 flex justify-end gap-2">
<GhostButton onClick={() => setShowWeights(false)}>取消</GhostButton>
<PrimaryButton onClick={() => {
saveProfile({ ...profile, matchWeights: weightDraft, matchDimNames: { ...DIM_NAMES } })
setShowWeights(false)
}}>保存权重</PrimaryButton>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
</div>
)
}
/** 结果表格:手动检索与检索方案结果共用(含匹配度悬停说明与分页) */
function ResultTable({ ids, onOpenPanel }: { ids: string[]; onOpenPanel: (s: AiPanelState) => void }) {
const { profile, findProject, addWatch, isWatched, watch, customTags, addCustomTag, toggleWatchTag } = useStore()
const [page, setPage] = useState(1)
// 关注后就地打标签的小弹窗:不用切到「重点关注」页再补标签
const [tagPickerFor, setTagPickerFor] = useState<string | null>(null)
const [newTag, setNewTag] = useState('')
const submitNewTag = (pid: string) => {
const t = newTag.trim()
if (!t) return
addCustomTag(t)
const w = watch.find(x => x.projectId === pid)
if (!w?.tags.includes(t)) toggleWatchTag(pid, t)
setNewTag('')
}
const total = ids.length
const pageCount = Math.max(1, Math.ceil(total / PAGE_SIZE))
const safePage = Math.min(page, pageCount)
const pageIds = useMemo(() => ids.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE), [ids, safePage])
return (
<>
<div>
<table className="w-full text-[13px]">
<thead>
<tr className="border-b border-line-soft bg-[#FAFBFD] text-left text-ink-400">
<th className="w-[30%] px-5 py-2.5 font-medium">项目名称</th>
<th className="px-3 py-2.5 font-medium">招标方</th>
<th className="px-3 py-2.5 font-medium">预算</th>
<th className="px-3 py-2.5 font-medium">时间节奏</th>
<th className="px-3 py-2.5 font-medium">参与门槛</th>
<th className="px-3 py-2.5 font-medium">匹配度</th>
<th className="px-3 py-2.5 font-medium">操作</th>
</tr>
</thead>
<tbody>
{pageIds.map((id, rowIdx) => {
const p = findProject(id)!
const m = matchScore(p, profile)
const t = timeDigest(p)
const k = keyRequirement(p)
const toneCls = { urgent: 'text-bad-500', warn: 'text-warn-500', ok: 'text-ok-500', muted: 'text-ink-400' }[t.tone]
const dotCls = { urgent: 'bg-bad-500', warn: 'bg-warn-500', ok: 'bg-ok-500', muted: 'bg-ink-400' }[t.tone]
const kTone = {
block: 'bg-bad-500/10 text-bad-500',
note: 'bg-[rgba(245,158,11,.1)] text-warn-500',
ok: 'bg-ok-500/10 text-ok-500',
}[k.tone]
return (
<tr key={p.id}
onClick={() => onOpenPanel({ kind: 'project', projectId: p.id })}
title="点击查看该项目的 AI 深入分析"
className="cursor-pointer border-b border-line-soft/70 transition-colors last:border-0 hover:bg-brand-50/40">
<td className="px-5 py-3">
{/* 项目名称直达招标源网页(新标签页打开,保留检索进度) */}
<a href={p.sourceUrl ?? undefined} target="_blank" rel="noreferrer" onClick={e => e.stopPropagation()}
className="inline-flex items-start gap-1 font-medium text-ink-900 hover:text-brand-500 hover:underline">
<span>{p.name}</span><ExternalLink size={12} className="mt-1 shrink-0 text-ink-400" />
</a>
<div className="mt-1 flex flex-wrap gap-1">
{p.keywords.slice(0, 2).map(kw => (
<span key={kw} className="rounded-full bg-[#F4F7FB] px-2 py-px text-[11px] text-ink-600">{kw}</span>
))}
</div>
</td>
<td className="px-3 py-3">
<div className="max-w-[150px] leading-snug text-ink-900">{p.purchaser}</div>
<div className="mt-0.5 text-xs text-ink-400">{p.region}</div>
</td>
<td className="whitespace-nowrap px-3 py-3">
{p.budget === null
? <span className="text-ink-400">未披露</span>
: <span className="font-num font-bold text-ink-900">{p.budget.toLocaleString()}<span className="text-xs font-medium text-ink-400"> 万元</span></span>}
</td>
<td className="whitespace-nowrap px-3 py-3" title={t.hint}>
<div className={`flex items-center gap-1.5 font-medium ${toneCls}`}>
<span className={`h-1.5 w-1.5 rounded-full ${dotCls}`} />
{t.label}
</div>
<div className="mt-0.5 font-num text-xs text-ink-400">{t.sub}</div>
</td>
<td className="whitespace-nowrap px-3 py-3">
<span className={cn('rounded-full px-2.5 py-0.5 text-xs font-medium', kTone)} title={p.requirements.join(';')}>
{k.label}
</span>
</td>
<td className="relative whitespace-nowrap px-3 py-3">
{m ? (
<div className="group inline-block cursor-help">
<span className="font-num text-[15px] font-bold text-brand-500">
{m.score}<span className="text-xs font-medium text-ink-400"> 分</span>
</span>
{/* 悬停展示打分维度与权重;完整报告在该行的「AI 分析」中 */}
<div className={cn(
'invisible absolute right-0 z-30 w-72 whitespace-normal break-words rounded-card border border-line-soft bg-white p-3 text-left opacity-0 shadow-card-hover transition-opacity group-hover:visible group-hover:opacity-100',
rowIdx >= pageIds.length - 3 ? 'bottom-full mb-1' : 'top-full mt-1',
)}>
<div className="text-xs font-medium leading-relaxed text-ink-900">贴合度打分构成 <span className="font-normal text-ink-400">(辅助参考,不参与筛选排序)</span></div>
<ul className="mt-1.5 space-y-1.5">
{m.dims.map(d => (
<li key={d.name}>
<div className="flex items-baseline gap-2 text-[12px]">
<span className="shrink-0 text-ink-600">{d.name}</span>
<span className="shrink-0 text-ink-400">权重 <span className="font-num">{d.weight}%</span></span>
<span className="flex-1" />
<span className="font-num font-medium text-ink-900">{d.score} 分</span>
</div>
<div className="mt-0.5 text-[11px] leading-snug text-ink-400">{d.note}</div>
</li>
))}
</ul>
<div className="mt-2 border-t border-line-soft pt-1.5 text-[11px] text-ink-400">点击本行「AI 分析」查看完整打分报告</div>
</div>
</div>
) : (
<span className="text-ink-400" title="完善公司档案后生成,不作为筛选或排序依据">—</span>
)}
</td>
<td className="relative whitespace-nowrap px-3 py-3">
<div className="flex items-center gap-1.5">
<button onClick={e => { e.stopPropagation(); onOpenPanel({ kind: 'project', projectId: p.id }) }}
className="inline-flex items-center gap-1 rounded-full border-brand-gradient px-2.5 py-1 text-[12px] font-medium shadow-card transition-shadow hover:shadow-card-hover">
<Sparkles size={12} className="text-brand-500" />
<span className="text-brand-gradient">AI 分析</span>
</button>
<button onClick={e => {
e.stopPropagation()
if (!isWatched(p.id)) addWatch(p.id)
setTagPickerFor(tagPickerFor === p.id ? null : p.id)
setNewTag('')
}}
title={isWatched(p.id) ? '已在重点关注中,点击管理标签' : '加入重点关注并打标签'}
className="rounded-full p-1.5 text-brand-500 transition-colors hover:bg-brand-50">
<Star size={15} fill={isWatched(p.id) ? 'currentColor' : 'none'} />
</button>
</div>
{/* 关注后的标签弹窗:选择已有标签或新建,不用切页 */}
{tagPickerFor === p.id && (
<>
<div className="fixed inset-0 z-20 cursor-default" onClick={e => { e.stopPropagation(); setTagPickerFor(null) }} />
<div onClick={e => e.stopPropagation()}
className={cn('absolute right-0 z-30 w-60 whitespace-normal rounded-card border border-line-soft bg-white p-3 text-left shadow-card-hover',
rowIdx >= pageIds.length - 2 ? 'bottom-full mb-1' : 'top-full mt-1')}>
<div className="text-xs font-medium text-ink-900">给这个项目打个标签</div>
{customTags.length > 0 && (
<div className="mt-2 flex flex-wrap gap-1.5">
{customTags.map(tag => {
const on = watch.find(x => x.projectId === p.id)?.tags.includes(tag) ?? false
return (
<button key={tag} onClick={() => toggleWatchTag(p.id, tag)}
className={cn('rounded-full border px-2.5 py-1 text-[12px] transition-colors',
on ? 'border-brand-500 bg-brand-50 text-brand-500' : 'border-line-soft text-ink-600 hover:border-brand-500/40 hover:text-brand-500')}>
{tag}
</button>
)
})}
</div>
)}
<div className="mt-2 flex gap-1.5">
<input value={newTag} onChange={e => setNewTag(e.target.value)}
onKeyDown={e => { if (e.key === 'Enter') submitNewTag(p.id) }}
placeholder="新建标签,回车添加"
className="w-full rounded-ctrl border border-line-soft px-2.5 py-1.5 text-[12px] outline-none placeholder:text-ink-400 focus:border-brand-500/60" />
<button onClick={() => submitNewTag(p.id)} disabled={!newTag.trim()}
className="shrink-0 rounded-ctrl bg-brand-500 px-2.5 text-[12px] text-white disabled:opacity-40">添加</button>
</div>
<button onClick={() => setTagPickerFor(null)}
className="mt-2 w-full rounded-ctrl border border-line-soft py-1 text-[12px] text-ink-600 transition-colors hover:border-brand-500/40 hover:text-brand-500">
完成
</button>
</div>
</>
)}
</td>
</tr>
)
})}
</tbody>
</table>
</div>
{/* 分页:说明当前展示范围,不把当前页当作全部 */}
<div className="flex items-center gap-3 px-5 py-3 text-[13px] text-ink-400">
<span>第 <span className="font-num text-ink-900">{(safePage - 1) * PAGE_SIZE + 1}–{Math.min(safePage * PAGE_SIZE, total)}</span> 条,共 <span className="font-num text-ink-900">{total}</span> 条</span>
<span className="flex-1" />
<GhostButton onClick={() => setPage(p => Math.max(1, p - 1))} disabled={safePage <= 1} className="!px-2.5 !py-1 text-xs">
<ChevronLeft size={14} /> 上一页
</GhostButton>
<span className="font-num">第 {safePage} / {pageCount} 页</span>
<GhostButton onClick={() => setPage(p => Math.min(pageCount, p + 1))} disabled={safePage >= pageCount} className="!px-2.5 !py-1 text-xs">
下一页 <ChevronRight size={14} />
</GhostButton>
</div>
</>
)
}
/** 结果区(有检索方案时):标签页切换「当前检索」与各方案结果,全部共用同一张结果表格 */
function TaskResultsSection({ tasks, currentConditions, manual, onOpenPanel }: {
tasks: ScheduleTask[]
currentConditions: SearchConditions
/** 手动检索的结果(未执行过手动检索时为 null,当前检索标签页展示实时结果) */
manual: { ids: string[]; executed: SearchConditions } | null
onOpenPanel: (s: AiPanelState) => void
}) {
const { profile, findProject } = useStore()
const [activeId, setActiveId] = useState<string>(manual ? 'current' : (tasks[0]?.id ?? 'current'))
// 每次手动检索执行后,自动切到「当前检索」标签页
const prevManual = useRef(manual)
useEffect(() => {
if (manual && manual !== prevManual.current) setActiveId('current')
prevManual.current = manual
}, [manual])
const isCurrent = activeId === 'current'
const active = tasks.find(t => t.id === activeId) ?? null
const ids = useMemo(() => {
const conds = isCurrent ? (manual?.executed ?? currentConditions) : active?.conditions
if (!conds) return [] as string[]
// 手动检索结果已按同一口径排序,直接复用;其余实时计算
if (isCurrent && manual) return manual.ids
const list = runSearch(conds)
if (profile.completed) {
list.sort((a, b) =>
(matchScore(findProject(b)!, profile)?.score ?? -1) - (matchScore(findProject(a)!, profile)?.score ?? -1))
}
return list
}, [isCurrent, manual, currentConditions, active, profile, findProject])
if (!active && !isCurrent) return null
const last = active?.runs[0]
const activeConds = isCurrent ? (manual?.executed ?? currentConditions) : active!.conditions
return (
<section className="mt-4 overflow-hidden rounded-card border border-line-soft bg-white shadow-card fade-up">
<div className="flex flex-wrap items-center gap-2 border-b border-line-soft px-5 py-3">
<Layers size={15} className="text-brand-500" />
<h2 className="text-[15px] font-bold">检索结果</h2>
<div className="ml-1 flex gap-0.5 rounded-full bg-[#F4F7FB] p-0.5">
<button onClick={() => setActiveId('current')}
className={cn('rounded-full px-3 py-1 text-xs transition-colors',
isCurrent ? 'bg-white font-medium text-brand-500 shadow-card' : 'text-ink-600 hover:text-brand-500')}>
当前结果
</button>
{tasks.map(t => (
<button key={t.id} onClick={() => setActiveId(t.id)}
className={cn('rounded-full px-3 py-1 text-xs transition-colors',
t.id === activeId ? 'bg-white font-medium text-brand-500 shadow-card' : 'text-ink-600 hover:text-brand-500')}>
{t.name}结果
</button>
))}
</div>
<span className="flex-1" />
</div>
<div className="flex flex-wrap items-center gap-2 border-b border-line-soft px-5 py-2 text-xs text-ink-400">
<span>{conditionsText(activeConds)}</span>
<span>·</span>
{isCurrent ? (
<span>{manual ? '手动检索' : '实时计算'}</span>
) : (
<span>最近执行 <span className="font-num">{last?.time}</span></span>
)}
<span>·</span>
<span>共 <span className="font-num text-ink-900">{ids.length}</span> 条{profile.completed ? ',按匹配度由高到低排序' : ''}</span>
</div>
{ids.length === 0 ? (
<div className="flex flex-col items-center justify-center py-14">
<div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-[rgba(245,158,11,.1)]">
<Search size={20} className="text-warn-500" />
</div>
<p className="mt-3 text-sm font-medium text-ink-900">这组条件下没有符合条件的项目</p>
<p className="mt-1 text-[13px] text-ink-400">可在上方调整关键词、地区、预算或发布时间范围后重新检索</p>
</div>
) : (
<ResultTable key={`${activeId}|${ids.join(',')}`} ids={ids} onOpenPanel={onOpenPanel} />
)}
</section>
)
}
/** 空态填充用的紧凑项目行:名称直达公告源网页,右侧直接给时间判断与 AI 分析入口 */
function ProjectPreviewRow({ p, onOpenPanel }: { p: Project; onOpenPanel: (s: AiPanelState) => void }) {
const t = timeDigest(p)
const toneCls = { urgent: 'text-bad-500', warn: 'text-warn-500', ok: 'text-ok-500', muted: 'text-ink-400' }[t.tone]
return (
<li className="flex items-center gap-3 px-5 py-3 transition-colors hover:bg-brand-50/40">
<div className="min-w-0 flex-1">
<a href={p.sourceUrl ?? undefined} target="_blank" rel="noreferrer"
className="inline-flex max-w-full items-center gap-1 text-[13px] font-medium text-ink-900 hover:text-brand-500 hover:underline">
<span className="truncate">{p.name}</span><ExternalLink size={11} className="shrink-0 text-ink-400" />
</a>
<div className="mt-0.5 truncate text-xs text-ink-400">
{p.purchaser} · {p.region} · {p.budget === null ? '预算未披露' : <span className="font-num">{p.budget.toLocaleString()} 万元</span>}
</div>
</div>
<span className={cn('shrink-0 text-xs font-medium', toneCls)} title={t.hint}>{t.label}</span>
<button onClick={() => onOpenPanel({ kind: 'project', projectId: p.id })}
className="inline-flex shrink-0 items-center gap-1 rounded-full border-brand-gradient px-2.5 py-1 text-[12px] font-medium shadow-card transition-shadow hover:shadow-card-hover">
<Sparkles size={12} className="text-brand-500" /><span className="text-brand-gradient">AI 分析</span>
</button>
</li>
)
}
import { useState } from 'react'
import { useNavigate } from 'react-router'
import { Compass, Sparkles, Bell, User, Lock, ArrowRight } from 'lucide-react'
import { PrimaryButton } from '../components/ui-ext/AiButton'
import { BEE_IMG } from '../lib/assets'
/** 登录页:演示环境任意账号密码可登录;登录态记录在本地 */
export function LoginPage({ onLogin }: { onLogin: () => void }) {
const navigate = useNavigate()
const [account, setAccount] = useState('')
const [password, setPassword] = useState('')
const [error, setError] = useState('')
const submit = () => {
if (!account.trim()) { setError('请输入账号'); return }
if (!password.trim()) { setError('请输入密码'); return }
onLogin()
navigate('/', { replace: true })
}
return (
<div className="relative flex h-[100dvh] items-center justify-center overflow-hidden"
style={{ background: 'linear-gradient(135deg, #EFF6FF 0%, #F0FDFA 45%, #F8FAFF 100%)' }}>
{/* 背景装饰:柔和光斑 */}
<div className="pointer-events-none absolute -left-32 -top-32 h-96 w-96 rounded-full opacity-40 blur-3xl"
style={{ background: 'radial-gradient(circle, #C7D2FE 0%, transparent 70%)' }} />
<div className="pointer-events-none absolute -bottom-40 -right-24 h-[28rem] w-[28rem] rounded-full opacity-40 blur-3xl"
style={{ background: 'radial-gradient(circle, #A5B4FC 0%, transparent 70%)' }} />
<div className="fade-up relative z-10 flex w-[860px] max-w-[94vw] overflow-hidden rounded-card border border-white/60 bg-white/80 shadow-card-hover backdrop-blur">
{/* 左侧品牌区 */}
<div className="relative hidden w-[45%] flex-col justify-between p-8 sm:flex"
style={{ background: 'linear-gradient(160deg, #6366F1 0%, #4F46E5 100%)' }}>
<div>
<div className="text-[20px] font-bold text-white">如昼商机助手</div>
<div className="mt-1 text-[13px] text-white/70">水行业招投标商机平台</div>
</div>
<div className="flex justify-center py-4">
<img src={BEE_IMG} alt="如昼小蜜蜂" className="bee-float h-44 w-44 object-contain drop-shadow-xl" />
</div>
<ul className="space-y-2.5 text-[13px] text-white/85">
<li className="flex items-center gap-2">
<Compass size={14} className="shrink-0 text-white/70" /> AI 整理招标信息,报名节奏一眼看清
</li>
<li className="flex items-center gap-2">
<Sparkles size={14} className="shrink-0 text-white/70" /> 结合公司档案打分,先看哪条直接给结论
</li>
<li className="flex items-center gap-2">
<Bell size={14} className="shrink-0 text-white/70" /> 检索方案一键复用,重点商机不再错过
</li>
</ul>
</div>
{/* 右侧登录表单 */}
<div className="flex-1 p-8 sm:p-10">
<h1 className="text-[20px] font-bold text-ink-900">欢迎回来</h1>
<p className="mt-1 text-[13px] text-ink-400">登录后继续查看今日商机</p>
<div className="mt-7 space-y-4">
<div>
<label className="text-[13px] font-medium text-ink-900">账号</label>
<div className="relative mt-1.5">
<User size={15} className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-400" />
<input value={account} onChange={e => { setAccount(e.target.value); setError('') }}
onKeyDown={e => { if (e.key === 'Enter') submit() }}
placeholder="请输入手机号或邮箱"
className="w-full rounded-ctrl border border-line-soft bg-white py-2.5 pl-9 pr-3 text-sm text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
</div>
<div>
<label className="text-[13px] font-medium text-ink-900">密码</label>
<div className="relative mt-1.5">
<Lock size={15} className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-400" />
<input type="password" value={password} onChange={e => { setPassword(e.target.value); setError('') }}
onKeyDown={e => { if (e.key === 'Enter') submit() }}
placeholder="请输入密码"
className="w-full rounded-ctrl border border-line-soft bg-white py-2.5 pl-9 pr-3 text-sm text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
</div>
{error && <div className="text-xs text-bad-500">{error}</div>}
<PrimaryButton onClick={submit} className="w-full !py-2.5 text-sm">
登 录 <ArrowRight size={15} />
</PrimaryButton>
</div>
<div className="mt-6 text-center text-xs text-ink-400">
演示环境:输入任意账号密码即可登录
</div>
</div>
</div>
</div>
)
}
import { useRef, useState } from 'react'
import { Building2, Save, Upload, Sparkles } from 'lucide-react'
import type { CompanyProfile } from '../types'
import { useStore } from '../lib/store'
import Pill from '../components/ui-ext/Pill'
import { PrimaryButton, GhostButton } from '../components/ui-ext/AiButton'
import { cn } from '@/lib/utils'
interface FieldDef {
key: keyof CompanyProfile
label: string
placeholder: string
textarea?: boolean
}
const GROUPS: { title: string; desc: string; fields: FieldDef[] }[] = [
{
title: '企业基本情况', desc: '明确研究主体和企业背景',
fields: [
{ key: 'companyName', label: '企业名称', placeholder: '请输入完整企业名称' },
{ key: 'intro', label: '企业简介', placeholder: '简要介绍公司背景、规模与发展阶段', textarea: true },
],
},
{
title: '业务与产品', desc: '帮助 AI 理解公司具体能做什么',
fields: [
{ key: 'mainBusiness', label: '主营业务', placeholder: '如:智慧水务平台建设、水质监测设备' },
{ key: 'products', label: '产品与服务', placeholder: '如:DMA 分区计量系统、管网漏损分析平台', textarea: true },
{ key: 'advantages', label: '核心优势', placeholder: '如:自研漏损算法、本地化交付团队', textarea: true },
],
},
{
title: '目标市场', desc: '用于提供贴合公司的建议,不会自动限制检索范围',
fields: [
{ key: 'serviceRegions', label: '服务地区', placeholder: '如:浙江、江苏、上海;或 全国' },
{ key: 'customerTypes', label: '客户类型', placeholder: '如:水务集团、住建局、园区管委会' },
{ key: 'projectTypes', label: '项目类型偏好', placeholder: '如:软件平台、监测设备、运营服务' },
{ key: 'amountPreference', label: '金额偏好', placeholder: '如:100-2000 万元' },
],
},
{
title: '资质与认证', desc: '对照公告参与条件;没有的可填「暂无」,资料缺失与确实不具备应区分',
fields: [
{ key: 'qualifications', label: '资质与认证', placeholder: '如:电子与智能化工程专业承包二级(有效期至 2028-06);软件著作权 6 项', textarea: true },
],
},
{
title: '代表业绩', desc: '对照公告同类业绩与实施经验要求',
fields: [
{ key: 'trackRecord', label: '代表业绩', placeholder: '如:2025 年某市供水管网漏损治理项目(540 万元,已通过验收)', textarea: true },
],
},
{
title: '交付能力', desc: '解释实施和履约条件',
fields: [
{ key: 'delivery', label: '交付与售后', placeholder: '如:自有实施团队 12 人,支持驻场;提供 7×24 响应', textarea: true },
],
},
{
title: '投标准备', desc: '用于提醒时间是否紧张',
fields: [
{ key: 'bidPreparation', label: '典型准备周期与限制', placeholder: '如:常规标书准备约 7 天,涉及现场勘察需 10 天以上' },
],
},
{
title: '参与边界', desc: '明确不参与或需谨慎的项目类型',
fields: [
{ key: 'boundaries', label: '参与边界', placeholder: '如:不参与需要垫资的工程施工总承包项目', textarea: true },
],
},
]
// 最低填写要求(演示口径):企业名称 + 主营业务
function meetsMinimum(p: CompanyProfile): boolean {
return p.companyName.trim() !== '' && p.mainBusiness.trim() !== ''
}
// 演示环境的 AI 导入抽取:基于关键词的启发式匹配,正式接入后由 AI 模型从文件中抽取
function extractProfileFromText(text: string): Partial<CompanyProfile> {
const lines = text.split(/\r?\n/).map(l => l.trim()).filter(Boolean)
const pick = (re: RegExp) => {
const line = lines.find(l => re.test(l))
return line ? line.replace(/^[-*•\d.、\s]+/, '').slice(0, 300) : undefined
}
const out: Partial<CompanyProfile> = {}
const put = (key: keyof CompanyProfile, v?: string) => { if (v) (out as Record<string, string>)[key] = v }
put('companyName', pick(/有限公司|股份公司|集团/))
put('intro', pick(/简介|成立于|是一家/))
put('mainBusiness', pick(/主营|主营业务|专注于|从事/))
put('products', pick(/产品|服务包括|解决方案/))
put('advantages', pick(/优势|擅长|自研/))
put('serviceRegions', pick(/地区|区域|覆盖|浙江|江苏|上海|安徽|华东|全国/))
put('customerTypes', pick(/客户/))
put('projectTypes', pick(/项目类型|偏好/))
put('amountPreference', pick(/\d+\s*[-~至]\s*\d+\s*万/))
put('qualifications', pick(/资质|认证|证书|软著|专利/))
put('trackRecord', pick(/业绩|案例|验收|中标/))
put('delivery', pick(/交付|售后|驻场|响应/))
put('bidPreparation', pick(/标书|准备周期|投标准备/))
put('boundaries', pick(/不参与|边界|谨慎/))
return out
}
const FIELD_LABELS: Record<string, string> = Object.fromEntries(
GROUPS.flatMap(g => g.fields.map(f => [f.key, f.label])),
)
const inputCls =
'rounded-ctrl border border-line-soft bg-white px-3 py-2 text-[13px] text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10'
export function ProfilePage() {
const { profile, saveProfile } = useStore()
const [form, setForm] = useState<CompanyProfile>({ ...profile })
const [savedTip, setSavedTip] = useState<string | null>(null)
const fileRef = useRef<HTMLInputElement>(null)
const [imported, setImported] = useState<Partial<CompanyProfile> | null>(null)
const [importError, setImportError] = useState('')
const set = (key: keyof CompanyProfile, value: string) => {
setForm(f => ({ ...f, [key]: value }))
setSavedTip(null)
}
const onImportFile = async (e: React.ChangeEvent<HTMLInputElement>) => {
const f = e.target.files?.[0]
e.target.value = ''
if (!f) return
const text = await f.text()
const extracted = extractProfileFromText(text)
if (Object.keys(extracted).length === 0) {
setImportError('没有从文件中识别到可填入的内容,可换一份更完整的介绍文件再试。')
setImported(null)
return
}
setImportError('')
setImported(extracted)
}
const applyImport = () => {
if (!imported) return
setForm(f => ({ ...f, ...imported }))
setImported(null)
setSavedTip(null)
}
const save = () => {
const completed = meetsMinimum(form)
saveProfile({ ...form, completed })
setForm(f => ({ ...f, completed }))
setSavedTip(completed
? '档案已保存并标记为「已完善」,项目分析将结合公司情况给出有依据的建议。'
: '已保存,但尚未达到「已完善」的最低要求(需填写企业名称与主营业务),匹配度暂不生成。')
}
return (
<div className="mx-auto max-w-[860px] px-4 py-4 sm:px-5 sm:py-5 xl:px-6">
<div className="flex flex-wrap items-center gap-3">
<Building2 size={18} className="text-brand-500" />
<h1 className="text-[17px] font-bold">公司档案</h1>
<Pill status={profile.completed ? '已完善' : '未完善'} />
{profile.completed && (
<span className="text-xs text-ink-400">v<span className="font-num">{profile.version}</span> · 更新于 <span className="font-num">{profile.updatedAt}</span></span>
)}
<span className="flex-1" />
<input ref={fileRef} type="file" accept=".txt,.md,.text,.markdown" className="hidden" onChange={onImportFile} />
<GhostButton onClick={() => fileRef.current?.click()}>
<Upload size={14} /> AI 导入
</GhostButton>
<PrimaryButton onClick={save}>
<Save size={14} /> 保存档案
</PrimaryButton>
</div>
{importError && (
<div className="mt-3 rounded-ctrl border border-warn-500/30 bg-warn-500/5 px-3.5 py-2.5 text-[13px] text-warn-500 fade-up">
{importError}
</div>
)}
{imported && (
<section className="mt-3 rounded-card border-brand-gradient bg-white p-4 shadow-card fade-up">
<div className="flex items-center gap-2">
<Sparkles size={14} className="shrink-0 text-brand-500" />
<span className="text-[13px] font-medium text-brand-500">AI 已从文件抽取以下内容</span>
<span className="text-xs text-ink-400">请核对后写入,写入前不会改动当前表单</span>
</div>
<ul className="mt-2.5 space-y-1.5">
{Object.entries(imported).map(([k, v]) => (
<li key={k} className="text-[13px]">
<span className="text-ink-400">{FIELD_LABELS[k] ?? k}:</span>
<span className="text-ink-900">{String(v)}</span>
</li>
))}
</ul>
<div className="mt-3 flex justify-end gap-2">
<GhostButton onClick={() => setImported(null)} className="!px-3 !py-1.5 text-xs">放弃</GhostButton>
<PrimaryButton onClick={applyImport} className="!px-3 !py-1.5 text-xs">核对无误,写入表单</PrimaryButton>
</div>
</section>
)}
{savedTip && (
<div className={cn('mt-3 rounded-ctrl border px-3.5 py-2.5 text-[13px] fade-up',
form.completed ? 'border-ok-500/30 bg-ok-500/5 text-ok-500' : 'border-warn-500/30 bg-warn-500/5 text-warn-500')}>
{savedTip}
</div>
)}
<div className="mt-4 space-y-4">
{GROUPS.map(g => (
<section key={g.title} className="rounded-card border border-line-soft bg-white p-5 shadow-card">
<div className="flex items-baseline gap-2">
<h2 className="text-[14px] font-semibold text-ink-900">{g.title}</h2>
<p className="text-xs text-ink-400">{g.desc}</p>
</div>
<div className="mt-3 space-y-3">
{g.fields.map(f => (
<div key={f.key}>
<label className="text-[13px] font-medium text-ink-900">
{f.label}
{(f.key === 'companyName' || f.key === 'mainBusiness') && (
<span className="ml-1 text-xs font-normal text-warn-500">(最低必填)</span>
)}
</label>
{f.textarea ? (
<textarea rows={2} value={form[f.key] as string} onChange={e => set(f.key, e.target.value)} placeholder={f.placeholder}
className={cn(inputCls, 'mt-1 w-full resize-y scrollbar-thin')} />
) : (
<input value={form[f.key] as string} onChange={e => set(f.key, e.target.value)} placeholder={f.placeholder}
className={cn(inputCls, 'mt-1 w-full')} />
)}
</div>
))}
</div>
</section>
))}
</div>
<div className="mb-8 mt-4" />
</div>
)
}
import { useEffect, useRef, useState } from 'react'
import { useSearchParams } from 'react-router'
import {
MessagesSquare, UserSearch, GitCompareArrows, Map, Send,
X, Check, Loader2, CircuitBoard,
} from 'lucide-react'
import type { ChatMessage, ResearchConversation } from '../types'
import { useStore, uid, nowStr } from '../lib/store'
import { researchAnswer } from '../lib/ai'
import { Markdown } from '../components/Markdown'
import { useStreaming, runSkillTrace } from '../hooks/useStreaming'
import { PrimaryButton } from '../components/ui-ext/AiButton'
type Entry = 'customer' | 'competitor' | 'market' | null
const ENTRIES = [
{ key: 'customer' as Entry, icon: UserSearch, title: '查目标客户', desc: '这家公司做什么,采购过什么?', placeholder: '输入完整企业名称,如:某某水务集团有限公司' },
{ key: 'competitor' as Entry, icon: GitCompareArrows, title: '查竞争对手', desc: '这家公司的业务和客户情况怎样?', placeholder: '输入竞争对手的完整名称,可补充关注业务' },
{ key: 'market' as Entry, icon: Map, title: '查区域市场', desc: '某地区智慧水务需求如何?', placeholder: '如:调研华东地区近一年的智慧水务市场' },
]
interface LocalMsg extends ChatMessage {
streaming?: boolean
pendingTrace?: boolean
}
export function ResearchPage() {
const { research, saveConversation } = useStore()
const [convId, setConvId] = useState<string | null>(null)
const [messages, setMessages] = useState<LocalMsg[]>([])
const [title, setTitle] = useState('')
const [entry, setEntry] = useState<Entry>(null)
const [input, setInput] = useState('')
const [busy, setBusy] = useState(false)
const scrollRef = useRef<HTMLDivElement>(null)
const traceCancelRef = useRef<(() => void) | null>(null)
// 新对话的 convId 在流式输出完成后才入库;入库前先记入待持久化集合,避免被“对话已删除”守卫误清
const pendingConvRef = useRef<Set<string>>(new Set())
const { stream, stop } = useStreaming()
const [searchParams, setSearchParams] = useSearchParams()
useEffect(() => {
scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: 'smooth' })
}, [messages])
useEffect(() => () => { stop(); traceCancelRef.current?.() }, [stop])
const messagesRef = useRef<LocalMsg[]>([])
useEffect(() => { messagesRef.current = messages }, [messages])
const persist = (msgs: LocalMsg[], t: string, id: string | null): string => {
const cid = id ?? uid('conv')
const existing = research.find(c => c.id === cid)
const conv: ResearchConversation = {
id: cid,
title: t || existing?.title || '未命名调研',
createdAt: existing?.createdAt ?? nowStr(),
messages: msgs.map(({ streaming: _s, pendingTrace: _p, ...m }) => m),
}
saveConversation(conv)
return cid
}
const ask = (raw: string) => {
const q = raw.trim()
if (!q || busy) return
setBusy(true)
setInput('')
const userMsg: LocalMsg = { role: 'user', content: q, time: nowStr() }
const result = researchAnswer(q, entry)
const assistantMsg: LocalMsg = {
role: 'assistant', content: '', time: nowStr(),
skillTrace: [], pendingTrace: true,
}
setMessages([...messages, userMsg, assistantMsg])
const newTitle = title || result.title
if (!title) setTitle(newTitle)
const cid = convId ?? uid('conv')
if (!convId) setConvId(cid)
pendingConvRef.current.add(cid)
// 展示实际发生的 Skill 调用进展,再输出结果
traceCancelRef.current?.()
traceCancelRef.current = runSkillTrace(result.skillTrace, doneSteps => {
setMessages(m => {
const arr = [...m]
arr[arr.length - 1] = { ...arr[arr.length - 1], skillTrace: doneSteps, pendingTrace: true }
return arr
})
}, () => {
stream(result.markdown, (partial, done) => {
setMessages(m => {
const arr = [...m]
arr[arr.length - 1] = { ...arr[arr.length - 1], content: partial, streaming: !done, pendingTrace: false }
return arr
})
if (done) {
setBusy(false)
pendingConvRef.current.delete(cid)
persist(messagesRef.current, newTitle, cid)
}
})
})
setEntry(null)
}
const openConversation = (c: ResearchConversation) => {
stop(); traceCancelRef.current?.()
setConvId(c.id)
setTitle(c.title)
setMessages(c.messages.map(m => ({ ...m })))
setBusy(false)
}
const newConversation = () => {
stop(); traceCancelRef.current?.()
setConvId(null); setTitle(''); setMessages([]); setBusy(false); setEntry(null)
}
// 左侧导航栏通过 URL 参数控制:?conv=<id> 打开历史对话,?new=1 新建对话
useEffect(() => {
const conv = searchParams.get('conv')
const isNew = searchParams.get('new')
if (!conv && !isNew) return
if (conv) {
const c = research.find(x => x.id === conv)
if (c) openConversation(c)
} else {
newConversation()
}
setSearchParams({}, { replace: true })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchParams])
// 当前对话在左侧导航被删除时,重置为新对话(待持久化的新对话除外)
useEffect(() => {
if (convId && !pendingConvRef.current.has(convId) && !research.some(c => c.id === convId)) newConversation()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [research, convId])
return (
<div className="flex h-full">
{/* 对话区 */}
<div className="flex min-w-0 flex-1 flex-col">
<div ref={scrollRef} className="flex-1 overflow-y-auto px-6 py-5 scrollbar-thin">
{messages.length === 0 ? (
<div className="mx-auto max-w-[720px] pt-10">
<div className="text-center">
<div className="mx-auto flex h-14 w-14 items-center justify-center rounded-2xl shadow-card-hover"
style={{ background: 'linear-gradient(135deg, #6366F1 0%, #818CF8 100%)' }}>
<MessagesSquare size={24} className="text-white" />
</div>
<h1 className="mt-4 text-[22px] font-bold">
对话<span className="text-brand-gradient">调研</span>
</h1>
</div>
<div className="mt-7 grid grid-cols-3 gap-3">
{ENTRIES.map(e => (
<button key={e.key} onClick={() => { setEntry(e.key); setInput('') }}
className="rounded-card border border-line-soft bg-white p-4 text-left shadow-card transition-all duration-200 hover:-translate-y-0.5 hover:border-brand-500/40 hover:shadow-card-hover">
<div className="flex h-9 w-9 items-center justify-center rounded-ctrl bg-brand-50">
<e.icon size={18} className="text-brand-500" />
</div>
<div className="mt-2.5 text-[14px] font-semibold text-ink-900">{e.title}</div>
<div className="mt-0.5 text-xs text-ink-400">{e.desc}</div>
</button>
))}
</div>
</div>
) : (
<div className="mx-auto max-w-[820px] space-y-4">
{messages.map((m, i) => (
<div key={i} className={m.role === 'user' ? 'flex justify-end' : ''}>
{m.role === 'user' ? (
<div className="max-w-[80%] rounded-2xl rounded-br-sm bg-brand-500 px-4 py-2 text-white shadow-[0_2px_8px_rgba(99,102,241,.25)]">{m.content}</div>
) : (
<div className="rounded-card border border-line-soft bg-white px-4 py-3 shadow-card">
{m.skillTrace && (
<div className="mb-2 rounded-ctrl border border-line-soft bg-canvas px-3 py-2">
<div className="flex items-center gap-2 text-[12px] font-semibold text-brand-500">
{m.pendingTrace ? <Loader2 size={13} className="animate-spin" /> : <CircuitBoard size={13} />}
Skill 调用进展
</div>
<ul className="mt-1 space-y-1">
{m.skillTrace.map((s, j) => (
<li key={j} className="flex items-center gap-1.5 text-[12px] text-ink-600 fade-up">
<Check size={12} className="text-ok-500" /> {s}
</li>
))}
</ul>
</div>
)}
{m.content ? <Markdown text={m.content} streaming={m.streaming} /> : null}
{m.time && !m.streaming && <div className="mt-2 font-num text-[11px] text-ink-400">{m.time}</div>}
</div>
)}
</div>
))}
</div>
)}
</div>
{/* 输入区 */}
<div className="border-t border-line-soft bg-white/75 px-6 py-3 backdrop-blur-md">
<div className="mx-auto max-w-[820px]">
{entry && (
<div className="mb-2 inline-flex items-center gap-2 rounded-full bg-brand-50 px-2.5 py-1 text-xs text-brand-500">
已选入口:{ENTRIES.find(e => e.key === entry)?.title}
<button onClick={() => setEntry(null)} className="hover:text-bad-500"><X size={12} /></button>
</div>
)}
<div className="flex items-end gap-2">
<textarea
value={input}
onChange={e => setInput(e.target.value)}
onKeyDown={e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); ask(input) } }}
rows={1}
placeholder={entry ? ENTRIES.find(e => e.key === entry)?.placeholder : '直接提出研究问题,如:「调研近一个月智慧水务市场」'}
className="max-h-32 flex-1 resize-none rounded-ctrl border border-line-soft px-3.5 py-2.5 text-sm text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10 scrollbar-thin"
/>
<PrimaryButton onClick={() => ask(input)} disabled={!input.trim() || busy} className="!rounded-full !p-3">
{busy ? <Loader2 size={16} className="animate-spin" /> : <Send size={16} />}
</PrimaryButton>
</div>
</div>
</div>
</div>
</div>
)
}
import { useMemo, useState } from 'react'
import { Star, ExternalLink, Trash2, ChevronDown, ChevronRight, Sparkles, Plus, X, Link2, Tag, FileUp } from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
import type { AiPanelState, Project, WatchStatus } from '../types'
import { RESULT_STATUSES } from '../types'
import { useStore, isHistoryStatus, uid, nowStr } from '../lib/store'
import Pill from '../components/ui-ext/Pill'
import { GhostButton, PrimaryButton } from '../components/ui-ext/AiButton'
import { cn } from '@/lib/utils'
export function WatchPage({ onOpenPanel }: { onOpenPanel: (s: AiPanelState) => void }) {
const {
watch, setWatchStatus, setWatchNote, removeWatch,
customTags, addCustomTag, removeCustomTag, toggleWatchTag, addCustomProject, findProject,
} = useStore()
const [tab, setTab] = useState<'active' | 'result' | 'skipped'>('active')
const [confirmRemove, setConfirmRemove] = useState<string | null>(null)
const [openHistory, setOpenHistory] = useState<string | null>(null)
const [tagFilter, setTagFilter] = useState<string | null>(null)
const [tagEditorFor, setTagEditorFor] = useState<string | null>(null)
const [newTag, setNewTag] = useState('')
const [showAddLink, setShowAddLink] = useState(false)
const [linkForm, setLinkForm] = useState({ url: '', name: '', purchaser: '', region: '', budget: '' })
const [linkFile, setLinkFile] = useState('')
const [linkError, setLinkError] = useState('')
// 状态变更弹窗:避免一排按钮诱导频繁点击,历史记录保持干净;备注随状态一起设置
const [statusModalFor, setStatusModalFor] = useState<string | null>(null)
const [pendingStatus, setPendingStatus] = useState<WatchStatus>('已关注')
const [pendingNote, setPendingNote] = useState('')
const active = useMemo(() => watch.filter(w => !isHistoryStatus(w.status)), [watch])
const result = useMemo(() => watch.filter(w => (RESULT_STATUSES as string[]).includes(w.status)), [watch])
const skipped = useMemo(() => watch.filter(w => w.status === '暂不考虑'), [watch])
const list = (tab === 'active' ? active : tab === 'result' ? result : skipped).filter(w => !tagFilter || w.tags.includes(tagFilter))
const submitLink = () => {
const url = linkForm.url.trim()
const name = linkForm.name.trim()
if (!url && !linkFile) { setLinkError('请填写公告网址或上传公告文件'); return }
if (url && !/^https?:\/\//i.test(url)) { setLinkError('网址需以 http:// 或 https:// 开头'); return }
if (!name) { setLinkError('请填写项目名称'); return }
const budgetNum = linkForm.budget.trim() === '' ? null : Number(linkForm.budget)
if (linkForm.budget.trim() !== '' && (Number.isNaN(budgetNum) || (budgetNum as number) < 0)) { setLinkError('预算需为数字(万元)'); return }
const p: Project = {
id: uid('custom'),
name,
region: linkForm.region.trim() || '未填写',
keywords: [],
budget: budgetNum,
publishDate: nowStr().slice(0, 10),
regDeadline: null,
bidDeadline: null,
purchaser: linkForm.purchaser.trim() || '待确认(详见公告原文)',
noticeType: '手动添加',
sourceName: linkFile ? '上传公告文件' : '手动添加链接',
sourceUrl: url || null,
summary: '手动添加的项目,可通过「向AI提问」进一步了解。',
detail: `该项目由用户手动添加。\n${url ? `公告链接:${url}\n` : ''}${linkFile ? `公告文件:${linkFile}\n` : ''}地区、预算与截止时间等信息以公告原文为准。`,
requirements: [],
}
addCustomProject(p)
setShowAddLink(false)
setLinkForm({ url: '', name: '', purchaser: '', region: '', budget: '' })
setLinkFile('')
setLinkError('')
}
return (
<div className="mx-auto max-w-[1000px] px-4 py-4 sm:px-5 sm:py-5 xl:px-6">
<div className="flex items-center gap-3">
<Star size={18} className="text-brand-500" />
<h1 className="text-[17px] font-bold">重点关注</h1>
<span className="flex-1" />
<GhostButton onClick={() => {
setLinkForm({ url: '', name: '', purchaser: '', region: '', budget: '' })
setLinkFile('')
setLinkError('')
setShowAddLink(true)
}} className="!px-3 !py-1.5 text-xs">
<Plus size={14} /> 添加项目
</GhostButton>
</div>
{/* 页签:胶囊切换(跟进中 / 已有结果 / 暂不考虑) */}
<div className="mt-4 inline-flex rounded-full border border-line-soft bg-white p-1 shadow-card">
<button onClick={() => setTab('active')}
className={cn('rounded-full px-4 py-1.5 text-[13px] font-medium transition-colors',
tab === 'active' ? 'bg-brand-500 text-white shadow-[0_2px_8px_rgba(99,102,241,.25)]' : 'text-ink-600 hover:text-brand-500')}>
跟进中 <span className="font-num">({active.length})</span>
</button>
<button onClick={() => setTab('result')}
className={cn('rounded-full px-4 py-1.5 text-[13px] font-medium transition-colors',
tab === 'result' ? 'bg-brand-500 text-white shadow-[0_2px_8px_rgba(99,102,241,.25)]' : 'text-ink-600 hover:text-brand-500')}>
已有结果 <span className="font-num">({result.length})</span>
</button>
<button onClick={() => setTab('skipped')}
className={cn('rounded-full px-4 py-1.5 text-[13px] font-medium transition-colors',
tab === 'skipped' ? 'bg-brand-500 text-white shadow-[0_2px_8px_rgba(99,102,241,.25)]' : 'text-ink-600 hover:text-brand-500')}>
暂不考虑 <span className="font-num">({skipped.length})</span>
</button>
</div>
{/* 自定义标签筛选:在卡片上给项目打标签后可按标签分类查看 */}
{customTags.length > 0 && (
<div className="mt-3 flex flex-wrap items-center gap-1.5">
<Tag size={13} className="text-ink-400" />
<button onClick={() => setTagFilter(null)}
className={cn('rounded-full border px-2.5 py-1 text-[12px] transition-colors',
tagFilter === null ? 'border-brand-500 bg-brand-50 text-brand-500' : 'border-line-soft text-ink-600 hover:border-brand-500/40 hover:text-brand-500')}>
全部
</button>
{customTags.map(t => (
<span key={t}
className={cn('inline-flex items-center rounded-full border text-[12px] transition-colors',
tagFilter === t ? 'border-brand-500 bg-brand-50 text-brand-500' : 'border-line-soft text-ink-600 hover:border-brand-500/40 hover:text-brand-500')}>
<button onClick={() => setTagFilter(tagFilter === t ? null : t)} className="py-1 pl-2.5 pr-1">
{t}
</button>
<button onClick={() => { removeCustomTag(t); if (tagFilter === t) setTagFilter(null) }}
title={`删除标签「${t}」(同时从各项目移除)`}
className="py-1 pl-0.5 pr-2 text-ink-400 hover:text-bad-500" aria-label={`删除标签 ${t}`}>
<X size={11} />
</button>
</span>
))}
{tagFilter && <span className="text-xs text-ink-400">筛选中:{tagFilter}(再点一次取消)</span>}
</div>
)}
{list.length === 0 ? (
<section className="mt-4 rounded-card border border-dashed border-line-soft bg-white py-16 text-center shadow-card">
<div className="mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-brand-50">
<Star size={24} className="text-brand-500" />
</div>
<p className="mt-4 text-sm text-ink-400">
{tab === 'active'
? '暂无跟进中的项目。在「发现商机」检索结果中点击 ☆ 加入重点关注。'
: tab === 'result'
? '暂无已有结果的项目。中标 / 未中标 / 流标的项目会保留在这里。'
: '暂无暂不考虑的项目。我方主动放弃跟进的项目会保留在这里,可随时转回跟进。'}
</p>
</section>
) : (
<ul className="mt-4 space-y-3">
{list.map(w => {
const p = findProject(w.projectId)
if (!p) return null
return (
<li key={w.projectId} className="rounded-card border border-line-soft bg-white p-5 shadow-card transition-shadow hover:shadow-card-hover fade-up">
<div className="flex items-start gap-3">
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
<span className="text-[15px] font-semibold text-ink-900">{p.name}</span>
<span className="rounded-full bg-[#F4F7FB] px-2 py-0.5 text-[11px] text-ink-600">{p.region}</span>
<span className="rounded-full bg-[#F4F7FB] px-2 py-0.5 text-[11px] text-ink-600">
{p.budget === null ? '预算未披露' : <span className="font-num">{p.budget.toLocaleString()} 万元</span>}
</span>
</div>
<div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-ink-400">
<span>发布 <span className="font-num">{p.publishDate}</span> · 报名截止 <span className="font-num">{p.regDeadline ?? '未披露'}</span></span>
{/* 自定义标签:跟在报名截止右侧,不单独占行 */}
<span className="relative flex flex-wrap items-center gap-1.5">
{w.tags.map(t => (
<span key={t} className="inline-flex items-center gap-1 rounded-full bg-brand-50 px-2 py-0.5 text-[11px] text-brand-500">
{t}
<button onClick={() => toggleWatchTag(w.projectId, t)} className="text-brand-500/60 hover:text-brand-500" aria-label={`移除标签 ${t}`}>
<X size={10} />
</button>
</span>
))}
<button onClick={() => { setTagEditorFor(tagEditorFor === w.projectId ? null : w.projectId); setNewTag('') }}
className="inline-flex items-center gap-0.5 rounded-full border border-dashed border-line-soft px-2 py-0.5 text-[11px] text-ink-400 transition-colors hover:border-brand-500/40 hover:text-brand-500">
<Plus size={10} /> 标签
</button>
{tagEditorFor === w.projectId && (
<div className="absolute left-0 top-full z-20 mt-1 w-56 rounded-card border border-line-soft bg-white p-3 shadow-card-hover fade-up">
<div className="text-xs font-medium text-ink-900">选择或新建标签</div>
<div className="mt-1.5 flex flex-wrap gap-1">
{customTags.length === 0 && <span className="text-[11px] text-ink-400">还没有标签,先在下方新建一个</span>}
{customTags.map(t => {
const on = w.tags.includes(t)
return (
<span key={t}
className={cn('inline-flex items-center rounded-full border text-[11px] transition-colors',
on ? 'border-brand-500 bg-brand-50 text-brand-500' : 'border-line-soft text-ink-600 hover:border-brand-500/40 hover:text-brand-500')}>
<button onClick={() => toggleWatchTag(w.projectId, t)} className="py-0.5 pl-2 pr-0.5">{t}</button>
<button onClick={() => removeCustomTag(t)} title={`删除标签「${t}」`}
className="py-0.5 pl-0.5 pr-1.5 text-ink-400 hover:text-bad-500" aria-label={`删除标签 ${t}`}>
<X size={9} />
</button>
</span>
)
})}
</div>
<div className="mt-2 flex items-center gap-1.5">
<input value={newTag} onChange={e => setNewTag(e.target.value)}
onKeyDown={e => {
if (e.key === 'Enter' && newTag.trim()) {
addCustomTag(newTag.trim())
if (!w.tags.includes(newTag.trim())) toggleWatchTag(w.projectId, newTag.trim())
setNewTag('')
}
}}
placeholder="新标签名,回车创建"
className="w-full rounded-ctrl border border-line-soft px-2 py-1 text-[12px] outline-none placeholder:text-ink-400 focus:border-brand-500/60" />
</div>
</div>
)}
</span>
</div>
<div className="mt-1 text-[13px] text-ink-600">{p.summary}</div>
</div>
<div className="flex shrink-0 flex-col items-end gap-1.5">
{p.sourceUrl && (
<a href={p.sourceUrl} target="_blank" rel="noreferrer"
className="inline-flex items-center gap-1 rounded-ctrl border border-line-soft bg-white px-3 py-1.5 text-xs font-medium text-ink-600 transition-colors hover:border-brand-500/40 hover:text-brand-500">
<ExternalLink size={12} /> 公告原文
</a>
)}
<button onClick={() => onOpenPanel({ kind: 'project', projectId: p.id })}
className="inline-flex items-center gap-1 rounded-ctrl border-brand-gradient px-3 py-1.5 text-xs font-medium shadow-card transition-shadow hover:shadow-card-hover">
<Sparkles size={12} className="text-brand-500" /><span className="text-brand-gradient">向AI提问</span>
</button>
</div>
</div>
{/* 状态:通过弹窗单独设置,避免误点与频繁变更历史 */}
<div className="mt-3.5 flex flex-wrap items-center gap-2">
<span className="text-[13px] text-ink-400">当前状态:</span>
<Pill status={w.status} />
<button onClick={() => {
setStatusModalFor(w.projectId)
setPendingStatus(w.status)
setPendingNote(w.note)
}}
className="rounded-full border border-line-soft px-2.5 py-1 text-[12px] text-ink-600 transition-colors hover:border-brand-500/40 hover:text-brand-500">
变更状态
</button>
<span className="flex-1" />
<button onClick={() => setConfirmRemove(w.projectId)}
className="inline-flex items-center gap-1 text-xs text-bad-500 hover:underline">
<Trash2 size={12} /> 取消关注
</button>
</div>
{/* 备注:填写过才展示;填写与修改统一在「变更状态」弹窗里进行 */}
{w.note && (
<div className="mt-3 rounded-ctrl border border-line-soft bg-canvas px-3 py-2 text-[13px] leading-relaxed text-ink-600">
{w.note}
</div>
)}
<div className="mt-2">
<button onClick={() => setOpenHistory(openHistory === w.projectId ? null : w.projectId)}
className="inline-flex items-center gap-1 text-xs text-ink-400 hover:text-brand-500">
{openHistory === w.projectId ? <ChevronDown size={13} /> : <ChevronRight size={13} />}
状态变更历史(<span className="font-num">{w.history.length}</span> 次)· 关注于 <span className="font-num">{w.createdAt}</span>
</button>
{openHistory === w.projectId && (
<ul className="ml-2 mt-1.5 space-y-1.5 border-l-2 border-line-soft pl-3 text-xs text-ink-400 fade-up">
{[...w.history].reverse().map((h, i) => (
<li key={i}>
<b className="text-ink-900">{h.status}</b> · <span className="font-num">{h.time}</span>
{h.note && <div className="mt-0.5 text-ink-600">当时备注:{h.note}</div>}
</li>
))}
</ul>
)}
</div>
</li>
)
})}
</ul>
)}
<AnimatePresence>
{confirmRemove && (
<motion.div className="fixed inset-0 z-50 flex items-center justify-center bg-ink-900/20 backdrop-blur-sm"
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }}
onClick={e => { if (e.target === e.currentTarget) setConfirmRemove(null) }}>
<motion.div className="relative w-[380px] rounded-card border border-line-soft bg-white p-5 text-center shadow-card-hover"
initial={{ scale: 0.96, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.96, opacity: 0 }} transition={{ duration: 0.18 }}>
<button onClick={() => setConfirmRemove(null)} aria-label="关闭"
className="absolute right-3 top-3 rounded-full p-1.5 text-ink-400 transition-colors hover:bg-[#F4F7FB]"><X size={15} /></button>
<div className="mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-bad-500/10 text-lg font-bold text-bad-500">!</div>
<h3 className="mt-2 font-bold">取消关注这个项目?</h3>
<p className="mt-1.5 text-[13px] leading-relaxed text-ink-400">
将移除该项目的状态、备注与全部历史。<br />
暂时不跟进,可改设为「暂不考虑」。
</p>
<div className="mt-4 flex justify-center gap-2">
<GhostButton onClick={() => setConfirmRemove(null)}>再想想</GhostButton>
<PrimaryButton onClick={() => { removeWatch(confirmRemove); setConfirmRemove(null) }}
className="!bg-bad-500 hover:!bg-bad-500/90 !shadow-[0_2px_8px_rgba(244,63,94,.25)]">确认取消关注</PrimaryButton>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
<AnimatePresence>
{showAddLink && (
<motion.div className="fixed inset-0 z-50 flex items-center justify-center bg-ink-900/20 backdrop-blur-sm"
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }}
onClick={e => { if (e.target === e.currentTarget) setShowAddLink(false) }}>
<motion.div className="w-[420px] rounded-card border border-line-soft bg-white p-5 shadow-card-hover"
initial={{ scale: 0.96, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.96, opacity: 0 }} transition={{ duration: 0.18 }}>
<div className="flex items-center gap-2">
<Link2 size={15} className="text-brand-500" />
<h3 className="font-bold">添加项目</h3>
<span className="flex-1" />
<button onClick={() => setShowAddLink(false)} aria-label="关闭"
className="rounded-full p-1.5 text-ink-400 transition-colors hover:bg-[#F4F7FB]"><X size={16} /></button>
</div>
<p className="mt-1 text-[13px] leading-relaxed text-ink-400">
粘贴公告网址,或直接上传公告文件(PDF / Word / 图片)。<br />
AI 会提取项目信息,加入后即可提问、跟进与打标签。
</p>
<div className="mt-3 space-y-2.5">
<div>
<label className="text-[13px] font-medium text-ink-900">公告网址 <span className="text-xs font-normal text-ink-400">选填</span></label>
<input value={linkForm.url} onChange={e => { setLinkForm(f => ({ ...f, url: e.target.value })); setLinkError('') }}
placeholder="https://…"
className="mt-1 w-full rounded-ctrl border border-line-soft px-3 py-2 text-[13px] outline-none placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
<div>
<label className="text-[13px] font-medium text-ink-900">公告文件 <span className="text-xs font-normal text-ink-400">选填,与网址二选一</span></label>
{linkFile ? (
<div className="mt-1 flex items-center gap-2 rounded-ctrl border border-brand-500/30 bg-brand-50 px-3 py-2 text-[13px] text-ink-900">
<FileUp size={14} className="shrink-0 text-brand-500" />
<span className="min-w-0 flex-1 truncate">{linkFile}</span>
<button onClick={() => setLinkFile('')} className="shrink-0 rounded-full p-0.5 text-ink-400 hover:text-bad-500" aria-label="移除文件">
<X size={13} />
</button>
</div>
) : (
<label className="mt-1 flex cursor-pointer items-center justify-center gap-1.5 rounded-ctrl border border-dashed border-line-soft px-3 py-2.5 text-[13px] text-ink-400 transition-colors hover:border-brand-500/40 hover:text-brand-500">
<FileUp size={14} /> 上传公告文件,AI 自动提取项目信息
<input type="file" accept=".pdf,.doc,.docx,.txt,.md,.png,.jpg,.jpeg" className="hidden"
onChange={e => {
const f = e.target.files?.[0]
if (!f) return
setLinkFile(f.name)
setLinkError('')
// 按文件名预填项目名称,用户可改
setLinkForm(prev => prev.name ? prev : { ...prev, name: f.name.replace(/\.[^.]+$/, '') })
e.target.value = ''
}} />
</label>
)}
</div>
<div>
<label className="text-[13px] font-medium text-ink-900">项目名称 <span className="text-warn-500">*</span></label>
<input value={linkForm.name} onChange={e => { setLinkForm(f => ({ ...f, name: e.target.value })); setLinkError('') }}
placeholder="按公告标题填写"
className="mt-1 w-full rounded-ctrl border border-line-soft px-3 py-2 text-[13px] outline-none placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
<div className="grid grid-cols-3 gap-2">
<div>
<label className="text-[13px] font-medium text-ink-900">招标方</label>
<input value={linkForm.purchaser} onChange={e => setLinkForm(f => ({ ...f, purchaser: e.target.value }))}
placeholder="选填"
className="mt-1 w-full rounded-ctrl border border-line-soft px-3 py-2 text-[13px] outline-none placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
<div>
<label className="text-[13px] font-medium text-ink-900">地区</label>
<input value={linkForm.region} onChange={e => setLinkForm(f => ({ ...f, region: e.target.value }))}
placeholder="选填"
className="mt-1 w-full rounded-ctrl border border-line-soft px-3 py-2 text-[13px] outline-none placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
<div>
<label className="text-[13px] font-medium text-ink-900">预算(万元)</label>
<input type="number" min={0} value={linkForm.budget} onChange={e => { setLinkForm(f => ({ ...f, budget: e.target.value })); setLinkError('') }}
placeholder="选填"
className="mt-1 w-full rounded-ctrl border border-line-soft px-3 py-2 text-[13px] font-num outline-none placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10" />
</div>
</div>
{linkError && <div className="text-xs text-bad-500">{linkError}</div>}
</div>
<div className="mt-4 flex justify-end gap-2">
<GhostButton onClick={() => setShowAddLink(false)}>取消</GhostButton>
<PrimaryButton onClick={submitLink}>添加并关注</PrimaryButton>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
{/* 状态变更弹窗 */}
<AnimatePresence>
{statusModalFor && (
<motion.div className="fixed inset-0 z-50 flex items-center justify-center bg-ink-900/20 backdrop-blur-sm"
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }}
onClick={e => { if (e.target === e.currentTarget) setStatusModalFor(null) }}>
<motion.div className="max-h-[85vh] w-[460px] max-w-[92vw] overflow-y-auto rounded-card border border-line-soft bg-white p-5 shadow-card-hover scrollbar-thin"
initial={{ scale: 0.96, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} exit={{ scale: 0.96, opacity: 0 }} transition={{ duration: 0.18 }}>
<div className="flex items-center justify-between">
<h3 className="font-bold">变更跟进状态</h3>
<button onClick={() => setStatusModalFor(null)} aria-label="关闭"
className="rounded-full p-1.5 text-ink-400 transition-colors hover:bg-[#F4F7FB]"><X size={16} /></button>
</div>
<p className="mt-1 text-[13px] text-ink-400">选择新状态后可顺手更新备注,变更与备注会一起记入状态历史。</p>
<div className="mt-3 space-y-2.5">
{([
['跟进中', ['已关注', '准备投标', '已报名', '已提交投标文件']],
['已有结果', ['已中标', '未中标', '已流标']],
['我方决定', ['暂不考虑']],
] as const).map(([group, statuses]) => (
<div key={group}>
<div className="mb-1 text-[11px] font-medium text-ink-400">{group}</div>
<div className="grid grid-cols-2 gap-1.5">
{statuses.map(s => (
<button key={s} onClick={() => setPendingStatus(s)}
className={cn('flex items-center gap-2 rounded-ctrl border px-2.5 py-2 text-left transition-colors',
pendingStatus === s ? 'border-brand-500 bg-brand-50' : 'border-line-soft hover:border-brand-500/40')}>
<span className={cn('h-3 w-3 shrink-0 rounded-full border-2', pendingStatus === s ? 'border-brand-500 bg-brand-500' : 'border-line-soft')} />
<span className={cn('min-w-0 text-[13px] font-medium leading-tight', pendingStatus === s ? 'text-brand-500' : 'text-ink-900')}>{s}</span>
</button>
))}
</div>
</div>
))}
</div>
<textarea
value={pendingNote}
onChange={e => setPendingNote(e.target.value)}
placeholder="备注(可选):为什么变更到这个状态、下一步要做什么…"
rows={2}
className="mt-3 w-full resize-y rounded-ctrl border border-line-soft px-3 py-2 text-[13px] text-ink-900 outline-none transition-shadow placeholder:text-ink-400 focus:border-brand-500/60 focus:ring-2 focus:ring-brand-500/10 scrollbar-thin"
/>
<div className="mt-4 flex justify-end gap-2">
<GhostButton onClick={() => setStatusModalFor(null)}>取消</GhostButton>
<PrimaryButton onClick={() => {
// 先保存备注再改状态,状态历史快照记下的就是这条新备注
setWatchNote(statusModalFor, pendingNote)
setWatchStatus(statusModalFor, pendingStatus)
setStatusModalFor(null)
}}>确定</PrimaryButton>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
</div>
)
}
// ---------- 数据模型 ----------
export interface Project {
id: string
name: string
region: string // 如 "浙江·杭州"
keywords: string[]
budget: number | null // 预算(万元),null = 公告未披露
publishDate: string // 公告发布日期 YYYY-MM-DD
regDeadline: string | null // 报名截止 YYYY-MM-DD,null = 未披露/不适用
bidDeadline: string | null // 投标截止
purchaser: string // 采购单位
noticeType: string // 招标公告 / 竞争性磋商 / 更正公告 等
sourceName: string // 来源平台名称
sourceUrl: string | null // 来源网址,null = 链接暂未收录
summary: string // 列表简析(一句项目概述或需关注事项)
detail: string // 项目内容(供 AI 分析引用)
requirements: string[] // 公告参与条件
}
export interface SearchConditions {
keyword: string
region: string
budgetMin: string // 万元,'' 表示不限
budgetMax: string
publishRange: '7d' | '30d' | '90d' | 'all'
}
export interface SearchBatch {
id: string
conditions: SearchConditions
executedAt: string
projectIds: string[]
total: number
}
export type WatchStatus =
| '已关注' | '准备投标' | '已报名' | '已提交投标文件'
| '已中标' | '未中标' | '已流标'
| '暂不考虑'
export const WATCH_STATUSES: WatchStatus[] = [
'已关注', '准备投标', '已报名', '已提交投标文件',
'已中标', '未中标', '已流标',
'暂不考虑',
]
export const RESULT_STATUSES: WatchStatus[] = ['已中标', '未中标', '已流标']
export const SKIPPED_STATUSES: WatchStatus[] = ['暂不考虑']
export const HISTORY_STATUSES: WatchStatus[] = [...RESULT_STATUSES, ...SKIPPED_STATUSES]
/** 每个状态的含义与边界说明,在变更状态弹窗中展示 */
export const WATCH_STATUS_DESC: Record<WatchStatus, string> = {
已关注: '先放进清单观望,还没决定是否参与',
准备投标: '决定参与,正在准备报名材料或投标文件',
已报名: '已在招标平台完成报名,等待递交标书',
已提交投标文件: '标书已递交,等待开标与评标结果',
已中标: '结果公告:我方中标',
未中标: '结果公告:我方未中标',
已流标: '招标方公告流标,或项目已终止',
暂不考虑: '我方主动放弃跟进(与项目结果无关),可随时转回',
}
export interface StatusChange {
status: WatchStatus
time: string
/** 状态变更那一刻的备注快照 */
note?: string
}
export interface WatchRecord {
projectId: string
status: WatchStatus
note: string
/** 用户自定义分类标签 */
tags: string[]
createdAt: string
history: StatusChange[]
}
export interface TaskRun {
time: string
status: 'success' | 'failed'
count: number
error?: string
}
export interface ScheduleTask {
id: string
name: string
conditions: SearchConditions
frequency: 'daily' | 'once'
time: string // HH:mm(北京时间)
createdAt: string
runs: TaskRun[]
}
export interface MatchWeights {
/** 业务贴合(%) */
business: number
/** 服务地区(%) */
region: number
/** 金额匹配(%) */
amount: number
/** 业绩与资质(%) */
track: number
}
/** 匹配度四个维度的显示名称,用户可自定义 */
export interface MatchDimNames {
business: string
region: string
amount: string
track: string
}
export const defaultMatchDimNames: MatchDimNames = {
business: '业务贴合',
region: '服务地区',
amount: '金额匹配',
track: '业绩与资质',
}
export interface CompanyProfile {
companyName: string
intro: string
mainBusiness: string
products: string
advantages: string
serviceRegions: string
customerTypes: string
projectTypes: string
amountPreference: string
qualifications: string
trackRecord: string
delivery: string
bidPreparation: string
boundaries: string
/** 匹配度四个维度的权重,用户可自配置 */
matchWeights: MatchWeights
/** 匹配度维度的自定义名称 */
matchDimNames: MatchDimNames
completed: boolean
version: number
updatedAt: string | null
}
export const defaultMatchWeights: MatchWeights = { business: 40, region: 20, amount: 20, track: 20 }
export const emptyProfile: CompanyProfile = {
companyName: '', intro: '', mainBusiness: '', products: '', advantages: '',
serviceRegions: '', customerTypes: '', projectTypes: '', amountPreference: '',
qualifications: '', trackRecord: '', delivery: '', bidPreparation: '', boundaries: '',
matchWeights: { ...defaultMatchWeights },
matchDimNames: { ...defaultMatchDimNames },
completed: false, version: 0, updatedAt: null,
}
/** 演示用公司档案:首次使用或档案为空时载入,让匹配度打分与 AI 分析报告可直接演示 */
export const demoProfile: CompanyProfile = {
companyName: '杭州澜清水务科技有限公司',
intro: '成立于 2016 年,专注智慧水务领域,服务长三角地区水务集团与政府监管部门。',
mainBusiness: '智慧水务平台建设、供水管网漏损控制、水质监测设备',
products: 'DMA 分区计量系统、管网漏损分析平台、水质在线监测设备、二次供水监控系统',
advantages: '自研漏损分析算法、本地化交付团队、7×24 响应',
serviceRegions: '浙江、江苏、上海',
customerTypes: '水务集团、住建局、园区管委会',
projectTypes: '软件平台、监测设备、运营服务',
amountPreference: '100-2000 万元',
qualifications: '电子与智能化工程专业承包二级(有效期至 2028-06);软件著作权 6 项;ISO9001 质量管理体系认证',
trackRecord: '2025 年某市供水管网漏损治理项目(540 万元,已通过验收);2024 年某县智慧水务平台建设项目(860 万元)',
delivery: '自有实施团队 12 人,支持驻场;提供 7×24 响应',
bidPreparation: '常规标书准备约 7 天,涉及现场勘察需 10 天以上',
boundaries: '不参与需要垫资的工程施工总承包项目',
matchWeights: { ...defaultMatchWeights },
matchDimNames: { ...defaultMatchDimNames },
completed: true,
version: 1,
updatedAt: null,
}
export interface ChatMessage {
role: 'user' | 'assistant'
content: string
skillTrace?: string[] // 实际发生的 Skill 调用记录
time: string
}
export interface ResearchConversation {
id: string
title: string
createdAt: string
messages: ChatMessage[]
}
export type AiPanelState =
| { kind: 'closed' }
| { kind: 'project'; projectId: string }
| { kind: 'search'; batchId: string }
export type PageKey = 'discover' | 'watch' | 'research' | 'profile'
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ["class"],
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive) / <alpha-value>)",
foreground: "hsl(var(--destructive-foreground) / <alpha-value>)",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
/* 如昼品牌色板:靛蓝主色 + 冷灰分层背景 */
canvas: "#F8F9FB",
sidebar: "#F1F3F6",
brand: {
50: "#EEF0FF",
100: "#E0E3FE",
500: "#6366F1",
600: "#4F46E5",
},
aqua: { 400: "#818CF8" },
ink: {
900: "#0F172A",
600: "#475569",
400: "#94A3B8",
},
line: { soft: "#EDF0F5" },
ok: { 500: "#10B981" },
warn: { 500: "#F59E0B" },
bad: { 500: "#F43F5E" },
},
fontFamily: {
sans: ['"Noto Sans SC"', 'system-ui', 'sans-serif'],
num: ['Manrope', '"Noto Sans SC"', 'sans-serif'],
},
borderRadius: {
card: "16px",
ctrl: "12px",
xl: "calc(var(--radius) + 4px)",
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
xs: "calc(var(--radius) - 6px)",
},
boxShadow: {
xs: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
/* 软阴影:大半径低透明度,卡片像悬浮的轻量薄片 */
card: "0 10px 25px -5px rgba(0, 0, 0, 0.04)",
"card-hover": "0 16px 36px -8px rgba(0, 0, 0, 0.08), 0 4px 14px rgba(99, 102, 241, 0.10)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
"caret-blink": {
"0%,70%,100%": { opacity: "1" },
"20%,50%": { opacity: "0" },
},
"water-drift": {
"0%": { backgroundPosition: "0 0" },
"100%": { backgroundPosition: "40px 0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"caret-blink": "caret-blink 1.25s ease-out infinite",
"water-drift": "water-drift 20s linear infinite alternate",
},
},
},
plugins: [require("tailwindcss-animate")],
}
Using Node.js 20, Tailwind CSS v3.4.19, and Vite v7.2.4
Tailwind CSS has been set up with the shadcn theme
Setup complete: /mnt/agents/output/app
Components (40+):
accordion, alert-dialog, alert, aspect-ratio, avatar, badge, breadcrumb,
button-group, button, calendar, card, carousel, chart, checkbox, collapsible,
command, context-menu, dialog, drawer, dropdown-menu, empty, field, form,
hover-card, input-group, input-otp, input, item, kbd, label, menubar,
navigation-menu, pagination, popover, progress, radio-group, resizable,
scroll-area, select, separator, sheet, sidebar, skeleton, slider, sonner,
spinner, switch, table, tabs, textarea, toggle-group, toggle, tooltip
Usage:
import { Button } from '@/components/ui/button'
import { Card, CardHeader, CardTitle } from '@/components/ui/card'
Structure:
src/sections/ Page sections
src/hooks/ Custom hooks
src/types/ Type definitions
src/App.css Styles specific to the Webapp
src/App.tsx Root React component
src/index.css Global styles
src/main.tsx Entry point for rendering the Webapp
index.html Entry point for the Webapp
tailwind.config.js Configures Tailwind's theme, plugins, etc.
vite.config.ts Main build and dev server settings for Vite
postcss.config.js Config file for CSS post-processing tools
\ No newline at end of file
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
},
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
\ No newline at end of file
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
import path from "path"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
import { inspectAttr } from 'kimi-plugin-inspect-react'
// https://vite.dev/config/
export default defineConfig({
base: './',
plugins: [inspectAttr(), react()],
server: {
port: 3000,
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment