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

初始化

parents
Pipeline #438 failed with stages
in 0 seconds
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "postcss.config.js",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {}
}
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Noto+Sans+SC:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<title>如昼商机助手</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
This diff is collapsed.
{
"name": "my-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
"@radix-ui/react-accordion": "^1.2.12",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-aspect-ratio": "^1.1.8",
"@radix-ui/react-avatar": "^1.1.11",
"@radix-ui/react-checkbox": "^1.3.3",
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-context-menu": "^2.2.16",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-hover-card": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
"@radix-ui/react-menubar": "^1.1.16",
"@radix-ui/react-navigation-menu": "^1.2.14",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-progress": "^1.1.8",
"@radix-ui/react-radio-group": "^1.3.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-separator": "^1.1.8",
"@radix-ui/react-slider": "^1.3.6",
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-switch": "^1.2.6",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-toggle": "^1.1.10",
"@radix-ui/react-toggle-group": "^1.1.11",
"@radix-ui/react-tooltip": "^1.2.8",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"embla-carousel-react": "^8.6.0",
"framer-motion": "^14.5.0",
"input-otp": "^1.4.2",
"lucide-react": "^0.562.0",
"next-themes": "^0.4.6",
"react": "^19.2.0",
"react-day-picker": "^9.13.0",
"react-dom": "^19.2.0",
"react-hook-form": "^7.70.0",
"react-resizable-panels": "^4.2.2",
"react-router": "^7.6.1",
"recharts": "^2.15.4",
"sonner": "^2.0.7",
"tailwind-merge": "^3.4.0",
"vaul": "^1.1.2",
"zod": "^4.3.5"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.1",
"@types/react": "^19.2.5",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
"autoprefixer": "^10.4.23",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"kimi-plugin-inspect-react": "^1.0.3",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.19",
"tailwindcss-animate": "^1.0.7",
"tw-animate-css": "^1.4.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.4",
"vite": "^7.2.4"
}
}
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" fill="none">
<defs>
<linearGradient id="rzg" x1="0" y1="0" x2="48" y2="48" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#2563EB"/>
<stop offset="1" stop-color="#22D3EE"/>
</linearGradient>
</defs>
<rect width="48" height="48" rx="12" fill="url(#rzg)"/>
<!-- half sun rising -->
<path d="M17 25a7 7 0 0 1 14 0" stroke="#fff" stroke-width="3" stroke-linecap="round"/>
<!-- sun rays -->
<path d="M24 12v3M15.5 15.5l2 2M32.5 15.5l-2 2" stroke="#fff" stroke-width="2.4" stroke-linecap="round" opacity="0.9"/>
<!-- wave lines -->
<path d="M10 27c2.5-2.2 5-2.2 7.5 0s5 2.2 7.5 0 5-2.2 7.5 0 4 1.8 5.5.6" stroke="#fff" stroke-width="2.6" stroke-linecap="round"/>
<path d="M13 33c2.5-2 5-2 7.5 0s5 2 7.5 0 4.4-1.7 7-.2" stroke="#fff" stroke-width="2.6" stroke-linecap="round" opacity="0.65"/>
</svg>
"""把 dist 构建产物打包成单个自包含 HTML(JS/CSS/图片全部内联)。"""
import base64
import re
import sys
from pathlib import Path
APP = Path(__file__).resolve().parent.parent
DIST = APP / 'dist'
OUT = APP.parent / '如昼商机助手.html'
def data_uri(path: Path, mime: str) -> str:
return f"data:{mime};base64,{base64.b64encode(path.read_bytes()).decode()}"
html = (DIST / 'index.html').read_text(encoding='utf-8')
js_file = next((DIST / 'assets').glob('index-*.js'))
css_file = next((DIST / 'assets').glob('index-*.css'))
js = js_file.read_text(encoding='utf-8')
css = css_file.read_text(encoding='utf-8')
# 图片资源内联为 data URI(file:// 下绝对路径会失效)
js = js.replace('"/avatar-user.gif"', f'"{data_uri(DIST / "avatar-user.gif", "image/gif")}"')
js = js.replace('"/avatar-user.png"', f'"{data_uri(DIST / "avatar-user.png", "image/png")}"')
js = js.replace('"/bee-briefcase.png"', f'"{data_uri(DIST / "bee-briefcase.png", "image/png")}"')
# 防止 JS 中的 </script> 提前闭合
js = js.replace('</script', '<\\/script')
# favicon 内联
html = html.replace('href="./logo.svg"',
f'href="{data_uri(DIST / "logo.svg", "image/svg+xml")}"')
# 内联 JS / CSS
html = re.sub(r'<script type="module" crossorigin src="\./assets/index-[^"]+\.js"></script>',
lambda m: '<script type="module">\n' + js + '\n</script>', html)
html = re.sub(r'<link rel="stylesheet" crossorigin href="\./assets/index-[^"]+\.css">',
lambda m: '<style>\n' + css + '\n</style>', html)
assert 'assets/index-' not in html, '还有未内联的资源引用'
assert '/avatar-user.' not in html, '图片路径未替换干净'
assert '/bee-briefcase.' not in html, '小蜜蜂图片路径未替换干净'
OUT.write_text(html, encoding='utf-8')
print(f'OK -> {OUT} ({OUT.stat().st_size / 1024 / 1024:.2f} MB)')
import { useEffect, useState } from 'react'
import { Routes, Route, useLocation, Navigate } from 'react-router'
import { StoreProvider } from './lib/store'
import Sidebar from './components/Sidebar'
import Topbar from './components/Topbar'
import { AiPanel } from './components/AiPanel'
import { DiscoverPage } from './pages/DiscoverPage'
import { WatchPage } from './pages/WatchPage'
import { ResearchPage } from './pages/ResearchPage'
import { ProfilePage } from './pages/ProfilePage'
import { LoginPage } from './pages/LoginPage'
import type { AiPanelState } from './types'
export default function App() {
const [panel, setPanel] = useState<AiPanelState>({ kind: 'closed' })
const { pathname } = useLocation()
// 演示登录态:本地记录,退出登录清除
const [authed, setAuthed] = useState(() => localStorage.getItem('rz-authed') === '1')
// 路由切换时内容区回顶
useEffect(() => {
document.getElementById('main-scroll')?.scrollTo({ top: 0, behavior: 'auto' })
}, [pathname])
const login = () => { localStorage.setItem('rz-authed', '1'); setAuthed(true) }
const logout = () => { localStorage.removeItem('rz-authed'); setAuthed(false) }
if (pathname === '/login') {
return authed ? <Navigate to="/" replace /> : <LoginPage onLogin={login} />
}
if (!authed) return <Navigate to="/login" replace />
return (
<StoreProvider>
<div className="flex h-[100dvh] overflow-hidden bg-canvas">
<div className="sticky top-0 h-[100dvh] max-lg:hidden">
<Sidebar onLogout={logout} />
</div>
<div className="flex min-w-0 flex-1 flex-col">
<Topbar />
<main id="main-scroll" className="min-h-0 flex-1 overflow-y-auto overscroll-contain scrollbar-thin">
<Routes>
<Route path="/" element={<DiscoverPage onOpenPanel={setPanel} />} />
<Route path="/watch" element={<WatchPage onOpenPanel={setPanel} />} />
<Route path="/research" element={<ResearchPage />} />
<Route path="/profile" element={<ProfilePage />} />
</Routes>
</main>
</div>
<AiPanel state={panel} onClose={() => setPanel({ kind: 'closed' })} />
</div>
</StoreProvider>
)
}
import { useEffect, useRef, useState } from 'react'
import { X, ExternalLink, Star, Send, Loader2, Sparkles } from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
import type { AiPanelState } from '../types'
import { useStore, conditionsText, nowStr } from '../lib/store'
import { projectAnalysis, projectFollowUp, searchQaAnswer } from '../lib/ai'
import { Markdown } from './Markdown'
import { useStreaming } from '../hooks/useStreaming'
import { cn } from '@/lib/utils'
interface Msg {
role: 'user' | 'assistant'
content: string
streaming?: boolean
}
const PROJECT_QUICK = ['报名和投标截止时间', '公告参与条件', '预算口径与报价参考', '风险与注意事项']
const SEARCH_QUICK = ['哪些项目报名快截止了', '这些项目的预算披露情况', '这些项目有哪些共同要求', '比较一下这些项目']
export function AiPanel({ state, onClose }: { state: AiPanelState; onClose: () => void }) {
const { profile, batches, addWatch, isWatched, removeWatch, findProject } = useStore()
const [messages, setMessages] = useState<Msg[]>([])
const [input, setInput] = useState('')
const [busy, setBusy] = useState(false)
const scrollRef = useRef<HTMLDivElement>(null)
const { stream, stop } = useStreaming()
const project = state.kind === 'project' ? findProject(state.projectId) : null
const batch = state.kind === 'search' ? batches.find(b => b.id === state.batchId) : null
const open = state.kind !== 'closed'
// 打开或切换项目/批次时重置对话,保证对话绑定当前对象
useEffect(() => {
if (!open) return
stop()
setInput('')
setBusy(true)
const initText = state.kind === 'project' && project
? projectAnalysis(project, profile)
: state.kind === 'search' && batch
? `### 基于本次搜索提问\n\n本次对话对应实际执行的检索条件:**${conditionsText(batch.conditions)}**,执行时间 ${batch.executedAt},共 **${batch.total} 条结果**。\n\n你可以围绕这批结果比较、提问。我只基于本次结果回答,不会修改结果列表的范围或顺序;如结果分页,默认覆盖全部 ${batch.total} 条而非仅当前页。`
: '暂无上下文'
setMessages([{ role: 'assistant', content: '', streaming: true }])
stream(initText, (partial, done) => {
setMessages([{ role: 'assistant', content: partial, streaming: !done }])
if (done) setBusy(false)
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state])
useEffect(() => {
scrollRef.current?.scrollTo({ top: scrollRef.current.scrollHeight, behavior: 'smooth' })
}, [messages])
const ask = (q: string) => {
const question = q.trim()
if (!question || busy) return
setInput('')
setBusy(true)
const answer = state.kind === 'project' && project
? projectFollowUp(project, question, profile)
: state.kind === 'search' && batch
? searchQaAnswer(batch, question, profile)
: '暂无上下文'
setMessages(m => [...m, { role: 'user', content: question }, { role: 'assistant', content: '', streaming: true }])
setTimeout(() => {
stream(answer, (partial, done) => {
setMessages(m => {
const next = [...m]
next[next.length - 1] = { role: 'assistant', content: partial, streaming: !done }
return next
})
if (done) setBusy(false)
})
}, 400)
}
const title = state.kind === 'project' ? '项目 AI 分析' : '基于本次搜索提问'
const subtitle = state.kind === 'project' && project
? `${project.region} · ${project.purchaser}`
: state.kind === 'search' && batch
? conditionsText(batch.conditions)
: ''
return (
<AnimatePresence>
{open && (
<div className="fixed inset-0 z-50" role="dialog" aria-label={title}>
<motion.div className="absolute inset-0 bg-ink-900/20 backdrop-blur-sm"
initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: 0.15 }}
onClick={onClose} />
<motion.aside
className="absolute right-0 top-0 flex h-full w-[600px] max-w-[94vw] flex-col border-l border-line-soft bg-white shadow-card-hover"
initial={{ x: 60, opacity: 0 }} animate={{ x: 0, opacity: 1 }} exit={{ x: 60, opacity: 0 }}
transition={{ duration: 0.22, ease: 'easeOut' }}>
{/* 头部:项目名称与操作(加入重点关注不单独占行) */}
<header className="flex items-start gap-2 border-b border-line-soft px-4 py-3">
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-ctrl"
style={{ background: 'linear-gradient(135deg, #6366F1 0%, #818CF8 100%)' }}>
<Sparkles size={16} className="text-white" />
</div>
<div className="min-w-0 flex-1">
<div className="text-[13px] text-ink-400">{title}</div>
<h2 className="truncate text-[15px] font-bold leading-snug" title={project?.name ?? ''}>
{state.kind === 'project' ? project?.name : '围绕当前检索结果提问'}
</h2>
<div className="mt-0.5 truncate text-xs text-ink-400">{subtitle}</div>
{state.kind === 'project' && project && (
<div className="mt-1">
{project.sourceUrl ? (
<a href={project.sourceUrl} target="_blank" rel="noreferrer"
className="inline-flex items-center gap-1 text-xs text-brand-500 hover:underline">
<ExternalLink size={12} /> 查看公告原文({project.sourceName})
</a>
) : (
<span className="text-xs text-ink-400">来源:{project.sourceName}(链接暂未收录)</span>
)}
</div>
)}
</div>
{state.kind === 'project' && project && (
isWatched(project.id) ? (
<button onClick={() => removeWatch(project.id)}
className="mt-1 inline-flex shrink-0 items-center gap-1 rounded-full bg-brand-50 px-2.5 py-1.5 text-xs font-medium text-brand-500 transition-colors hover:bg-brand-100">
<Star size={13} fill="currentColor" /> 已关注
</button>
) : (
<button onClick={() => addWatch(project.id)}
className="mt-1 inline-flex shrink-0 items-center gap-1 rounded-full border border-brand-500/50 px-2.5 py-1.5 text-xs font-medium text-brand-500 transition-colors hover:bg-brand-50">
<Star size={13} /> 加入重点关注
</button>
)
)}
<button onClick={onClose} className="mt-1 shrink-0 rounded-full p-1.5 text-ink-400 transition-colors hover:bg-[#F4F7FB]" aria-label="关闭">
<X size={16} />
</button>
</header>
{/* 消息区 */}
<div ref={scrollRef} className="flex-1 space-y-4 overflow-y-auto bg-canvas px-4 py-3 scrollbar-thin">
{messages.map((m, i) => (
<div key={i} className={m.role === 'user' ? 'flex justify-end' : ''}>
{m.role === 'user' ? (
<div className="max-w-[85%] rounded-2xl rounded-br-sm bg-brand-500 px-3.5 py-2 text-[14px] text-white shadow-[0_2px_8px_rgba(99,102,241,.25)]">{m.content}</div>
) : (
<div className="max-w-full rounded-card rounded-tl-sm border border-line-soft bg-white px-3.5 py-2.5 shadow-card">
<Markdown text={m.content} streaming={m.streaming} />
</div>
)}
</div>
))}
{busy && messages[messages.length - 1]?.role === 'user' && (
<div className="flex items-center gap-2 text-[13px] text-ink-400">
<Loader2 size={14} className="animate-spin text-brand-500" /> 正在分析…
</div>
)}
</div>
{/* 快捷问题 + 输入区(紧凑排列) */}
<footer className="border-t border-line-soft bg-white px-3 pb-3 pt-2">
<div className="mb-2 flex flex-wrap gap-1.5">
{(state.kind === 'project' ? PROJECT_QUICK : SEARCH_QUICK).map(q => (
<button key={q} disabled={busy} onClick={() => ask(q)}
className="rounded-full border border-line-soft px-2.5 py-1 text-xs text-ink-600 transition-colors hover:border-brand-500/40 hover:text-brand-500 disabled:opacity-50">
{q}
</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={state.kind === 'project' ? '围绕这个项目继续追问…' : '围绕本次检索结果提问…'}
className="max-h-28 flex-1 resize-none rounded-ctrl border border-line-soft px-3 py-2 text-[14px] 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"
/>
<button onClick={() => ask(input)} disabled={!input.trim() || busy}
className={cn('rounded-full bg-brand-500 p-2.5 text-white shadow-[0_2px_8px_rgba(99,102,241,.25)] transition-colors hover:bg-brand-600 disabled:opacity-40')}
aria-label="发送">
<Send size={16} />
</button>
</div>
<div className="mt-1.5 text-[11px] text-ink-400">
AI 分析供参考,是否跟进、报名或投标由你决定 · 上下文时间 <span className="font-num">{nowStr().slice(0, 10)}</span>
</div>
</footer>
</motion.aside>
</div>
)}
</AnimatePresence>
)
}
import React, { useMemo } from 'react'
// 轻量 Markdown 渲染:支持标题、加粗、列表、表格、引用、分隔线、行内代码
function renderInline(text: string): React.ReactNode[] {
const nodes: React.ReactNode[] = []
let rest = text
let key = 0
while (rest) {
const m = rest.match(/\*\*([^*]+)\*\*|`([^`]+)`/)
if (!m) { nodes.push(rest); break }
const idx = m.index ?? 0
if (idx > 0) nodes.push(rest.slice(0, idx))
if (m[1] !== undefined) nodes.push(<strong key={key++}>{m[1]}</strong>)
else nodes.push(<code key={key++}>{m[2]}</code>)
rest = rest.slice(idx + m[0].length)
}
return nodes
}
export function Markdown({ text, streaming }: { text: string; streaming?: boolean }) {
const blocks = useMemo(() => {
const lines = text.split('\n')
const out: React.ReactNode[] = []
let i = 0
let key = 0
while (i < lines.length) {
const line = lines[i]
// 表格
if (line.trim().startsWith('|') && i + 1 < lines.length && /^\|[\s:|-]+\|/.test(lines[i + 1].trim())) {
const header = line.trim().slice(1, -1).split('|').map(s => s.trim())
const rows: string[][] = []
i += 2
while (i < lines.length && lines[i].trim().startsWith('|')) {
rows.push(lines[i].trim().slice(1, -1).split('|').map(s => s.trim()))
i++
}
out.push(
<table key={key++}>
<thead><tr>{header.map((h, j) => <th key={j}>{renderInline(h)}</th>)}</tr></thead>
<tbody>{rows.map((r, ri) => <tr key={ri}>{r.map((c, ci) => <td key={ci}>{renderInline(c)}</td>)}</tr>)}</tbody>
</table>
)
continue
}
// 无序列表
if (/^\s*-\s+/.test(line)) {
const items: string[] = []
while (i < lines.length && /^\s*-\s+/.test(lines[i])) {
items.push(lines[i].replace(/^\s*-\s+/, ''))
i++
}
out.push(<ul key={key++}>{items.map((it, j) => <li key={j}>{renderInline(it)}</li>)}</ul>)
continue
}
// 有序列表
if (/^\s*\d+\.\s+/.test(line)) {
const items: string[] = []
while (i < lines.length && /^\s*\d+\.\s+/.test(lines[i])) {
items.push(lines[i].replace(/^\s*\d+\.\s+/, ''))
i++
}
out.push(<ol key={key++}>{items.map((it, j) => <li key={j}>{renderInline(it)}</li>)}</ol>)
continue
}
// 标题
const h3 = line.match(/^###\s+(.*)/)
if (h3) { out.push(<h3 key={key++}>{renderInline(h3[1])}</h3>); i++; continue }
const h4 = line.match(/^####\s+(.*)/)
if (h4) { out.push(<h4 key={key++}>{renderInline(h4[1])}</h4>); i++; continue }
// 引用(用作提示块)
if (/^>\s?/.test(line)) {
const buf: string[] = []
while (i < lines.length && /^>\s?/.test(lines[i])) {
buf.push(lines[i].replace(/^>\s?/, ''))
i++
}
out.push(<div key={key++} className="md-note">{buf.map((b, j) => <p key={j}>{renderInline(b)}</p>)}</div>)
continue
}
// 分隔线
if (/^---+$/.test(line.trim())) { out.push(<hr key={key++} />); i++; continue }
// 空行
if (!line.trim()) { i++; continue }
// 普通段落
out.push(<p key={key++}>{renderInline(line)}</p>)
i++
}
return out
}, [text])
return <div className={`md-body${streaming ? ' stream-caret' : ''}`}>{blocks}</div>
}
import { useState } from 'react'
import { Plus, Play, Pencil, Trash2, X, Layers } from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
import type { ScheduleTask, SearchConditions } from '../types'
import { useStore, conditionsText, uid, nowStr } from '../lib/store'
import { PrimaryButton, GhostButton } from './ui-ext/AiButton'
import { cn } from '@/lib/utils'
interface Props {
currentConditions: SearchConditions
/** 任务列表弹窗是否打开(列表不占首页版面) */
open: boolean
onClose: () => void
}
const emptyTaskForm = (conds: SearchConditions, n: number) => ({
name: `方案${n}`,
conditions: { ...conds },
})
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'
export function ScheduleTasks({ currentConditions, open, onClose }: Props) {
const { tasks, saveTask, deleteTask, runTaskNow } = useStore()
const [editing, setEditing] = useState<ScheduleTask | null>(null)
const [showModal, setShowModal] = useState(false)
const [form, setForm] = useState(() => emptyTaskForm(currentConditions, tasks.length + 1))
const [confirmDelete, setConfirmDelete] = useState<string | null>(null)
const openCreate = () => {
setEditing(null)
setForm(emptyTaskForm(currentConditions, tasks.length + 1))
setShowModal(true)
}
const openEdit = (t: ScheduleTask) => {
setEditing(t)
setForm({ name: t.name, conditions: { ...t.conditions } })
setShowModal(true)
}
const submit = () => {
if (!form.name.trim()) return
if (editing) {
saveTask({ ...editing, name: form.name.trim(), conditions: form.conditions })
} else {
// 检索方案不再包含定时设置;保留字段默认值仅作数据兼容
saveTask({
id: uid('task'), name: form.name.trim(), frequency: 'daily', time: '09:15',
conditions: form.conditions, createdAt: nowStr(), runs: [],
})
}
setShowModal(false)
}
return (
<>
{/* 检索方案列表:以弹窗承载,不在首页占位;点检索区「检索方案」打开 */}
<AnimatePresence>
{open && (
<motion.div className="fixed inset-0 z-40 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) onClose() }}>
<motion.div
className="max-h-[85vh] w-[720px] max-w-[94vw] overflow-y-auto rounded-card border border-line-soft bg-white 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 gap-2 border-b border-line-soft px-5 py-3">
<Layers size={16} className="text-brand-500" />
<span className="text-[14px] font-semibold text-ink-900">检索方案</span>
<span className="text-xs text-ink-400"><span className="font-num">{tasks.length}</span> 个已保存的方案</span>
<span className="flex-1" />
<PrimaryButton onClick={openCreate} className="!px-3 !py-1.5 text-xs">
<Plus size={13} /> 新建方案
</PrimaryButton>
<button onClick={onClose} className="rounded-full p-1.5 text-ink-400 hover:bg-[#F4F7FB]"><X size={16} /></button>
</div>
{tasks.length === 0 ? (
<div className="px-5 py-10 text-center text-[13px] text-ink-400">
还没有检索方案,点右上角「新建方案」,把常用的检索条件存下来一键复用
</div>
) : (
<ul className="divide-y divide-line-soft/70">
{tasks.map(t => {
const last = t.runs[0]
return (
<li key={t.id} className="flex items-center gap-3 px-5 py-2.5">
<span className="shrink-0 text-[13px] font-medium text-ink-900">{t.name}</span>
<span className="min-w-0 flex-1 truncate text-xs text-ink-400" title={conditionsText(t.conditions)}>{conditionsText(t.conditions)}</span>
{last ? (
<span className="shrink-0 whitespace-nowrap text-xs text-ink-400">
最近执行 <span className="font-num">{last.time}</span> ·{' '}
{last.status === 'success'
? <span className="text-ok-500">{last.count} 条结果</span>
: <span className="text-bad-500">失败:{last.error ?? '未知原因'}</span>}
</span>
) : (
<span className="shrink-0 whitespace-nowrap text-xs text-ink-400">尚未执行</span>
)}
<button onClick={() => runTaskNow(t.id)} title="按这组条件立即执行一次"
className="shrink-0 rounded-full p-1.5 text-brand-500 transition-colors hover:bg-brand-50"><Play size={14} /></button>
<button onClick={() => openEdit(t)} title="编辑"
className="shrink-0 rounded-full p-1.5 text-ink-400 transition-colors hover:bg-[#F4F7FB] hover:text-brand-500"><Pencil size={14} /></button>
<button onClick={() => setConfirmDelete(t.id)} title="删除"
className="shrink-0 rounded-full p-1.5 text-ink-400 transition-colors hover:bg-bad-500/10 hover:text-bad-500"><Trash2 size={14} /></button>
</li>
)
})}
</ul>
)}
</motion.div>
</motion.div>
)}
</AnimatePresence>
{/* 创建 / 编辑检索方案窗口 */}
<AnimatePresence>
{showModal && (
<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) setShowModal(false) }}>
<motion.div
className="max-h-[85vh] w-[520px] 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="mb-3 flex items-center justify-between">
<h3 className="text-[16px] font-bold">{editing ? '编辑检索方案' : '新建检索方案'}</h3>
<button onClick={() => setShowModal(false)} className="rounded-full p-1.5 text-ink-400 hover:bg-[#F4F7FB]"><X size={16} /></button>
</div>
<div className="space-y-3">
<div>
<label className="text-[13px] font-medium text-ink-900">方案名称</label>
<input value={form.name} onChange={e => setForm(f => ({ ...f, name: e.target.value }))}
className={cn(inputCls, 'mt-1 w-full')} />
</div>
<div className="space-y-2 rounded-ctrl border border-line-soft bg-canvas p-3">
<div className="text-[13px] font-semibold text-brand-500">检索条件</div>
<div className="grid grid-cols-2 gap-2">
<input placeholder="关键词" value={form.conditions.keyword}
onChange={e => setForm(f => ({ ...f, conditions: { ...f.conditions, keyword: e.target.value } }))}
className={cn(inputCls, '!py-1.5 text-[13px]')} />
<input placeholder="地区(如:浙江)" value={form.conditions.region}
onChange={e => setForm(f => ({ ...f, conditions: { ...f.conditions, region: e.target.value } }))}
className={cn(inputCls, '!py-1.5 text-[13px]')} />
<input placeholder="预算下限(万元)" type="number" value={form.conditions.budgetMin}
onChange={e => setForm(f => ({ ...f, conditions: { ...f.conditions, budgetMin: e.target.value } }))}
className={cn(inputCls, '!py-1.5 font-num text-[13px]')} />
<input placeholder="预算上限(万元)" type="number" value={form.conditions.budgetMax}
onChange={e => setForm(f => ({ ...f, conditions: { ...f.conditions, budgetMax: e.target.value } }))}
className={cn(inputCls, '!py-1.5 font-num text-[13px]')} />
<select value={form.conditions.publishRange}
onChange={e => setForm(f => ({ ...f, conditions: { ...f.conditions, publishRange: e.target.value as SearchConditions['publishRange'] } }))}
className={cn(inputCls, 'col-span-2 !py-1.5 text-[13px]')}>
<option value="7d">发布于近 7 天</option>
<option value="30d">发布于近 30 天</option>
<option value="90d">发布于近 90 天</option>
<option value="all">全部时间</option>
</select>
</div>
</div>
</div>
<div className="mt-4 flex justify-end gap-2">
<GhostButton onClick={() => setShowModal(false)}>取消</GhostButton>
<PrimaryButton onClick={submit} disabled={!form.name.trim()}>
{editing ? '保存修改' : '保存方案'}
</PrimaryButton>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>
{/* 删除确认 */}
<AnimatePresence>
{confirmDelete && (
<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) setConfirmDelete(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={() => setConfirmDelete(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 text-[13px] text-ink-400">删除后不可恢复,历史执行记录将一并删除。</p>
<div className="mt-4 flex justify-center gap-2">
<GhostButton onClick={() => setConfirmDelete(null)}>取消</GhostButton>
<PrimaryButton onClick={() => { deleteTask(confirmDelete); setConfirmDelete(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>
</>
)
}
import { useState } from 'react'
import { NavLink, useLocation, useNavigate } from 'react-router'
import { Compass, Star, MessagesSquare, Building2, Plus, Pencil, Trash2, Search, LogOut, X } from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
import { cn } from '@/lib/utils'
import { useStore } from '@/lib/store'
import Pill from '@/components/ui-ext/Pill'
import { GhostButton, PrimaryButton } from '@/components/ui-ext/AiButton'
const NAV = [
{ to: '/', label: '发现商机', icon: Compass, end: true },
{ to: '/watch', label: '重点关注', icon: Star },
{ to: '/research', label: '对话调研', icon: MessagesSquare },
{ to: '/profile', label: '公司档案', icon: Building2 },
]
export default function Sidebar({ onLogout }: { onLogout: () => void }) {
const { profile, watch, research, saveConversation, deleteConversation } = useStore()
const location = useLocation()
const navigate = useNavigate()
const [renaming, setRenaming] = useState<string | null>(null)
const [renameText, setRenameText] = useState('')
const [histQuery, setHistQuery] = useState('')
const [confirmDelete, setConfirmDelete] = useState<string | null>(null)
const researchOpen = location.pathname === '/research'
const filtered = research.filter(c => !histQuery.trim() || c.title.includes(histQuery.trim()))
const submitRename = (id: string) => {
const c = research.find(x => x.id === id)
if (c && renameText.trim()) saveConversation({ ...c, title: renameText.trim() })
setRenaming(null)
}
return (
<aside className="flex h-[100dvh] w-60 shrink-0 flex-col bg-sidebar">
{/* Logo 区 */}
<div className="px-5 pb-5 pt-6">
<div className="text-[16px] font-bold text-ink-900">如昼商机助手</div>
<div className="text-xs text-ink-400">水行业招投标商机平台</div>
</div>
{/* 导航 */}
<nav className={cn('space-y-1 px-3', !researchOpen && 'flex-1 overflow-y-auto scrollbar-thin')}>
{NAV.map(item => (
<NavLink
key={item.to}
to={item.to}
end={item.end}
className={({ isActive }) =>
cn(
'relative flex items-center gap-3 rounded-ctrl px-3 py-2.5 text-sm transition-colors duration-150',
isActive ? 'bg-brand-50 font-medium text-brand-500' : 'text-ink-600 hover:bg-white',
)
}
>
{({ isActive }) => (
<>
{isActive && (
<span className="absolute left-0 top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-full bg-brand-500" />
)}
<item.icon size={20} strokeWidth={isActive ? 2.2 : 1.8} />
<span className="flex-1">{item.label}</span>
{item.to === '/watch' && watch.length > 0 && (
<span className="rounded-full bg-brand-50 px-2 py-0.5 text-xs font-num font-bold text-brand-500">{watch.length}</span>
)}
{item.to === '/profile' && (
<Pill status={profile.completed ? '已完善' : '未完善'} />
)}
</>
)}
</NavLink>
))}
</nav>
{/* 对话调研:导航栏下半部分展开最近对话 */}
{researchOpen && (
<div className="flex min-h-0 flex-1 flex-col border-t border-line-soft/60 fade-up">
<div className="flex items-center justify-between px-4 pt-3">
<span className="text-xs font-medium text-ink-900">最近对话</span>
<button onClick={() => navigate('/research?new=1')}
className="inline-flex items-center gap-1 rounded-full border border-line-soft px-2.5 py-1 text-[11px] text-ink-600 transition-colors hover:border-brand-500/40 hover:text-brand-500">
<Plus size={11} /> 新建对话
</button>
</div>
<div className="px-3 pt-2">
<div className="relative">
<Search size={12} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-400" />
<input value={histQuery} onChange={e => setHistQuery(e.target.value)} placeholder="搜索对话"
className="w-full rounded-full border border-line-soft bg-white py-1.5 pl-7 pr-2 text-[12px] text-ink-900 outline-none placeholder:text-ink-400 focus:border-brand-500/60" />
</div>
</div>
<div className="mt-1 flex-1 space-y-0.5 overflow-y-auto px-2 pb-2 scrollbar-thin">
{filtered.length === 0 ? (
<p className="px-3 py-6 text-center text-[11px] leading-relaxed text-ink-400">
{histQuery ? '没有匹配的对话' : '开始一次探索,对话会保存在这里'}
</p>
) : filtered.map(c => (
<div key={c.id}
className="group flex cursor-pointer items-center gap-0.5 rounded-ctrl px-2 py-1.5 text-[12px] text-ink-600 transition-colors hover:bg-white"
onClick={() => navigate(`/research?conv=${c.id}`)}>
{renaming === c.id ? (
<input autoFocus value={renameText} onChange={e => setRenameText(e.target.value)}
onClick={e => e.stopPropagation()}
onKeyDown={e => { if (e.key === 'Enter') submitRename(c.id); if (e.key === 'Escape') setRenaming(null) }}
onBlur={() => submitRename(c.id)}
className="min-w-0 flex-1 rounded border border-brand-500 px-1.5 py-0.5 text-[12px] outline-none" />
) : (
<>
<span className="min-w-0 flex-1 truncate">{c.title}</span>
<button onClick={e => { e.stopPropagation(); setRenaming(c.id); setRenameText(c.title) }}
className="rounded p-0.5 opacity-0 transition-opacity hover:bg-white group-hover:opacity-100" title="重命名">
<Pencil size={11} />
</button>
<button onClick={e => { e.stopPropagation(); setConfirmDelete(c.id) }}
className="rounded p-0.5 text-bad-500 opacity-0 transition-opacity hover:bg-white group-hover:opacity-100" title="删除">
<Trash2 size={11} />
</button>
</>
)}
</div>
))}
</div>
</div>
)}
{/* 用户区 */}
<div className="border-t border-line-soft/60 px-5 py-3">
<div className="flex items-center gap-3">
<img src="/avatar-user.png" alt="用户头像" className="h-9 w-9 rounded-full ring-2 ring-brand-50" />
<div className="min-w-0 flex-1">
<div className="truncate text-sm font-medium text-ink-900">张晨</div>
<div className="text-xs text-ink-400">商务拓展</div>
</div>
<button onClick={onLogout} title="退出登录"
className="rounded-full p-1.5 text-ink-400 transition-colors hover:bg-bad-500/10 hover:text-bad-500">
<LogOut size={15} />
</button>
</div>
</div>
{/* 删除对话确认 */}
<AnimatePresence>
{confirmDelete && (
<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) setConfirmDelete(null) }}>
<motion.div className="relative w-[360px] 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={() => setConfirmDelete(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 truncate text-[13px] text-ink-400" title={research.find(x => x.id === confirmDelete)?.title}>
「{research.find(x => x.id === confirmDelete)?.title}」
</p>
<p className="mt-0.5 text-[13px] text-ink-400">删除后将无法恢复。</p>
<div className="mt-4 flex justify-center gap-2">
<GhostButton onClick={() => setConfirmDelete(null)}>再想想</GhostButton>
<PrimaryButton onClick={() => { deleteConversation(confirmDelete); setConfirmDelete(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>
</aside>
)
}
import { useEffect, useState } from 'react'
import { useLocation } from 'react-router'
const PAGE_META: Record<string, { title: string; sub: string }> = {
'/': { title: '发现商机', sub: '检索招投标项目,浏览事实与简要分析' },
'/watch': { title: '重点关注', sub: '记录跟进情况,回看公告与继续分析' },
'/research': { title: '对话调研', sub: '研究客户、竞争对手与区域市场' },
'/profile': { title: '公司档案', sub: '让建议贴合公司实际能力' },
}
export default function Topbar() {
const { pathname } = useLocation()
const meta = PAGE_META[pathname] ?? PAGE_META['/']
const [now, setNow] = useState(new Date())
useEffect(() => {
const t = window.setInterval(() => setNow(new Date()), 30000)
return () => window.clearInterval(t)
}, [])
const p = (n: number) => String(n).padStart(2, '0')
return (
<header className="sticky top-0 z-40 flex h-16 items-center gap-5 border-b border-line-soft/50 bg-white/80 px-4 backdrop-blur-md sm:px-6 xl:px-8">
<div className="min-w-0">
<h1 className="text-xl font-semibold leading-tight text-ink-900">{meta.title}</h1>
<p className="text-xs text-ink-400 max-sm:hidden">{meta.sub}</p>
</div>
<div className="flex-1" />
<div className="hidden items-center gap-2 text-xs text-ink-400 sm:flex">
<span className="font-num">
北京时间 {now.getFullYear()}-{p(now.getMonth() + 1)}-{p(now.getDate())} {p(now.getHours())}:{p(now.getMinutes())}
</span>
</div>
</header>
)
}
import { forwardRef } from 'react'
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import { motion } from 'framer-motion'
import { Sparkles, Loader2 } from 'lucide-react'
import { cn } from '@/lib/utils'
interface AiButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode
loading?: boolean
/** 隐藏左侧 sparkle 图标 */
noIcon?: boolean
}
/** 渐变 AI 按钮:白底 + 渐变描边 + 渐变文字,全站 AI 能力入口统一视觉 */
const AiButton = forwardRef<HTMLButtonElement, AiButtonProps>(
({ children, loading, noIcon, className, ...props }, ref) => {
return (
<motion.button
ref={ref}
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
{...(props as object)}
className={cn(
'border-brand-gradient inline-flex items-center gap-1.5 rounded-ctrl px-4 py-2 text-sm font-medium',
'shadow-card transition-shadow duration-200 hover:shadow-card-hover',
'disabled:cursor-not-allowed disabled:opacity-60',
className,
)}
>
{loading ? (
<Loader2 size={15} className="animate-spin text-brand-500" />
) : (
!noIcon && <Sparkles size={15} className="text-brand-500" />
)}
<span className="text-brand-gradient">{children}</span>
</motion.button>
)
},
)
AiButton.displayName = 'AiButton'
export default AiButton
/** 主按钮:蓝底白字,hover 微放大,带 Loading 态 */
export function PrimaryButton({
children,
loading,
className,
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & { loading?: boolean }) {
return (
<motion.button
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
{...(props as object)}
className={cn(
'inline-flex items-center justify-center gap-1.5 rounded-ctrl bg-brand-500 px-4 py-2 text-sm font-medium text-white',
'shadow-[0_2px_8px_rgba(99,102,241,.25)] transition-colors duration-200 hover:bg-brand-600',
'disabled:cursor-not-allowed disabled:opacity-60',
className,
)}
>
{loading && <Loader2 size={15} className="animate-spin" />}
{children}
</motion.button>
)
}
/** 幽灵按钮:白底 1px 灰边 */
export function GhostButton({
children,
className,
...props
}: ButtonHTMLAttributes<HTMLButtonElement>) {
return (
<motion.button
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
{...(props as object)}
className={cn(
'inline-flex items-center justify-center gap-1.5 rounded-ctrl border border-line-soft bg-white px-3.5 py-1.5 text-[13px] font-medium text-ink-600',
'transition-colors duration-200 hover:border-brand-500/40 hover:text-brand-500',
className,
)}
>
{children}
</motion.button>
)
}
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