diff --git a/web/components/kefu/widget-demo.tsx b/web/components/kefu/widget-demo.tsx index 687e5fe..6e9922d 100644 --- a/web/components/kefu/widget-demo.tsx +++ b/web/components/kefu/widget-demo.tsx @@ -72,10 +72,12 @@ function injectWidget(config: KefuWidgetHostConfig) { export function KefuWidgetDemo() { const [config, setConfig] = useState(INITIAL_CONFIG) const [status, setStatus] = useState("请填写 channelId") + const [origin, setOrigin] = useState("") useEffect(() => { const timer = window.setTimeout(() => { const initialConfig = getDefaultConfig() + setOrigin(window.location.origin) setConfig(initialConfig) setStatus(initialConfig.channelId ? "Widget 已挂载" : "请填写 channelId") @@ -91,13 +93,17 @@ export function KefuWidgetDemo() { }, []) const snippet = useMemo(() => { + const scriptSrc = origin + ? `${origin}/sdk/cs-ai-agent-sdk.min.js` + : "/sdk/cs-ai-agent-sdk.min.js" + return ` -` - }, [config]) +` + }, [config, origin]) function updateField( key: K,