mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00

* feat: org CRUD (#3380) * feat: add org schema * feat: org manage UI * feat: OrgInfoModal * feat: org tree view * feat: org management * fix: init root org * feat: org permission for app * feat: org support for dataset * fix: disable org role control * styles: opt type signatures * fix: remove unused permission * feat: delete org collaborator * perf: Team org ui (#3499) * perf: org ui * perf: org ui * feat: org auth for app & dataset (#3498) * feat: auth org resource permission * feat: org auth support for app & dataset * perf: org permission check (#3500) * i18n (#3501) * name * i18n * feat: support dataset changeOwner (#3483) * feat: support dataset changeOwner * chore: update dataset change owner api * feat: permission manage UI for org (#3503) * perf: password check;perf: image upload check;perf: sso login check (#3509) * perf: password check * perf: image upload check * perf: sso login check * force show update notification modal & fix login page text (#3512) * fix login page English text * update notification modal * perf: notify account (#3515) * perf(plugin): improve searXNG empty result handling and documentation (#3507) * perf(plugin): improve searXNG empty result handling and documentation * 修改了文档和代码部分无搜索的结果的反馈 * refactor: org pathId (#3516) * optimize payment process (#3517) * feat: support wecom sso (#3518) * feat: support wecom sso * chore: remove unused wecom js-sdk dependency * fix qrcode script (#3520) * fix qrcode script * i18n * perf: full text collection and search code;perf: rename function (#3519) * perf: full text collection and search code * perf: rename function * perf: notify modal * remove invalid code * perf: sso login * perf: pay process * 4.8.18 test (#3524) * perf: remove local token * perf: index * perf: file encoding;perf: leave team code;@c121914yu perf: full text search code (#3528) * perf: text encoding * perf: leave team code * perf: full text search code * fix: http status * perf: embedding search and vector avatar * perf: async read file (#3531) * refactor: team permission manager (#3535) * perf: classify org, group and member * refactor: team per manager * fix: missing functions * 4.8.18 test (#3543) * perf: login check * doc * perf: llm model config * perf: team clb config * fix: MemberModal UI (#3553) * fix: adapt MemberModal title and icon * fix: adapt member modal * fix: search input placeholder * fix: add button text * perf: org permission (#3556) * docs:用户答疑的官方文档补充 (#3540) * docs:用户答疑的官方文档补充 * 问题回答的内容修补 * share link random avatar (#3541) * share link random avatar * fix * delete unused code * share page avatar (#3558) * feat: init 4818 * share page avatar * feat: tmp upgrade code (#3559) * feat: tmp upgrade code * fulltext search test * update action * full text tmp code (#3561) * full text tmp code * fix: init * fix: init * remove tmp code * remove tmp code * 4818-alpha * 4.8.18 test (#3562) * full text tmp code * fix: init * upgrade code * account log * account log * perf: dockerfile * upgrade code * chore: update docs app template submission (#3564) --------- Co-authored-by: a.e. <49438478+I-Info@users.noreply.github.com> Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: Jiangween <145003935+Jiangween@users.noreply.github.com>
115 lines
5.1 KiB
JavaScript
115 lines
5.1 KiB
JavaScript
function embedChatbot() {
|
|
const chatBtnId = 'fastgpt-chatbot-button';
|
|
const chatWindowId = 'fastgpt-chatbot-window';
|
|
const script = document.getElementById('chatbot-iframe');
|
|
const botSrc = script?.getAttribute('data-bot-src');
|
|
const defaultOpen = script?.getAttribute('data-default-open') === 'true';
|
|
const canDrag = script?.getAttribute('data-drag') === 'true';
|
|
const MessageIcon =
|
|
script?.getAttribute('data-open-icon') ||
|
|
`data:image/svg+xml;base64,PHN2ZyB0PSIxNjkwNTMyNzg1NjY0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQxMzIiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48cGF0aCBkPSJNNTEyIDMyQzI0Ny4wNCAzMiAzMiAyMjQgMzIgNDY0QTQxMC4yNCA0MTAuMjQgMCAwIDAgMTcyLjQ4IDc2OEwxNjAgOTY1LjEyYTI1LjI4IDI1LjI4IDAgMCAwIDM5LjA0IDIyLjRsMTY4LTExMkE1MjguNjQgNTI4LjY0IDAgMCAwIDUxMiA4OTZjMjY0Ljk2IDAgNDgwLTE5MiA0ODAtNDMyUzc3Ni45NiAzMi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U3MWE0NS41NjggNDUuNTY4IDAgMCAwLTY0LjQzODg1OCA2NC40Mzg4NTh6IiBmaWxsPSIjNGU4M2ZkIiBwLWlkPSI2MzY4Ij48L3BhdGg+PC9zdmc+';
|
|
|
|
if (!botSrc) {
|
|
console.error(`Can't find appid`);
|
|
return;
|
|
}
|
|
if (document.getElementById(chatBtnId)) {
|
|
return;
|
|
}
|
|
|
|
const ChatBtn = document.createElement('div');
|
|
ChatBtn.id = chatBtnId;
|
|
ChatBtn.style.cssText =
|
|
'position: fixed; bottom: 30px; right: 60px; width: 40px; height: 40px; cursor: pointer; z-index: 2147483647; transition: 0;';
|
|
|
|
// btn icon
|
|
const ChatBtnDiv = document.createElement('img');
|
|
ChatBtnDiv.src = defaultOpen ? CloseIcon : MessageIcon;
|
|
ChatBtnDiv.setAttribute('width', '100%');
|
|
ChatBtnDiv.setAttribute('height', '100%');
|
|
ChatBtnDiv.draggable = false;
|
|
|
|
const iframe = document.createElement('iframe');
|
|
iframe.allow = '*';
|
|
iframe.referrerPolicy = 'no-referrer';
|
|
iframe.title = 'FastGPT Chat Window';
|
|
iframe.id = chatWindowId;
|
|
iframe.src = botSrc;
|
|
iframe.style.cssText =
|
|
'border: none; position: fixed; flex-direction: column; justify-content: space-between; box-shadow: rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px; bottom: 80px; right: 60px; width: 375px; height: 667px; max-width: 90vw; max-height: 85vh; border-radius: 0.75rem; display: flex; z-index: 2147483647; overflow: hidden; left: unset; background-color: #F3F4F6;';
|
|
iframe.style.visibility = defaultOpen ? 'unset' : 'hidden';
|
|
|
|
document.body.appendChild(iframe);
|
|
|
|
const observer = new MutationObserver((mutations) => {
|
|
mutations.forEach((mutation) => {
|
|
if (mutation.type === 'attributes' && mutation.attributeName === 'data-bot-src') {
|
|
const newBotSrc = script.getAttribute('data-bot-src');
|
|
if (newBotSrc) {
|
|
iframe.src = newBotSrc;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
observer.observe(script, {
|
|
attributes: true,
|
|
attributeFilter: ['data-bot-src']
|
|
});
|
|
|
|
let chatBtnDragged = false;
|
|
let chatBtnDown = false;
|
|
let chatBtnMouseX;
|
|
let chatBtnMouseY;
|
|
ChatBtn.addEventListener('click', function () {
|
|
if (chatBtnDragged) {
|
|
chatBtnDragged = false;
|
|
return;
|
|
}
|
|
const chatWindow = document.getElementById(chatWindowId);
|
|
|
|
if (!chatWindow) return;
|
|
const visibilityVal = chatWindow.style.visibility;
|
|
if (visibilityVal === 'hidden') {
|
|
chatWindow.style.visibility = 'unset';
|
|
ChatBtnDiv.src = CloseIcon;
|
|
} else {
|
|
chatWindow.style.visibility = 'hidden';
|
|
ChatBtnDiv.src = MessageIcon;
|
|
}
|
|
});
|
|
|
|
ChatBtn.addEventListener('mousedown', (e) => {
|
|
e.stopPropagation();
|
|
|
|
if (!chatBtnMouseX && !chatBtnMouseY) {
|
|
chatBtnMouseX = e.clientX;
|
|
chatBtnMouseY = e.clientY;
|
|
}
|
|
|
|
chatBtnDown = true;
|
|
});
|
|
|
|
window.addEventListener('mousemove', (e) => {
|
|
e.stopPropagation();
|
|
if (!canDrag || !chatBtnDown) return;
|
|
|
|
chatBtnDragged = true;
|
|
const transformX = e.clientX - chatBtnMouseX;
|
|
const transformY = e.clientY - chatBtnMouseY;
|
|
|
|
ChatBtn.style.transform = `translate3d(${transformX}px, ${transformY}px, 0)`;
|
|
});
|
|
|
|
window.addEventListener('mouseup', (e) => {
|
|
chatBtnDown = false;
|
|
});
|
|
|
|
ChatBtn.appendChild(ChatBtnDiv);
|
|
document.body.appendChild(ChatBtn);
|
|
}
|
|
window.addEventListener('load', embedChatbot);
|
|
|