Merge pull request #500 from alibaba/fix/demo-showpanel-type
fix(page-agent): keep demo showPanel out of config type
This commit is contained in:
@@ -22,6 +22,7 @@ const currentScript = document.currentScript as HTMLScriptElement | null
|
||||
// in case document.x is not ready yet
|
||||
setTimeout(() => {
|
||||
let config: PageAgentConfig
|
||||
let showPanel = true
|
||||
|
||||
if (currentScript) {
|
||||
console.log('🚀 page-agent.js detected current script:', currentScript.src)
|
||||
@@ -30,21 +31,20 @@ setTimeout(() => {
|
||||
const baseURL = url.searchParams.get('baseURL') || DEMO_BASE_URL
|
||||
const apiKey = url.searchParams.get('apiKey') || DEMO_API_KEY
|
||||
const language = (url.searchParams.get('lang') as 'zh-CN' | 'en-US') || 'zh-CN'
|
||||
const showPanel = ((url.searchParams.get('showPanel') as 'true' | 'false') || 'true') === 'true'
|
||||
config = { model, baseURL, apiKey, language, showPanel }
|
||||
showPanel = ((url.searchParams.get('showPanel') as 'true' | 'false') || 'true') === 'true'
|
||||
config = { model, baseURL, apiKey, language }
|
||||
} else {
|
||||
console.log('🚀 page-agent.js no current script detected, using default demo config')
|
||||
config = {
|
||||
model: import.meta.env.LLM_MODEL_NAME ? import.meta.env.LLM_MODEL_NAME : DEMO_MODEL,
|
||||
baseURL: import.meta.env.LLM_BASE_URL ? import.meta.env.LLM_BASE_URL : DEMO_BASE_URL,
|
||||
apiKey: import.meta.env.LLM_API_KEY ? import.meta.env.LLM_API_KEY : DEMO_API_KEY,
|
||||
showPanel: true,
|
||||
}
|
||||
}
|
||||
|
||||
// Create agent
|
||||
window.pageAgent = new PageAgent(config)
|
||||
if (config.showPanel) {
|
||||
if (showPanel) {
|
||||
window.pageAgent.panel.show()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user