manual save(2026-01-22 16:03)
This commit is contained in:
@@ -73,6 +73,7 @@ function App() {
|
||||
<Route path="/cases" element={<PageWrapper><Cases /></PageWrapper>} />
|
||||
<Route path="/news" element={<PageWrapper><News /></PageWrapper>} />
|
||||
<Route path="/learning" element={<PageWrapper><Learning /></PageWrapper>} />
|
||||
<Route path="/assistant" element={<PageWrapper><Assistant /></PageWrapper>} />
|
||||
<Route path="/contact" element={<PageWrapper><Contact /></PageWrapper>} />
|
||||
|
||||
{/* English routes */}
|
||||
@@ -82,6 +83,7 @@ function App() {
|
||||
<Route path="/en/cases" element={<PageWrapper><Cases /></PageWrapper>} />
|
||||
<Route path="/en/news" element={<PageWrapper><News /></PageWrapper>} />
|
||||
<Route path="/en/learning" element={<PageWrapper><Learning /></PageWrapper>} />
|
||||
<Route path="/en/assistant" element={<PageWrapper><Assistant /></PageWrapper>} />
|
||||
<Route path="/en/contact" element={<PageWrapper><Contact /></PageWrapper>} />
|
||||
|
||||
<Route path="*" element={<NotFound />} />
|
||||
|
||||
@@ -68,6 +68,8 @@ export const Footer: React.FC = () => {
|
||||
? 'News'
|
||||
: n.id === 'learning'
|
||||
? 'Learning'
|
||||
: n.id === 'assistant'
|
||||
? 'AI Assistant'
|
||||
: n.id === 'contact'
|
||||
? 'Contact'
|
||||
: n.label
|
||||
|
||||
@@ -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<SearchResult[]> {
|
||||
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: '' })
|
||||
|
||||
Reference in New Issue
Block a user