Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
王蔡翾
rz-GB-web
Commits
60f45bfe
Commit
60f45bfe
authored
Nov 13, 2026
by
王蔡翾
Browse files
bug修复
parent
969193af
Changes
8
Show whitespace changes
Inline
Side-by-side
scripts/verify-prototype.mjs
View file @
60f45bfe
...
...
@@ -21,4 +21,8 @@ assert.equal(registrationDate(['报名请查看公告,投标截止2026-11-12']
assert
.
equal
(
registrationReminder
([
'
报名截至2026-11-11
'
],
'
2026-11-11
'
)?.
label
,
'
报名今天截止
'
)
assert
.
equal
(
registrationReminder
([
'
报名结束日期2026-11-14
'
],
'
2026-11-11
'
)?.
label
,
'
报名仅剩 3 天
'
)
assert
.
equal
(
registrationReminder
([
'
报名截至2026-11-10
'
],
'
2026-11-11
'
)?.
label
,
'
报名已截止
'
)
console
.
log
(
'
原型交互数据检查通过(15 项断言)
'
)
const
deadline
=
[
'
报名截止时间:2026年11月11日17:30
'
]
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
,
Date
.
parse
(
'
2026-11-11T17:29:59+08:00
'
))?.
label
,
'
报名今天截止
'
)
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
,
Date
.
parse
(
'
2026-11-11T17:30:00+08:00
'
))?.
label
,
'
报名已截止
'
)
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
)?.
display
,
'
2026-11-11 17:30
'
)
console
.
log
(
'
原型交互数据检查通过(18 项断言)
'
)
src/components/ConversationView.tsx
View file @
60f45bfe
...
...
@@ -49,10 +49,13 @@ export function ConversationView({ id: initialId, scope: initialScope, embedded
pending
.
current
.
conversationId
=
c
.
id
}
const
conv
=
pending
.
current
.
conversationId
await
api
(
`/conversations/
${
conv
}
/
${
path
}
`
,
{
method
:
'
POST
'
,
headers
:
{
'
Idempotency-Key
'
:
pending
.
current
.
key
},
body
:
JSON
.
stringify
(
body
)
})
const
task
=
await
api
<
{
id
:
string
}
>
(
`/conversations/
${
conv
}
/
${
path
}
`
,
{
method
:
'
POST
'
,
headers
:
{
'
Idempotency-Key
'
:
pending
.
current
.
key
},
body
:
JSON
.
stringify
(
body
)
})
pending
.
current
=
null
;
setInput
(
''
);
conversationsChanged
()
if
(
id
)
{
setMessages
(
await
api
<
ConversationMessage
[]
>
(
`/conversations/
${
id
}
/messages`
))
// POST 已在同一事务保存消息和任务。立即订阅新任务,避免额外的历史 GET 失败时吞掉本轮。
setMessages
(
rows
=>
rows
.
some
(
row
=>
row
.
task_id
===
task
.
id
)
?
rows
:
[...
rows
,
{
id
:
task
.
id
,
task_id
:
task
.
id
,
role
:
'
user
'
,
content
:
raw
.
trim
(),
created_at
:
new
Date
().
toISOString
(),
}])
}
else
if
(
embedded
)
setId
(
conv
)
else
navigate
(
`/research?conv=
${
conv
}
`
,
{
replace
:
true
})
}
catch
(
e
)
{
setError
(
message
(
e
))
}
finally
{
inFlight
.
current
=
false
;
setBusy
(
false
)
}
...
...
src/components/OpportunityTable.tsx
View file @
60f45bfe
...
...
@@ -7,6 +7,7 @@ import { useStore } from '../lib/store'
import
{
defaultMatchDimNames
}
from
'
../types
'
import
type
{
AnalysisPanelState
}
from
'
./AiPanel
'
import
{
ProjectTags
}
from
'
./ProjectTags
'
import
{
PrototypeDialog
}
from
'
./PrototypeDialog
'
import
{
GhostButton
}
from
'
./ui-ext/AiButton
'
const
PAGE_SIZE
=
8
...
...
@@ -26,7 +27,7 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
if
(
saving
)
return
setSaving
(
true
);
setError
(
''
)
try
{
//
星标切换关注状态;标签使用独立触发器,保存关注后仍可就地打标签
。
//
关注已落库才打开标签窗口,窗口独立于星标和表格滚动容器
。
if
(
isWatched
(
id
))
{
await
removeWatch
(
id
);
setTagProject
(
null
)
}
else
{
await
addWatch
(
id
);
setTagProject
(
id
)
}
}
...
...
@@ -36,30 +37,33 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
{
error
&&
<
p
role
=
"alert"
className
=
"px-5 py-2 text-xs text-bad-500"
>
{
error
}
</
p
>
}
<
div
className
=
"overflow-x-auto"
><
table
className
=
"w-full min-w-[940px] table-fixed text-left text-[13px]"
>
<
colgroup
>
{
[
27
,
13
,
9
,
16
,
16
,
6
,
13
].
map
((
width
,
i
)
=>
<
col
key
=
{
i
}
style
=
{
{
width
:
`
${
width
}
%`
}
}
/>)
}
</
colgroup
>
<
thead
><
tr
className
=
"border-b border-line-soft bg-[#FAFBFD] text-ink-400"
>
{
[
'
项目与建设内容
'
,
'
招标方与地域
'
,
'
预算
'
,
'
时间节奏
'
,
'
资质与业绩
门槛
'
,
'
匹配度
'
,
'
操作
'
].
map
((
name
,
i
)
=>
<
th
key
=
{
name
}
className
=
{
i
===
0
?
'
px-5 py-2.5 font-medium
'
:
'
px-3 py-2.5 font-medium
'
}
>
{
name
}
</
th
>)
}
</
tr
></
thead
>
<
thead
><
tr
className
=
"border-b border-line-soft bg-[#FAFBFD] text-ink-400"
>
{
[
'
项目与建设内容
'
,
'
招标方与地域
'
,
'
预算
'
,
'
时间节奏
'
,
'
参与
门槛
'
,
'
匹配度
'
,
'
操作
'
].
map
((
name
,
i
)
=>
<
th
key
=
{
name
}
className
=
{
i
===
0
?
'
px-5 py-2.5 font-medium
'
:
'
px-3 py-2.5 font-medium
'
}
>
{
name
}
</
th
>)
}
</
tr
></
thead
>
<
tbody
>
{
rows
.
map
(
item
=>
{
const
p
=
item
.
facts
,
summary
=
item
.
analysis
?.
summary
,
match
=
item
.
analysis
?.
match
const
reminder
=
registrationReminder
(
summary
?.
schedule
)
const
construction
=
summary
?.
con
struction
.
startsWith
(
'
未取得正文
'
)
?
p
.
products
.
join
(
'
、
'
)
:
summary
?.
construction
||
p
.
products
.
join
(
'
、
'
)
const
construction
=
summary
?.
con
clusion
?.
construction
||
summary
?.
construction
||
p
.
products
.
join
(
'
、
'
)
||
(
p
.
title
?
`标题线索 ·
${
p
.
title
}
`
:
'
项目建设内容待核验
'
)
const
qualifications
=
summary
?.
qualifications
??
[]
// 同一行尽量兼顾资质与业绩,不让多个同类条款把另一项挤出列表。
const
requirements
=
[...
new
Set
([
qualifications
.
find
(
line
=>
/资质|资格|许可证|认证|承包/
.
test
(
line
)),
qualifications
.
find
(
line
=>
line
.
includes
(
'
业绩
'
))].
filter
(
Boolean
))]
const
timing
=
summary
?.
schedule
.
find
(
line
=>
/工期|交付|服务期/
.
test
(
line
))
const
timing
=
summary
?.
conclusion
?.
timing
||
summary
?.
schedule
.
find
(
line
=>
/工期|交付|服务期
|开标|投标截止
/
.
test
(
line
))
const
watched
=
isWatched
(
p
.
id
)
return
<
tr
key
=
{
p
.
id
}
onClick
=
{
()
=>
open
(
item
)
}
className
=
"cursor-pointer border-b border-line-soft/70 align-top transition-colors last:border-0 hover:bg-brand-50/40"
>
<
td
className
=
"px-5 py-3"
><
a
href
=
{
p
.
url
??
undefined
}
target
=
"_blank"
rel
=
"noreferrer"
onClick
=
{
e
=>
{
e
.
stopPropagation
();
if
(
!
p
.
url
)
open
(
item
)
}
}
className
=
"inline-flex items-start gap-1 font-medium leading-snug text-ink-900 hover:text-brand-500 hover:underline"
><
span
>
{
p
.
title
||
'
标题待核验
'
}
</
span
>
{
p
.
url
&&
<
ExternalLink
size
=
{
12
}
className
=
"mt-1 shrink-0 text-ink-400"
/>
}
</
a
><
p
className
=
"mt-1
line-clamp-3
text-xs leading-relaxed text-ink-600"
title
=
{
construction
||
undefined
}
><
span
className
=
"font-medium"
>
建设内容
</
span
>
·
{
construction
||
'
公告摘要未披露
'
}
</
p
></
td
>
<
td
className
=
"px-3 py-3"
><
div
className
=
"leading-snug"
>
{
p
.
purchaser
||
'
待核验
'
}
</
div
><
div
className
=
"mt-1 text-xs text-ink-600"
>
地域 ·
{
summary
?.
region
||
p
.
region
||
'
未披露
'
}
</
div
></
td
>
<
td
className
=
"px-5 py-3"
><
a
href
=
{
p
.
url
??
undefined
}
target
=
"_blank"
rel
=
"noreferrer"
onClick
=
{
e
=>
{
e
.
stopPropagation
();
if
(
!
p
.
url
)
open
(
item
)
}
}
className
=
"inline-flex items-start gap-1 font-medium leading-snug text-ink-900 hover:text-brand-500 hover:underline"
><
span
>
{
p
.
title
||
'
标题待核验
'
}
</
span
>
{
p
.
url
&&
<
ExternalLink
size
=
{
12
}
className
=
"mt-1 shrink-0 text-ink-400"
/>
}
</
a
><
p
className
=
"mt-1
break-words
text-xs leading-relaxed text-ink-600"
><
span
className
=
"font-medium"
>
建设内容
</
span
>
·
{
construction
}
</
p
></
td
>
<
td
className
=
"px-3 py-3"
><
div
className
=
"leading-snug"
>
{
p
.
purchaser
||
'
待核验
'
}
</
div
><
div
className
=
"mt-1 text-xs text-ink-600"
>
地域 ·
{
summary
?.
conclusion
?.
region
||
summary
?.
region
||
p
.
region
||
'
项目地域待核验
'
}
</
div
></
td
>
<
td
className
=
"whitespace-nowrap px-3 py-3"
>
{
p
.
budgetWan
==
null
?
<
span
className
=
"text-ink-400"
>
未披露
</
span
>
:
<
span
className
=
"font-num font-bold"
>
{
p
.
budgetWan
.
toLocaleString
()
}
<
span
className
=
"text-xs font-medium text-ink-400"
>
万元
</
span
></
span
>
}
</
td
>
<
td
className
=
"px-3 py-3 text-xs"
><
p
className
=
{
`font-semibold
${
reminder
&&
reminder
.
days
>=
0
&&
reminder
.
days
<=
7
?
'
text-bad-500
'
:
'
text-ink-600
'
}
`
}
>
{
reminder
?.
label
??
'
报名截止
未披露
'
}
</
p
>
{
reminder
&&
<
time
className
=
"mt-1 block font-num text-ink-600"
dateTime
=
{
reminder
.
date
}
>
{
reminder
.
d
ate
}
</
time
>
}{
timing
&&
<
p
className
=
"mt-1
line-clamp-2
text-ink-600"
title
=
{
timing
}
>
{
timing
}
</
p
>
}
<
p
className
=
"mt-1 font-num text-ink-400"
>
发布
{
p
.
publishDate
||
'
未知
'
}
</
p
></
td
>
<
td
className
=
"px-3 py-3 text-xs leading-relaxed text-ink-600"
>
{
(
requirements
.
length
?
requirements
:
qualifications
.
slice
(
0
,
1
)
).
map
((
line
,
i
)
=>
<
p
key
=
{
i
}
className
=
"mb-1
line-clamp-3"
title
=
{
line
}
>
{
line
}
</
p
>)
}{
!
qualifications
.
length
&&
'
公告摘要未披露
'
}
</
td
>
<
td
className
=
"px-3 py-3 text-xs"
><
p
className
=
{
`font-semibold
${
reminder
&&
reminder
.
days
>=
0
&&
reminder
.
days
<=
7
?
'
text-bad-500
'
:
'
text-ink-600
'
}
`
}
>
{
reminder
?.
label
??
'
报名截止
时间待核验
'
}
</
p
>
{
reminder
&&
<
time
className
=
"mt-1 block font-num text-ink-600"
dateTime
=
{
reminder
.
date
Time
}
>
{
reminder
.
d
isplay
}
</
time
>
}{
timing
&&
<
p
className
=
"mt-1
break-words
text-ink-600"
>
{
timing
}
</
p
>
}
<
p
className
=
"mt-1 font-num text-ink-400"
>
发布
{
p
.
publishDate
||
'
未知
'
}
</
p
></
td
>
<
td
className
=
"px-3 py-3 text-xs leading-relaxed text-ink-600"
>
{
summary
?.
conclusion
?.
participation
||
(
(
requirements
.
length
?
requirements
:
qualifications
)
.
slice
(
0
,
2
).
map
((
line
,
i
)
=>
<
p
key
=
{
i
}
className
=
"mb-1
break-words"
>
{
line
}
</
p
>)
)
}{
!
summary
?.
conclusion
?.
participation
&&
!
qualifications
.
length
&&
'
请核对公告中的资格和业绩要求
'
}
</
td
>
<
td
className
=
"px-3 py-3"
><
Popover
.
Root
open
=
{
scoreProject
===
p
.
id
}
onOpenChange
=
{
value
=>
setScoreProject
(
value
?
p
.
id
:
null
)
}
><
Popover
.
Trigger
asChild
><
button
onMouseEnter
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onMouseLeave
=
{
()
=>
setScoreProject
(
null
)
}
onFocus
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onBlur
=
{
()
=>
setScoreProject
(
null
)
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
className
=
"whitespace-nowrap font-num text-[15px] font-bold text-brand-500"
aria
-
label
=
{
`查看
${
p
.
title
}
匹配度构成`
}
>
{
match
?.
score
??
'
—
'
}{
match
?.
score
!=
null
&&
<
span
className
=
"text-xs font-medium text-ink-400"
>
分
</
span
>
}
</
button
></
Popover
.
Trigger
><
Popover
.
Portal
><
Popover
.
Content
onClick
=
{
e
=>
e
.
stopPropagation
()
}
sideOffset
=
{
8
}
className
=
"z-50 w-72 rounded-card border border-line-soft bg-white p-3 shadow-card-hover"
><
h4
className
=
"text-xs font-medium"
>
贴合度打分构成
</
h4
>
{
match
?
<><
ul
className
=
"mt-2 space-y-2"
>
{
Object
.
entries
(
match
.
dimensions
).
map
(([
key
,
dim
])
=>
<
li
key
=
{
key
}
className
=
"text-xs"
><
div
className
=
"flex justify-between"
><
span
>
{
defaultMatchDimNames
[
key
as
keyof
typeof
defaultMatchDimNames
]
??
key
}
· 权重
{
match
.
weights
[
key
]
}
%
</
span
><
b
>
{
dim
.
known
?
`
${
dim
.
score
}
分`
:
'
待核验
'
}
</
b
></
div
><
p
className
=
"mt-0.5 text-[11px] text-ink-400"
>
{
dim
.
basis
}
</
p
></
li
>)
}
</
ul
><
p
className
=
"mt-2 text-[11px] text-ink-400"
>
完整性
{
match
.
completeness
}
% · 档案 v
{
match
.
profileVersion
}
·
{
match
.
limitation
}
</
p
></>
:
<
p
className
=
"mt-2 text-xs text-ink-400"
>
尚无已保存评分,请完善公司档案后重新检索。
</
p
>
}
</
Popover
.
Content
></
Popover
.
Portal
></
Popover
.
Root
></
td
>
<
td
className
=
"whitespace-nowrap px-3 py-3"
><
div
className
=
"flex flex-wrap items-center gap-1.5"
><
button
onClick
=
{
e
=>
{
e
.
stopPropagation
();
open
(
item
)
}
}
className
=
"inline-flex items-center gap-1 rounded-full border-brand-gradient px-2.5 py-1 text-[12px] font-medium shadow-card hover:shadow-card-hover"
><
Sparkles
size
=
{
12
}
className
=
"text-brand-500"
/><
span
className
=
"text-brand-gradient"
>
AI 分析
</
span
></
button
>
<
button
disabled
=
{
saving
}
onClick
=
{
e
=>
{
e
.
stopPropagation
();
void
follow
(
p
.
id
)
}
}
aria
-
pressed
=
{
watched
}
aria
-
label
=
{
watched
?
'
取消重点关注
'
:
'
加入重点关注
'
}
className
=
"rounded-full p-1 text-brand-500 hover:bg-brand-50"
><
Star
size
=
{
15
}
fill
=
{
watched
?
'
currentColor
'
:
'
none
'
}
/></
button
>
{
watched
&&
<
Popover
.
Root
open
=
{
tagProject
===
p
.
id
}
onOpenChange
=
{
value
=>
setTagProject
(
value
?
p
.
id
:
null
)
}
><
Popover
.
Trigger
asChild
>
<
button
onClick
=
{
e
=>
e
.
stopPropagation
()
}
aria
-
label
=
"管理关注标签"
className
=
"rounded-full p-1 text-ink-400 hover:bg-brand-50 hover:text-brand-500"
><
Tag
size
=
{
13
}
/></
button
>
</
Popover
.
Trigger
><
Popover
.
Portal
><
Popover
.
Content
align
=
"end"
sideOffset
=
{
6
}
className
=
"z-50"
onClick
=
{
e
=>
e
.
stopPropagation
()
}
><
ProjectTags
projectId
=
{
p
.
id
}
onClose
=
{
()
=>
setTagProject
(
null
)
}
/></
Popover
.
Content
></
Popover
.
Portal
></
Popover
.
Root
>
}
{
watched
&&
<
button
onClick
=
{
e
=>
{
e
.
stopPropagation
()
;
setTagProject
(
p
.
id
)
}
}
aria
-
label
=
"管理关注标签"
className
=
"rounded-full p-1 text-ink-400 hover:bg-brand-50 hover:text-brand-500"
><
Tag
size
=
{
13
}
/></
button
>
}
</
div
></
td
>
</
tr
>
})
}
</
tbody
>
</
table
></
div
>
{
tagProject
&&
<
PrototypeDialog
open
title
=
"设置关注标签"
onClose
=
{
()
=>
setTagProject
(
null
)
}
className
=
"w-auto"
>
<
div
className
=
"mt-3"
><
ProjectTags
key
=
{
tagProject
}
projectId
=
{
tagProject
}
onClose
=
{
()
=>
setTagProject
(
null
)
}
/></
div
>
</
PrototypeDialog
>
}
{
!
items
.
length
&&
<
div
className
=
"py-16 text-center"
><
SearchEmpty
/></
div
>
}
{
!!
items
.
length
&&
<
div
className
=
"flex flex-wrap items-center gap-3 px-5 py-3 text-[13px] text-ink-400"
><
span
>
第
<
span
className
=
"font-num text-ink-900"
>
{
(
current
-
1
)
*
PAGE_SIZE
+
1
}
–
{
Math
.
min
(
current
*
PAGE_SIZE
,
items
.
length
)
}
</
span
>
条,共
<
span
className
=
"font-num text-ink-900"
>
{
items
.
length
}
</
span
>
条
</
span
><
span
className
=
"flex-1"
/><
GhostButton
disabled
=
{
current
<=
1
}
onClick
=
{
()
=>
setPage
(
current
-
1
)
}
className
=
"!px-2.5 !py-1 text-xs"
><
ChevronLeft
size
=
{
14
}
/>
上一页
</
GhostButton
><
span
className
=
"font-num"
>
第
{
current
}
/
{
totalPages
}
页
</
span
><
GhostButton
disabled
=
{
current
>=
totalPages
}
onClick
=
{
()
=>
setPage
(
current
+
1
)
}
className
=
"!px-2.5 !py-1 text-xs"
>
下一页
<
ChevronRight
size
=
{
14
}
/></
GhostButton
></
div
>
}
</>
...
...
src/components/ResearchSections.tsx
View file @
60f45bfe
import
{
useState
,
type
ReactNode
}
from
'
react
'
import
type
{
ResearchReport
}
from
'
../lib/day3
'
import
type
{
AgentTask
}
from
'
../hooks/useTaskEvents
'
type
RecordData
=
Record
<
string
,
unknown
>
type
Section
=
ResearchReport
[
'
sections
'
][
number
]
...
...
@@ -29,6 +30,11 @@ const company = (data: RecordData) => text(data, 'fullname', 'company_name', 'na
function
linked
(
label
:
string
,
url
:
string
):
ReactNode
{
if
(
!
label
||
!
/^https
?
:
\/\/
/i
.
test
(
url
))
return
label
// 校验浏览器可识别的 HTTP 地址后使用原串,避免重组 URL 时丢失供应商的签名参数。
try
{
const
parsed
=
new
URL
(
url
)
if
(
!
parsed
.
hostname
||
parsed
.
username
||
parsed
.
password
)
return
label
}
catch
{
return
label
}
return
<
a
href
=
{
url
}
target
=
"_blank"
rel
=
"noopener noreferrer"
className
=
"text-brand-500 hover:underline"
>
{
label
}
</
a
>
}
...
...
@@ -75,11 +81,11 @@ function Purchases({ data }: { data: RecordData }) {
}
/** 以已核验记录组织报告。候选表只在待确认时展示,确认后转为所选主体和正式画像。 */
export
function
ResearchSections
({
sections
,
choices
}:
Pick
<
ResearchReport
,
'
sections
'
|
'
choices
'
>
)
{
return
sections
?.
map
(
section
=>
<
ResearchSection
key
=
{
section
.
key
}
section
=
{
section
}
choice
=
{
choices
?.
find
(
item
=>
item
.
key
===
section
.
key
)
}
/>)
export
function
ResearchSections
({
sections
,
choices
,
evidence
}:
Pick
<
ResearchReport
,
'
sections
'
|
'
choices
'
>
&
{
evidence
:
AgentTask
[
'
evidence
'
]
}
)
{
return
sections
?.
map
(
section
=>
<
ResearchSection
key
=
{
section
.
key
}
section
=
{
section
}
choice
=
{
choices
?.
find
(
item
=>
item
.
key
===
section
.
key
)
}
sourceUrl
=
{
evidence
.
find
(
item
=>
item
.
id
===
section
.
evidenceId
&&
item
.
verified
)?.
url
??
''
}
/>)
}
function
ResearchSection
({
section
,
choice
}:
{
section
:
Section
;
choice
?:
ResearchReport
[
'
choices
'
][
number
]
})
{
function
ResearchSection
({
section
,
choice
,
sourceUrl
}:
{
section
:
Section
;
choice
?:
ResearchReport
[
'
choices
'
][
number
]
;
sourceUrl
:
string
})
{
const
data
=
record
(
section
.
data
),
items
=
records
(
data
.
items
),
{
key
,
tool
}
=
section
if
(
choice
?.
selected
)
{
const
selected
=
choice
.
options
.
find
(
option
=>
option
.
id
===
choice
.
selected
)
...
...
@@ -117,8 +123,12 @@ function ResearchSection({ section, choice }: { section: Section; choice?: Resea
[
'
最低
'
,
text
(
stats
,
'
min
'
)],
[
'
最高
'
,
text
(
stats
,
'
max
'
)],
[
'
均价
'
,
text
(
stats
,
'
avg
'
,
'
mean
'
)],
[
'
中位数
'
,
text
(
stats
,
'
median
'
)],
].
filter
(
row
=>
row
[
1
])
}
/>
}
if
(
tool
===
'
web_search
'
)
return
<
BusinessTable
title
=
"公开资料"
headers
=
{
[
'
来源
'
,
'
摘要
'
]
}
rows
=
{
records
(
data
.
results
).
map
(
item
=>
[
linked
(
text
(
item
,
'
title
'
),
text
(
item
,
'
url
'
)),
text
(
item
,
'
snippet
'
).
slice
(
0
,
240
)])
}
/>
if
(
tool
===
'
web_fetch
'
)
return
<
Excerpt
title
=
{
linked
(
text
(
data
,
'
title
'
)
||
'
公开资料摘录
'
,
text
(
data
,
'
url
'
))
}
value
=
{
text
(
data
,
'
content
'
,
'
fulltext
'
)
}
/>
if
(
tool
===
'
web_search
'
)
return
<
BusinessTable
title
=
"公开资料"
headers
=
{
[
'
来源
'
,
'
摘要
'
]
}
rows
=
{
records
(
data
.
results
).
map
(
item
=>
[
linked
(
text
(
item
,
'
title
'
,
'
site_name
'
)
||
'
打开原网页
'
,
text
(
item
,
'
url
'
)),
text
(
item
,
'
snippet
'
).
slice
(
0
,
240
)])
}
/>
// Fetch 正文响应可能只有 title/content。使用本次请求登记的原始网址,旧报告也可打开。
if
(
tool
===
'
web_fetch
'
)
return
<
section
>
{
(
sourceUrl
||
text
(
data
,
'
url
'
))
&&
<
p
>
{
linked
(
'
打开原网页
'
,
sourceUrl
||
text
(
data
,
'
url
'
))
}
</
p
>
}
<
Excerpt
title
=
{
text
(
data
,
'
title
'
)
||
'
公开资料摘录
'
}
value
=
{
text
(
data
,
'
content
'
,
'
fulltext
'
)
}
/>
</
section
>
if
(
tool
===
'
FILE_PARSE
'
)
return
<
BusinessTable
title
=
"文件要点摘录"
headers
=
{
[
'
位置
'
,
'
摘录
'
]
}
rows
=
{
records
(
data
.
segments
).
map
(
item
=>
[
text
(
item
,
'
locator
'
),
text
(
item
,
'
text
'
).
slice
(
0
,
240
)])
}
/>
if
(
tool
===
'
vision
'
)
return
<
Excerpt
title
=
"文件页面文字摘录"
value
=
{
text
(
data
,
'
content
'
,
'
text
'
)
}
/>
return
null
...
...
src/components/ResearchTask.tsx
View file @
60f45bfe
import
{
createUuid
}
from
'
../lib/uuid
'
import
{
Check
,
CircuitBoard
,
Loader2
}
from
'
lucide-react
'
import
{
Check
,
ChevronDown
,
CircuitBoard
,
Loader2
}
from
'
lucide-react
'
import
{
useRef
,
useState
}
from
'
react
'
import
{
api
}
from
'
../lib/api
'
import
{
useTaskEvents
}
from
'
../hooks/useTaskEvents
'
...
...
@@ -50,12 +50,13 @@ export function ResearchTask({ id, title }: { id: string; title?: string }) {
return
<
article
className
=
"rounded-[16px] bg-white px-4 py-3 shadow-card"
>
{
title
&&
<
h2
className
=
"mb-3 whitespace-pre-wrap break-words text-base font-bold text-ink-900"
>
{
title
}
</
h2
>
}
{
!
task
?
<
p
role
=
"status"
>
{
streamError
||
'
正在读取任务…
'
}
</
p
>
:
<>
<
div
className
=
"mb-3 rounded-ctrl bg-canvas px-3 py-2"
>
<
div
className
=
"flex items-center gap-2 text-[12px] font-semibold text-brand-500"
>
{
complete
?
<
CircuitBoard
size
=
{
13
}
/>
:
<
Loader2
size
=
{
13
}
className
=
"animate-spin"
/>
}
Skill 调用进展
</
div
>
{
/* 状态切换时重置展开状态。结束后默认收起,手动展开可回看;继续执行时重新展开。 */
}
<
details
key
=
{
`
${
id
}
:
${
complete
}
`
}
open
=
{
!
complete
}
className
=
"group mb-3 rounded-ctrl bg-canvas px-3 py-2"
>
<
summary
className
=
"flex cursor-pointer list-none items-center gap-2 text-[12px] font-semibold text-brand-500"
>
{
complete
?
<
CircuitBoard
size
=
{
13
}
/>
:
<
Loader2
size
=
{
13
}
className
=
"animate-spin"
/>
}
Skill 调用进展
<
ChevronDown
size
=
{
13
}
className
=
"-rotate-90 group-open:rotate-0"
/></
summary
>
<
ul
className
=
"mt-1 space-y-1"
>
{
task
.
calls
.
map
(
call
=>
<
li
key
=
{
String
(
call
.
id
)
}
className
=
"flex items-center gap-1.5 text-[12px] text-ink-600"
>
{
call
.
status
===
'
SUCCEEDED
'
?
<
Check
size
=
{
12
}
className
=
"text-ok-500"
/>
:
<
span
className
=
"h-3 w-3"
/>
}{
toolNames
[
String
(
call
.
tool_name
)]
??
String
(
call
.
tool_name
)
}
</
li
>)
}
</
ul
>
</
d
iv
>
</
d
etails
>
{
(
error
||
streamError
)
&&
<
p
role
=
"alert"
className
=
"mb-2 text-xs text-bad-500"
>
{
error
||
streamError
}
</
p
>
}
{
(
task
.
status
.
startsWith
(
'
WAITING_
'
)
||
task
.
status
===
'
FAILED
'
)
&&
task
.
question
&&
<
p
className
=
"mb-3 text-[13px] text-ink-600"
>
{
task
.
question
}
</
p
>
}
{
(
task
.
status
.
startsWith
(
'
WAITING_
'
)
||
[
'
FAILED
'
,
'
PARTIAL
'
,
'
CANCELLED
'
].
includes
(
task
.
status
)
)
&&
task
.
question
&&
<
p
className
=
"mb-3 text-[13px] text-ink-600"
role
=
{
task
.
status
===
'
FAILED
'
?
'
alert
'
:
undefined
}
>
{
task
.
question
}
</
p
>
}
{
task
.
status
.
startsWith
(
'
WAITING_
'
)
&&
<
form
key
=
{
`
${
id
}
:
${
revision
}
:
${
task
.
status
}
`
}
onSubmit
=
{
e
=>
{
e
.
preventDefault
();
void
command
(
false
,
e
.
currentTarget
)
}
}
className
=
"space-y-3 rounded-ctrl bg-canvas p-4"
>
{
task
.
status
===
'
WAITING_ENTITY
'
&&
report
?.
choices
?.
filter
(
choice
=>
choice
.
options
.
length
>
0
&&
!
choice
.
selected
).
map
(
choice
=>
<
label
key
=
{
choice
.
key
}
className
=
"block text-sm"
>
{
choice
.
key
.
startsWith
(
'
entity:
'
)
?
`企业
${
Number
(
choice
.
key
.
split
(
'
:
'
)[
1
])
+
1
}
`
:
choice
.
key
===
'
buyer:entity
'
?
'
采购方主体
'
:
'
项目公告
'
}
<
select
name
=
{
choice
.
key
}
required
defaultValue
=
{
choice
.
selected
}
className
=
{
`
${
inputClass
}
mt-1`
}
><
option
value
=
""
>
选择本次明确主体
</
option
>
{
choice
.
options
.
map
(
option
=>
<
option
key
=
{
option
.
id
}
value
=
{
option
.
id
}
>
{
option
.
name
}
·
{
option
.
region
||
'
地区未知
'
}
·
{
option
.
id
}
</
option
>)
}
</
select
>
...
...
@@ -72,8 +73,14 @@ export function ResearchTask({ id, title }: { id: string; title?: string }) {
</
section
>
}
{
report
.
ownFit
&&
<
div
><
h3
className
=
"font-semibold text-ink-900"
>
结合公司档案对照
</
h3
><
p
>
贴合度参考:
{
report
.
ownFit
.
match
.
score
??
'
资料不足
'
}
分
</
p
>
{
Object
.
entries
(
report
.
ownFit
.
match
.
dimensions
).
map
(([
key
,
dimension
])
=>
<
p
key
=
{
key
}
className
=
"text-[13px]"
>
{
dimension
.
basis
}
</
p
>)
}
</
div
>
}
{
report
.
commonCustomers
&&
<
div
><
h3
className
=
"font-semibold text-ink-900"
>
共同客户
</
h3
><
p
>
{
report
.
commonCustomers
.
join
(
'
、
'
)
||
'
当前样本未检出共同客户
'
}
</
p
></
div
>
}
<
ResearchSections
sections
=
{
report
.
sections
}
choices
=
{
report
.
choices
}
/>
<
ResearchSections
sections
=
{
report
.
sections
}
choices
=
{
report
.
choices
}
evidence
=
{
task
.
evidence
}
/>
{
report
.
gaps
?.
length
>
0
&&
<
ul
className
=
"list-disc space-y-1 pl-5 text-[13px]"
>
{
report
.
gaps
.
map
(
gap
=>
<
li
key
=
{
gap
}
>
{
gap
}
</
li
>)
}
</
ul
>
}
{
report
.
kind
===
'
SNAPSHOT_QA
'
&&
complete
&&
task
.
evidence
.
length
>
0
&&
<
details
className
=
"rounded-ctrl bg-canvas px-3 py-1.5 text-[13px]"
>
<
summary
className
=
"cursor-pointer font-medium text-ink-900"
>
回答来源
</
summary
>
<
ul
className
=
"space-y-1"
>
{
task
.
evidence
.
filter
(
source
=>
source
.
verified
).
map
(
source
=>
<
li
key
=
{
source
.
id
}
className
=
"break-words"
>
{
source
.
url
&&
/^https
?
:
\/\/
/i
.
test
(
source
.
url
)
?
<
a
href
=
{
source
.
url
}
target
=
"_blank"
rel
=
"noopener noreferrer"
className
=
"text-brand-500 hover:underline"
>
{
source
.
title
||
'
打开原网页
'
}
</
a
>
:
source
.
title
||
source
.
locator
}
</
li
>)
}
</
ul
>
</
details
>
}
</
div
>
}
{
task
.
answeredAt
&&
<
time
dateTime
=
{
task
.
answeredAt
}
className
=
"mt-3 block font-num text-[11px] text-ink-400"
>
{
answerTime
.
format
(
new
Date
(
task
.
answeredAt
))
}
</
time
>
}
</>
}
...
...
src/hooks/useTaskEvents.ts
View file @
60f45bfe
...
...
@@ -17,7 +17,7 @@ export interface AgentTask {
answeredAt
?:
string
|
null
result
:
unknown
usage
?:
{
external_calls
:
number
;
zlbx_calls
:
number
;
known_cost_units
:
number
;
unknown_cost_calls
:
number
;
model_web_calls
:
number
;
input_tokens
:
number
;
output_tokens
:
number
;
unknown_token_calls
:
number
}
request
:
{
operation
:
string
;
workflow
:
string
;
input
:
string
;
entityConfirmed
:
boolean
;
maxCalls
:
number
;
maxCostUnits
:
number
;
opportunity
?:
SearchQuery
;
research
?:
ResearchRequest
;
qa
?:
QaScope
}
request
:
{
operation
:
string
;
workflow
:
string
;
input
:
string
;
entityConfirmed
:
boolean
;
maxCalls
:
number
;
maxCostUnits
:
number
;
opportunity
?:
SearchQuery
;
research
?:
ResearchRequest
;
qa
?:
QaScope
;
summarizeList
?:
boolean
}
children
?:
{
id
:
string
;
status
:
string
;
operation
:
string
;
target
?:
{
research
?:
ResearchRequest
;
qa
?:
QaScope
}
}[]
calls
:
Record
<
string
,
unknown
>
[]
evidence
:
{
id
:
string
;
url
:
string
|
null
;
locator
:
string
;
excerpt
:
string
;
title
?:
string
;
verified
?:
boolean
}[]
...
...
@@ -43,8 +43,10 @@ export function useTaskEvents(taskId: string | null, revision = 0) {
const
next
=
await
api
<
AgentTask
>
(
`/agent/tasks/
${
taskId
}
`
)
// 多页进度与终态可能相邻到达,只接受最近一次读取,防止慢响应覆盖最终报告。
if
(
active
&&
version
===
refreshVersion
)
{
if
(
initial
)
{
setEvents
([]);
setError
(
''
);
initial
=
false
}
if
(
initial
)
{
setEvents
([]);
initial
=
false
}
setTask
(
next
)
setError
(
''
)
if
(
!
[
'
RECEIVED
'
,
'
PLANNING
'
,
'
RUNNING
'
].
includes
(
next
.
status
))
clearInterval
(
poll
)
}
return
next
}
...
...
@@ -69,7 +71,7 @@ export function useTaskEvents(taskId: string | null, revision = 0) {
cursor
.
current
=
entry
.
id
setEvents
(
items
=>
[...
items
,
entry
])
setError
(
''
);
retries
=
0
if
([
'
PAGE_COLLECTED
'
,
'
MARKET_COLLECTED
'
,
'
RESEARCH_STEP
'
].
includes
(
entry
.
type
))
void
refresh
().
catch
(
error
=>
{
if
(
active
)
setError
(
error
.
message
)
})
if
([
'
STATE
'
,
'
TOOL_START
'
,
'
PAGE_COLLECTED
'
,
'
MARKET_COLLECTED
'
,
'
RESEARCH_STEP
'
,
'
SUMMARY_PROGRESS
'
].
includes
(
entry
.
type
))
void
refresh
().
catch
(
error
=>
{
if
(
active
)
setError
(
error
.
message
)
})
})
source
.
addEventListener
(
'
idle
'
,
()
=>
{
source
?.
close
()
...
...
@@ -82,8 +84,10 @@ export function useTaskEvents(taskId: string | null, revision = 0) {
}
}
// 某些代理会缓冲 SSE,连接可能保持打开却迟迟收不到结束事件。轮询仅回读任务,补齐最终答案。
const
poll
=
setInterval
(()
=>
{
void
refresh
().
catch
(()
=>
{
/* SSE 的重连流程负责提示错误 */
})
},
5000
)
void
refresh
().
then
(()
=>
{
if
(
active
)
connect
()
}).
catch
(
retry
)
return
()
=>
{
active
=
false
;
source
?.
close
();
if
(
timer
)
clearTimeout
(
timer
)
}
return
()
=>
{
active
=
false
;
source
?.
close
();
if
(
timer
)
clearTimeout
(
timer
)
;
clearInterval
(
poll
)
}
},
[
taskId
,
revision
])
return
{
events
,
task
:
task
?.
id
===
taskId
?
task
:
null
,
error
}
}
src/lib/day2.ts
View file @
60f45bfe
...
...
@@ -25,7 +25,8 @@ export interface RankedItem {
facts
:
Candidate
;
relevance
:
number
;
preferenceBonus
:
number
;
reasoning
:
string
[]
analysis
:
null
|
{
projectNumber
:
string
summary
:
{
construction
:
string
;
region
:
string
;
schedule
:
string
[];
qualifications
:
string
[];
gaps
:
string
[];
evidenceId
:
string
;
locator
:
string
;
method
:
string
}
summary
:
{
construction
:
string
;
region
:
string
;
schedule
:
string
[];
qualifications
:
string
[];
gaps
:
string
[];
evidenceId
:
string
;
locator
:
string
;
method
:
string
conclusion
?:
{
construction
?:
string
;
region
?:
string
;
timing
?:
string
;
participation
?:
string
}
}
match
:
{
score
:
number
|
null
;
completeness
:
number
;
profileVersion
:
number
;
version
:
string
;
limitation
:
string
weights
:
Record
<
string
,
number
>
;
dimensions
:
Record
<
string
,
{
score
:
number
;
known
:
boolean
;
basis
:
string
}
>
}
}
...
...
@@ -86,28 +87,37 @@ const registration = /报名(?:及获取文件)?|(?:获取|领取|下载|购买)
const
calendarDate
=
/^
(\d{4})\s
*
[
-年
/
.
]\s
*
(\d{1,2})\s
*
[
-月
/
.
]\s
*
(\d{1,2})
/
/** 仅在报名或获取采购文件的条款内读取截止日。日期区间取尾端,投标、开标和服务结束日期不能补位。 */
export
function
registrationD
at
e
(
schedule
:
string
[]
=
[])
:
string
|
null
{
function
registrationD
eadlin
e
(
schedule
:
string
[]
=
[])
{
for
(
const
clause
of
schedule
.
flatMap
(
line
=>
line
.
split
(
/
[
,,;;。
\n]
/
)))
{
for
(
const
marker
of
clause
.
matchAll
(
registration
))
{
const
related
=
clause
.
slice
(
marker
.
index
+
marker
[
0
].
length
).
split
(
/
(?:
递交|提交
)(?:
投标|响应
)
|投标截止|响应截止|开标|服务
(?:
截止|期
)
|工期/
)[
0
]
const
end
=
related
.
match
(
/
(?:
截止|截至|结束
)(?:
时间|日期
)?\s
*
[
::为至到于
]?\s
*
(
.+
)
/
)
const
end
=
related
.
match
(
/
(?:
截止|截至|结束
)(?:
时间|日期
)?\s
*
[
::为至到于
]?\s
*
(
\d{4}
.*
)
/
)
??
related
.
match
(
/
(?:
至|到|
[
~~—–
])\s
*
(
.+
)
/
)
const
match
=
end
?.[
1
].
match
(
calendarDate
)
if
(
!
match
)
continue
const
value
=
`
${
match
[
1
]}
-
${
match
[
2
].
padStart
(
2
,
'
0
'
)}
-
${
match
[
3
].
padStart
(
2
,
'
0
'
)}
`
const
date
=
new
Date
(
`
${
value
}
T00:00:00Z`
)
if
(
Number
.
isFinite
(
date
.
getTime
())
&&
date
.
toISOString
().
slice
(
0
,
10
)
===
value
)
return
value
if
(
!
Number
.
isFinite
(
date
.
getTime
())
||
date
.
toISOString
().
slice
(
0
,
10
)
!==
value
)
continue
// 显式提供小时和分钟时保留时分。无时分的公告按日显示,避免把当天零点误判为截止。
const
clock
=
end
?.[
1
].
slice
(
match
[
0
].
length
).
match
(
/^
[
日号
\s
T
]
*
([
01
]?\d
|2
[
0-3
])[
::
]([
0-5
]\d)(?:[
::
]([
0-5
]\d))?(?!\d)
/
)
const
time
=
clock
?
`
${
clock
[
1
].
padStart
(
2
,
'
0
'
)}
:
${
clock
[
2
]}${
clock
[
3
]
?
`:
${
clock
[
3
]}
`
:
''
}
`
:
null
return
{
date
:
value
,
time
}
}
}
return
null
}
export
function
registrationDate
(
schedule
?:
string
[])
{
return
registrationDeadline
(
schedule
)?.
date
??
null
}
/** 用北京时间的两个日历日计算剩余天数,避免临近午夜时用小时差造成前后一天的偏差。 */
export
function
registrationReminder
(
schedule
?:
string
[],
today
=
beijingDate
())
{
const
date
=
registrationDate
(
schedule
)
if
(
!
date
)
return
null
export
function
registrationReminder
(
schedule
?:
string
[],
today
=
beijingDate
(),
now
=
Date
.
now
())
{
const
deadline
=
registrationDeadline
(
schedule
)
if
(
!
deadline
)
return
null
const
{
date
,
time
}
=
deadline
const
days
=
(
Date
.
parse
(
date
)
-
Date
.
parse
(
today
))
/
86400000
return
{
date
,
days
,
label
:
days
<
0
?
'
报名已截止
'
:
days
===
0
?
'
报名今天截止
'
:
`报名仅剩
${
days
}
天`
}
const
dateTime
=
time
?
`
${
date
}
T
${
time
}
+08:00`
:
date
const
expired
=
days
<
0
||
(
days
===
0
&&
!!
time
&&
now
>=
Date
.
parse
(
dateTime
))
return
{
date
,
dateTime
,
display
:
time
?
`
${
date
}
${
time
}
`
:
date
,
days
,
label
:
expired
?
'
报名已截止
'
:
days
===
0
?
'
报名今天截止
'
:
`报名仅剩
${
days
}
天`
}
}
export
function
budgetLabel
(
conditions
:
SearchQuery
)
{
...
...
src/pages/DiscoverPage.tsx
View file @
60f45bfe
...
...
@@ -31,7 +31,6 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
const
[
range
,
setRange
]
=
useState
(
'
30
'
)
const
[
regionText
,
setRegionText
]
=
useState
(
''
)
const
[
limits
,
setLimits
]
=
useState
({
maxCalls
:
5
,
maxCostUnits
:
10
})
const
[
searchMaxPages
,
setSearchMaxPages
]
=
useState
(
5
)
const
[
schemes
,
setSchemes
]
=
useState
<
SearchScheme
[]
>
([])
const
[
history
,
setHistory
]
=
useState
<
SearchHistory
[]
>
([])
const
selected
=
params
.
get
(
'
batch
'
)
??
history
.
find
(
run
=>
run
.
schemeId
)?.
id
??
null
...
...
@@ -54,10 +53,9 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
return
pending
.
current
.
key
}
const
reload
=
useCallback
(
async
()
=>
{
const
[
saved
,
runs
,
allowed
]
=
await
Promise
.
all
([
api
<
SearchScheme
[]
>
(
'
/search-schemes
'
),
api
<
SearchHistory
[]
>
(
'
/searches
'
),
api
<
{
maxCalls
:
number
;
maxCostUnits
:
number
;
searchMaxPages
:
number
}
>
(
'
/system/limits
'
)])
const
[
saved
,
runs
,
allowed
]
=
await
Promise
.
all
([
api
<
SearchScheme
[]
>
(
'
/search-schemes
'
),
api
<
SearchHistory
[]
>
(
'
/searches
'
),
api
<
{
maxCalls
:
number
;
maxCostUnits
:
number
}
>
(
'
/system/limits
'
)])
setSchemes
(
saved
);
setHistory
(
runs
)
setLimits
({
maxCalls
:
allowed
.
maxCalls
,
maxCostUnits
:
allowed
.
maxCostUnits
})
setSearchMaxPages
(
allowed
.
searchMaxPages
)
},
[])
useEffect
(()
=>
{
void
reload
().
catch
(
e
=>
setError
(
message
(
e
)))
},
[
reload
])
const
update
=
<
K
extends
keyof
SearchQuery
>
(key: K, value: SearchQuery[K]) => setQuery(current => (
{
...
current
,
[
key
]:
value
}
))
...
...
@@ -78,7 +76,8 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
if
(
conditions
.
keywords
.
length
===
0
&&
conditions
.
mode
!==
'
MARKET
'
)
throw
new
Error
(
'
请填写关键词,使用逗号分隔
'
)
if
(
conditions
.
beginDate
>
conditions
.
endDate
)
throw
new
Error
(
'
开始日期不能晚于结束日期
'
)
// 普通检索尽量读满部署允许的页数,预算筛选即使首两页无命中也能继续检查后续页。
const
payload
=
{
conditions
,
maxCalls
:
Math
.
min
(
limits
.
maxCalls
,
searchMaxPages
),
maxCostUnits
:
Math
.
min
(
10
,
limits
.
maxCostUnits
)
}
// 详情和列表模型使用与分页共用的预算;页数上限由服务端单独保护。
const
payload
=
{
conditions
,
summarizeList
:
conditions
.
mode
===
'
SEARCH
'
,
maxCalls
:
limits
.
maxCalls
,
maxCostUnits
:
Math
.
min
(
10
,
limits
.
maxCostUnits
)
}
const
next
=
await
api
<
AgentTask
>
(
'
/searches
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Idempotency-Key
'
:
keyFor
(
payload
)
},
body
:
JSON
.
stringify
(
payload
)
})
pending
.
current
=
null
;
choose
(
next
.
id
);
setRevision
(
v
=>
v
+
1
);
await
reload
()
}
)
...
...
@@ -90,7 +89,7 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
await
api
(
`/search-schemes
${
editing
?
`/
${
editing
.
id
}
`
:
''
}
`
,
{
method
:
editing
?
'
PUT
'
:
'
POST
'
,
body
:
JSON
.
stringify
({
name
:
schemeName
.
trim
(),
version
:
editing
?.
version
??
0
,
conditions
:
{
...
query
,
keywords
:
keyword
.
split
(
/
[\s
、,,;;
]
+/
).
filter
(
Boolean
)
}
})
})
setEditing
(
null
);
setSchemeName
(
''
);
setShowSchemeForm
(
false
);
await
reload
()
}
)
//
原型只展示本次检索结果;服务端仍保留完整快照,不在页面另加审计与调试区域
。
//
当前列表同时接收检索页和 AI 归纳进度,刷新页面可回到同一个批次
。
const report = task?.result as SearchReport | null
const dirty = !!report
&&
JSON.stringify(
{
...
query
,
keywords
:
keyword
.
split
(
/
[\s
、,,;;
]
+/
).
filter
(
Boolean
)
}
) !== JSON.stringify(report.conditions)
const active = !!task
&&
!['SUCCEEDED', 'FAILED', 'PARTIAL', 'CANCELLED'].includes(task.status)
&&
!task.status.startsWith('WAITING_')
...
...
@@ -171,8 +170,14 @@ export function DiscoverPage({ onOpenPanel }: { onOpenPanel: (state: AnalysisPan
{
selected
&&
!
task
&&
<
p
className
=
"p-6 text-sm"
role
=
"status"
>
正在加载任务快照…
</
p
>
}
{
task
&&
<>
{
report
?.
scope
.
budgetFilteredLocally
&&
!
report
.
scope
.
complete
&&
<
p
className
=
"border-b border-line-soft px-5 py-2 text-xs text-ink-400"
>
预算已筛选
{
report
.
scope
.
fetchedCount
}
条已读取公告,未读取部分尚未纳入。
</
p
>
}
{
task
.
status
!==
'
SUCCEEDED
'
&&
<
div
className
=
"flex flex-wrap items-center gap-3 px-5 py-3 text-xs"
><
span
className
=
"rounded-full bg-brand-50 px-3 py-1 text-brand-500"
>
{
taskStates
[
task
.
status
]
??
task
.
status
}
</
span
><
span
>
{
task
.
question
}
</
span
>
{
active
&&
<
GhostButton
disabled
=
{
busy
}
onClick
=
{
()
=>
void
runAction
(
async
()
=>
{
await
api
(
`/agent/tasks/
${
task
.
id
}
/cancel`
,
{
method
:
'
POST
'
});
setRevision
(
v
=>
v
+
1
)
})
}
>
取消后续请求
</
GhostButton
>
}{
task
.
status
.
startsWith
(
'
WAITING_
'
)
&&
<
GhostButton
disabled
=
{
busy
}
onClick
=
{
()
=>
void
runAction
(
async
()
=>
{
const
conditions
=
task
.
request
.
opportunity
;
if
(
!
conditions
)
return
;
const
payload
=
{
conditions
,
...
limits
};
await
api
(
`/searches/
${
task
.
id
}
/continue`
,
{
method
:
'
POST
'
,
headers
:
{
'
Idempotency-Key
'
:
keyFor
({
continue
:
task
.
id
,
...
payload
})
},
body
:
JSON
.
stringify
(
payload
)
});
pending
.
current
=
null
;
setRevision
(
v
=>
v
+
1
)
})
}
>
{
task
.
status
===
'
WAITING_BUDGET
'
?
`确认提高至
${
limits
.
maxCalls
}
次 /
${
limits
.
maxCostUnits
}
积分并继续`
:
'
已补配置,继续原任务
'
}
</
GhostButton
>
}
</
div
>
}
{
report
&&
<>
{
active
&&
!
report
.
items
.
length
?
<
p
role
=
"status"
className
=
"p-12 text-center text-sm text-ink-400"
>
正在检索并整理公告…
</
p
>
:
<
OpportunityTable
key
=
{
selected
}
items
=
{
report
.
items
}
batchId
=
{
task
.
id
}
onOpenPanel
=
{
onOpenPanel
}
/>
}
</>
}
{
task
.
status
!==
'
SUCCEEDED
'
&&
<
div
className
=
"flex flex-wrap items-center gap-3 px-5 py-3 text-xs"
><
span
className
=
"rounded-full bg-brand-50 px-3 py-1 text-brand-500"
>
{
taskStates
[
task
.
status
]
??
task
.
status
}
</
span
><
span
>
{
task
.
question
}
</
span
>
{
active
&&
<
GhostButton
disabled
=
{
busy
}
onClick
=
{
()
=>
void
runAction
(
async
()
=>
{
await
api
(
`/agent/tasks/
${
task
.
id
}
/cancel`
,
{
method
:
'
POST
'
});
setRevision
(
v
=>
v
+
1
)
})
}
>
取消后续请求
</
GhostButton
>
}{
task
.
status
.
startsWith
(
'
WAITING_
'
)
&&
<
GhostButton
disabled
=
{
busy
}
onClick
=
{
()
=>
void
runAction
(
async
()
=>
{
const
conditions
=
task
.
request
.
opportunity
;
if
(
!
conditions
)
return
;
const
payload
=
{
conditions
,
summarizeList
:
task
.
request
.
summarizeList
??
false
,
...
limits
};
await
api
(
`/searches/
${
task
.
id
}
/continue`
,
{
method
:
'
POST
'
,
headers
:
{
'
Idempotency-Key
'
:
keyFor
({
continue
:
task
.
id
,
...
payload
})
},
body
:
JSON
.
stringify
(
payload
)
});
pending
.
current
=
null
;
setRevision
(
v
=>
v
+
1
)
})
}
>
{
task
.
status
===
'
WAITING_BUDGET
'
?
`确认提高至
${
limits
.
maxCalls
}
次 /
${
limits
.
maxCostUnits
}
积分并继续`
:
'
已补配置,继续原任务
'
}
</
GhostButton
>
}
</
div
>
}
{
report
&&
<>
{
active
&&
!
report
.
items
.
length
?
<
p
role
=
"status"
className
=
"p-12 text-center text-sm text-ink-400"
>
正在检索并整理公告…
</
p
>
:
<>
{
task
.
request
.
summarizeList
&&
report
.
items
.
length
>
0
&&
<
p
role
=
"status"
className
=
"border-b border-line-soft px-5 py-2 text-xs text-ink-600"
>
{
active
?
'
正在整理 AI 结论
'
:
'
已生成 AI 结论
'
}
·
{
report
.
summaryProgress
.
completed
}
/
{
report
.
summaryProgress
.
total
}
条
{
!
active
&&
report
.
summaryProgress
.
completed
<
report
.
summaryProgress
.
total
&&
'
,其余项目显示已有公告信息
'
}
</
p
>
}
<
OpportunityTable
key
=
{
selected
}
items
=
{
report
.
items
}
batchId
=
{
task
.
id
}
onOpenPanel
=
{
onOpenPanel
}
/>
</>
}
</>
}
</>
}
</
section
>
:
watchPreview
.
length
>
0
?
<
section
className
=
"mt-4 overflow-hidden rounded-card border border-line-soft bg-white shadow-card"
><
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"
>
共
{
watch
.
length
}
条,展示前
{
Math
.
min
(
watchPreview
.
length
,
6
)
}
条
</
span
><
span
className
=
"flex-1"
/><
span
className
=
"text-xs text-ink-400"
>
在上方设置条件点击「检索」,发现更多商机
</
span
></
div
><
ul
className
=
"divide-y divide-line-soft/70"
>
{
watchPreview
.
slice
(
0
,
6
).
map
(
row
=>
<
li
key
=
{
row
.
projectId
}
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
=
{
row
.
project
.
url
??
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"
>
{
row
.
project
.
title
}
</
span
><
ExternalLink
size
=
{
11
}
className
=
"shrink-0 text-ink-400"
/></
a
><
p
className
=
"mt-0.5 text-xs text-ink-400"
>
{
row
.
project
.
purchaser
}
·
{
row
.
project
.
region
}
·
{
row
.
project
.
budgetWan
==
null
?
'
预算未披露
'
:
`
${
row
.
project
.
budgetWan
}
万元`
}
</
p
></
div
><
span
className
=
"shrink-0 text-xs font-medium text-ink-400"
>
{
registrationDate
(
row
.
summary
?.
schedule
)
?
`报名截止
${
registrationDate
(
row
.
summary
?.
schedule
)}
`
:
'
截止时间未披露
'
}
</
span
><
button
onClick
=
{
()
=>
onOpenPanel
({
kind
:
'
project
'
,
project
:
{
...
row
.
project
,
userFileId
:
row
.
fileId
},
summary
:
row
.
summary
})
}
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 hover:shadow-card-hover"
><
Sparkles
size
=
{
12
}
className
=
"text-brand-500"
/><
span
className
=
"text-brand-gradient"
>
AI 分析
</
span
></
button
></
li
>)
}
</
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"
>
设置检索条件后点击「检索」
</
p
><
p
className
=
"mt-1 text-xs text-ink-400"
>
点击任意一行查看 AI 分析
</
p
></
section
>
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment