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="/cases" element={<PageWrapper><Cases /></PageWrapper>} />
|
||||||
<Route path="/news" element={<PageWrapper><News /></PageWrapper>} />
|
<Route path="/news" element={<PageWrapper><News /></PageWrapper>} />
|
||||||
<Route path="/learning" element={<PageWrapper><Learning /></PageWrapper>} />
|
<Route path="/learning" element={<PageWrapper><Learning /></PageWrapper>} />
|
||||||
|
<Route path="/assistant" element={<PageWrapper><Assistant /></PageWrapper>} />
|
||||||
<Route path="/contact" element={<PageWrapper><Contact /></PageWrapper>} />
|
<Route path="/contact" element={<PageWrapper><Contact /></PageWrapper>} />
|
||||||
|
|
||||||
{/* English routes */}
|
{/* English routes */}
|
||||||
@@ -82,6 +83,7 @@ function App() {
|
|||||||
<Route path="/en/cases" element={<PageWrapper><Cases /></PageWrapper>} />
|
<Route path="/en/cases" element={<PageWrapper><Cases /></PageWrapper>} />
|
||||||
<Route path="/en/news" element={<PageWrapper><News /></PageWrapper>} />
|
<Route path="/en/news" element={<PageWrapper><News /></PageWrapper>} />
|
||||||
<Route path="/en/learning" element={<PageWrapper><Learning /></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="/en/contact" element={<PageWrapper><Contact /></PageWrapper>} />
|
||||||
|
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ export const Footer: React.FC = () => {
|
|||||||
? 'News'
|
? 'News'
|
||||||
: n.id === 'learning'
|
: n.id === 'learning'
|
||||||
? 'Learning'
|
? 'Learning'
|
||||||
|
: n.id === 'assistant'
|
||||||
|
? 'AI Assistant'
|
||||||
: n.id === 'contact'
|
: n.id === 'contact'
|
||||||
? 'Contact'
|
? 'Contact'
|
||||||
: n.label
|
: n.label
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { Header } from '../components/Header'
|
|||||||
import { Footer } from '../components/Footer'
|
import { Footer } from '../components/Footer'
|
||||||
import { Breadcrumbs } from '../components/Breadcrumbs'
|
import { Breadcrumbs } from '../components/Breadcrumbs'
|
||||||
import { FormSubmissions, Forms, SearchResults } from '../clientsdk/sdk.gen'
|
import { FormSubmissions, Forms, SearchResults } from '../clientsdk/sdk.gen'
|
||||||
|
import type { Post, SearchResult, SearchResultQueryOperations } from '../clientsdk/types.gen'
|
||||||
import { createClient } from '../clientsdk/client'
|
import { createClient } from '../clientsdk/client'
|
||||||
import { customQuerySerializer } from '../clientsdk/querySerializer'
|
import { customQuerySerializer } from '../clientsdk/querySerializer'
|
||||||
import { API_URL, TENANT_API_KEY, TENANT_SLUG } from '../config'
|
import { API_URL, TENANT_API_KEY, TENANT_SLUG } from '../config'
|
||||||
@@ -110,21 +111,24 @@ function buildFallbackAnswer(locale: Locale, question: string) {
|
|||||||
].join('\n')
|
].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({
|
const response = await SearchResults.listSearchResults({
|
||||||
client,
|
client,
|
||||||
query: {
|
query: {
|
||||||
limit: 5,
|
limit: 5,
|
||||||
depth: 2,
|
depth: 2,
|
||||||
where: {
|
where,
|
||||||
title: {
|
|
||||||
contains: question,
|
|
||||||
},
|
|
||||||
} as any,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return ((response as any)?.data?.docs ?? []) as any[]
|
const docs = (response as unknown as { data?: { docs?: SearchResult[] } })?.data?.docs
|
||||||
|
return docs ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveLeadFormId() {
|
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 target = forms.find((f) => {
|
||||||
const title = String(f?.title || '')
|
const title = String(f?.title || '')
|
||||||
return /AI\s*智能助手|诚裕智能客服|AI Assistant|Assistant Lead|留资/i.test(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) {
|
if (docs.length > 0 && top?.doc?.value) {
|
||||||
const post = top.doc.value
|
const post = top.doc.value
|
||||||
const title = post?.title || top?.title
|
const resolvedPost: Post | null = typeof post === 'string' ? null : post
|
||||||
const excerpt = stripHtml(post?.content_html || '')
|
const title = resolvedPost?.title || top?.title
|
||||||
|
const excerpt = stripHtml(resolvedPost?.content_html || '')
|
||||||
|
|
||||||
const answer =
|
const answer =
|
||||||
locale === 'en'
|
locale === 'en'
|
||||||
@@ -326,7 +331,7 @@ export const Assistant: React.FC = () => {
|
|||||||
{ field: 'source', value: 'AI智能助手' },
|
{ field: 'source', value: 'AI智能助手' },
|
||||||
].filter((item) => item.value),
|
].filter((item) => item.value),
|
||||||
},
|
},
|
||||||
} as any)
|
})
|
||||||
|
|
||||||
setLeadSubmitted(true)
|
setLeadSubmitted(true)
|
||||||
setLead({ name: '', phone: '', company: '', demand: '' })
|
setLead({ name: '', phone: '', company: '', demand: '' })
|
||||||
|
|||||||
Reference in New Issue
Block a user