From 6a305f7242cf74e186da4dd925234710268f39af Mon Sep 17 00:00:00 2001 From: SiteAgent Bot Date: Thu, 22 Jan 2026 16:03:55 +0800 Subject: [PATCH] manual save(2026-01-22 16:03) --- src/App.tsx | 2 ++ src/components/Footer.tsx | 8 +++++--- src/pages/Assistant.tsx | 27 ++++++++++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index feb85cb..2e44a04 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -73,6 +73,7 @@ function App() { } /> } /> } /> + } /> } /> {/* English routes */} @@ -82,6 +83,7 @@ function App() { } /> } /> } /> + } /> } /> } /> diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 537cb26..555ef69 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -68,9 +68,11 @@ export const Footer: React.FC = () => { ? 'News' : n.id === 'learning' ? 'Learning' - : n.id === 'contact' - ? 'Contact' - : n.label + : n.id === 'assistant' + ? 'AI Assistant' + : n.id === 'contact' + ? 'Contact' + : n.label : n.label} diff --git a/src/pages/Assistant.tsx b/src/pages/Assistant.tsx index d52090f..3eab5a4 100644 --- a/src/pages/Assistant.tsx +++ b/src/pages/Assistant.tsx @@ -15,6 +15,7 @@ import { Header } from '../components/Header' import { Footer } from '../components/Footer' import { Breadcrumbs } from '../components/Breadcrumbs' import { FormSubmissions, Forms, SearchResults } from '../clientsdk/sdk.gen' +import type { Post, SearchResult, SearchResultQueryOperations } from '../clientsdk/types.gen' import { createClient } from '../clientsdk/client' import { customQuerySerializer } from '../clientsdk/querySerializer' import { API_URL, TENANT_API_KEY, TENANT_SLUG } from '../config' @@ -110,21 +111,24 @@ function buildFallbackAnswer(locale: Locale, question: string) { ].join('\n') } -async function searchKnowledge(question: string) { +async function searchKnowledge(question: string): Promise { + const where: SearchResultQueryOperations = { + title: { + contains: question, + }, + } + const response = await SearchResults.listSearchResults({ client, query: { limit: 5, depth: 2, - where: { - title: { - contains: question, - }, - } as any, + where, }, }) - return ((response as any)?.data?.docs ?? []) as any[] + const docs = (response as unknown as { data?: { docs?: SearchResult[] } })?.data?.docs + return docs ?? [] } async function resolveLeadFormId() { @@ -136,7 +140,7 @@ async function resolveLeadFormId() { }, }) - const forms = ((res as any)?.data?.docs ?? []) as any[] + const forms = (res as unknown as { data?: { docs?: Array<{ id?: string; title?: string }> } })?.data?.docs ?? [] const target = forms.find((f) => { const title = String(f?.title || '') return /AI\s*智能助手|诚裕智能客服|AI Assistant|Assistant Lead|留资/i.test(title) @@ -229,8 +233,9 @@ export const Assistant: React.FC = () => { if (docs.length > 0 && top?.doc?.value) { const post = top.doc.value - const title = post?.title || top?.title - const excerpt = stripHtml(post?.content_html || '') + const resolvedPost: Post | null = typeof post === 'string' ? null : post + const title = resolvedPost?.title || top?.title + const excerpt = stripHtml(resolvedPost?.content_html || '') const answer = locale === 'en' @@ -326,7 +331,7 @@ export const Assistant: React.FC = () => { { field: 'source', value: 'AI智能助手' }, ].filter((item) => item.value), }, - } as any) + }) setLeadSubmitted(true) setLead({ name: '', phone: '', company: '', demand: '' })