@ -204,15 +204,15 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
< / div >
< / div >
< / div >
< / div >
< div class = "fg-row" >
< div class = "fg-row" >
< div class = "fg" >
< label > launcherIcon 悬浮按钮图标< / label >
< input id = "cfg-launcher-icon" type = "text" placeholder = "URL 或 SVG 字符串,留空使用默认极光粒子图标" style = "width:100%;box-sizing:border-box;" / >
< div class = "hint" > 留空则使用默认极光粒子动画< / div >
< / div >
< div class = "fg" >
< div class = "fg" >
< label > showClear 清空按钮< / label >
< label > showClear 清空按钮< / label >
< select id = "cfg-clear" > < option value = "1" selected > 显示< / option > < option value = "0" > 隐藏< / option > < / select >
< select id = "cfg-clear" > < option value = "1" selected > 显示< / option > < option value = "0" > 隐藏< / option > < / select >
< / div >
< / div >
< div class = "fg" >
< label > watermark 水印文字< / label >
< input type = "text" id = "cfg-watermark" value = "" placeholder = "水印格式:日期 + 此值" >
< div class = "hint" > 留空则不显示水印< / div >
< / div >
< / div >
< / div >
< div class = "actions" >
< div class = "actions" >
< button class = "btn btn-primary btn-full" id = "btn-init" onclick = "doInit()" > 🚀 初始化 SDK< / button >
< button class = "btn btn-primary btn-full" id = "btn-init" onclick = "doInit()" > 🚀 初始化 SDK< / button >
@ -348,6 +348,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
debug: getEl('cfg-debug').value === '1',
debug: getEl('cfg-debug').value === '1',
theme: getEl('cfg-theme-mode').value,
theme: getEl('cfg-theme-mode').value,
showClear: getEl('cfg-clear').value === '1',
showClear: getEl('cfg-clear').value === '1',
watermark: getEl('cfg-watermark').value.trim() || undefined,
};
};
// 有 Token 时传入鉴权参数
// 有 Token 时传入鉴权参数
if (token) {
if (token) {
@ -446,7 +447,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
// SDK 可选参数的默认值(与 config.ts parseConfig 严格对齐),用于判断是否需要在生成代码中输出
// SDK 可选参数的默认值(与 config.ts parseConfig 严格对齐),用于判断是否需要在生成代码中输出
const SDK_DEFAULTS = {
const SDK_DEFAULTS = {
title: 'AI 智能助手',
title: 'AI 智能助手',
width: 38 0,
width: 50 0,
height: 520,
height: 520,
position: 'right-bottom',
position: 'right-bottom',
primaryColor: '#4F46E5',
primaryColor: '#4F46E5',
@ -494,6 +495,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
if (cfg.showCategorySwitch !== SDK_DEFAULTS.showCategorySwitch) params.push(' showCategorySwitch: ' + cfg.showCategorySwitch + ', // 是否显示知识库切换');
if (cfg.showCategorySwitch !== SDK_DEFAULTS.showCategorySwitch) params.push(' showCategorySwitch: ' + cfg.showCategorySwitch + ', // 是否显示知识库切换');
if (cfg.enableRag !== SDK_DEFAULTS.enableRag) params.push(' enableRag: ' + cfg.enableRag + ', // 启用 RAG 知识库检索');
if (cfg.enableRag !== SDK_DEFAULTS.enableRag) params.push(' enableRag: ' + cfg.enableRag + ', // 启用 RAG 知识库检索');
if (cfg.showClear !== SDK_DEFAULTS.showClear) params.push(' showClear: ' + cfg.showClear + ', // 显示清空按钮');
if (cfg.showClear !== SDK_DEFAULTS.showClear) params.push(' showClear: ' + cfg.showClear + ', // 显示清空按钮');
const watermark = getEl('cfg-watermark').value.trim();
if (watermark) params.push(' watermark: ' + JSON.stringify(watermark) + ', // 聊天窗口水印文字');
// debug 强制 false(生产环境推荐),无论面板当前值
// debug 强制 false(生产环境推荐),无论面板当前值
params.push(' debug: false // 调试日志,生产环境建议关闭');
params.push(' debug: false // 调试日志,生产环境建议关闭');
const initBlock = 'ChatbotSDK.init({\n' + params.join('\n') + '\n});';
const initBlock = 'ChatbotSDK.init({\n' + params.join('\n') + '\n});';
@ -525,7 +528,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
// 语法高亮:先转义 HTML,再用单遍正则匹配 HTML 注释 / 字符串 / 行注释 / 数字 / 对象 key
// 语法高亮:先转义 HTML,再用单遍正则匹配 HTML 注释 / 字符串 / 行注释 / 数字 / 对象 key
function highlightCode(code) {
function highlightCode(code) {
const esc = code.replace(/& /g, '& ').replace(/< /g, '< ').replace(/>/g, '> ');
const esc = code.replace(/& /g, '& ').replace(/< /g, '< ').replace(/>/g, '> ');
const re = /(< !--[\s\S]*?--> )|('[^']*'|"[^"]*")|(\/\/[^\n]*)|\b(\d+)\b|\b(integrateId|requestDomain|userId|categoryId|title|primaryColor|position|width|streaming|locale|showCategorySwitch|enableRag|rewriteStrategy|debug|showClear|showAdminPanel|launcherIcon|token|roles)(?=\s*:)/g;
const re = /(< !--[\s\S]*?--> )|('[^']*'|"[^"]*")|(\/\/[^\n]*)|\b(\d+)\b|\b(integrateId|requestDomain|userId|categoryId|title|primaryColor|position|width|streaming|locale|showCategorySwitch|enableRag|rewriteStrategy|debug|showClear|watermark| showAdminPanel|launcherIcon|token|roles)(?=\s*:)/g;
return esc.replace(re, (m, htmlCmt, str, cmt, num, key) => {
return esc.replace(re, (m, htmlCmt, str, cmt, num, key) => {
if (htmlCmt) return '< span class = "cm" > ' + htmlCmt + '< / span > ';
if (htmlCmt) return '< span class = "cm" > ' + htmlCmt + '< / span > ';
if (str) return '< span class = "st" > ' + str + '< / span > ';
if (str) return '< span class = "st" > ' + str + '< / span > ';
@ -684,7 +687,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans S
setEl('footer-time',new Date().toLocaleTimeString());
setEl('footer-time',new Date().toLocaleTimeString());
if(typeof window.ChatbotSDK!=='undefined'){const tag=getEl('tag-sdk');tag.className='tag tag--pass';tag.textContent='✅ SDK 已加载';}
if(typeof window.ChatbotSDK!=='undefined'){const tag=getEl('tag-sdk');tag.className='tag tag--pass';tag.textContent='✅ SDK 已加载';}
// 监听配置表单变化,实时刷新接入代码
// 监听配置表单变化,实时刷新接入代码
['cfg-iid','cfg-domain','cfg-uid','cfg-title','cfg-color','cfg-pos','cfg-width','cfg-height','cfg-resizable','cfg-stream','cfg-locale','cfg-cat','cfg-rag','cfg-clear','cfg-debug','cfg-theme','cfg-theme -mode','cfg-apikey','cfg-token'].forEach(function(id){
['cfg-iid','cfg-domain','cfg-uid','cfg-title','cfg-color','cfg-pos','cfg-width','cfg-height','cfg-resizable','cfg-stream','cfg-locale','cfg-cat','cfg-rag','cfg-clear','cfg-debug','cfg-theme-mode','cfg-apikey','cfg-token','cfg-watermark '].forEach(function(id){
const el=getEl(id);
const el=getEl(id);
if(!el)return;
if(!el)return;
el.addEventListener('input', generateCode);
el.addEventListener('input', generateCode);