mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-29 16:12:55 +00:00
feat: 优化
This commit is contained in:
parent
0c9fbc14d7
commit
cde17a9434
|
|
@ -1,15 +1,15 @@
|
|||
function auth(token,protocol,host){
|
||||
const XML=new XMLHttpRequest()
|
||||
XML.open("POST",`${protocol}//${host}/api/application/authentication`,false)
|
||||
XML.setRequestHeader('Content-Type', 'application/json');
|
||||
res=XML.send(JSON.stringify({"access_token":token}))
|
||||
return XML.status==200
|
||||
function auth(token, protocol, host) {
|
||||
const XML = new XMLHttpRequest()
|
||||
XML.open('POST', `${protocol}//${host}/api/application/authentication`, false)
|
||||
XML.setRequestHeader('Content-Type', 'application/json')
|
||||
res = XML.send(JSON.stringify({ access_token: token }))
|
||||
return XML.status == 200
|
||||
}
|
||||
|
||||
function embedChatbot() {
|
||||
const t = window.maxkbChatConfig
|
||||
check=auth(t.token,t.protocol, t.host)
|
||||
if (t && t.token && t.protocol && t.host&& check) {
|
||||
check = auth(t.token, t.protocol, t.host)
|
||||
if (t && t.token && t.protocol && t.host && check) {
|
||||
icon = `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="56" viewBox="0 0 48 56" fill="none">
|
||||
<g filter="url(#filter0_d_349_49711)">
|
||||
<path d="M8 24C8 12.9543 16.9543 4 28 4H48V44H28C16.9543 44 8 35.0457 8 24Z" fill="url(#paint0_linear_349_49711)"/>
|
||||
|
|
@ -41,8 +41,7 @@ function embedChatbot() {
|
|||
chat_container = document.createElement('div')
|
||||
chat_container.id = 'chat_container'
|
||||
chat_container.style.cssText = `z-index:10000;position: relative;
|
||||
width: 420px;
|
||||
height: 600px;
|
||||
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--N300, #DEE0E3);
|
||||
background: linear-gradient(188deg, rgba(235, 241, 255, 0.20) 39.6%, rgba(231, 249, 255, 0.20) 94.3%), #EFF0F1;
|
||||
|
|
@ -69,27 +68,26 @@ function embedChatbot() {
|
|||
`
|
||||
close_button.onclick = () => {
|
||||
document.body.removeChild(chat_container)
|
||||
chat_button.style['display']='block'
|
||||
chat_button.style['display'] = 'block'
|
||||
}
|
||||
|
||||
chat_container.append(close_button)
|
||||
document.body.append(chat_container)
|
||||
let is_404=false
|
||||
let is_404 = false
|
||||
chat_button.onclick = ($event) => {
|
||||
if( chat_container.style['display']=='block'){
|
||||
chat_container.style['display']='none'
|
||||
if (chat_container.style['display'] == 'block') {
|
||||
chat_container.style['display'] = 'none'
|
||||
} else {
|
||||
if(auth(t.token,t.protocol, t.host)){
|
||||
if(is_404){
|
||||
if (auth(t.token, t.protocol, t.host)) {
|
||||
if (is_404) {
|
||||
document.body.removeChild(chat_container)
|
||||
document.body.append(chat_container)
|
||||
|
||||
is_404=false
|
||||
}
|
||||
chat_container.style['display']='block'
|
||||
|
||||
}else{
|
||||
is_404=true
|
||||
|
||||
is_404 = false
|
||||
}
|
||||
chat_container.style['display'] = 'block'
|
||||
} else {
|
||||
is_404 = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -518,3 +518,15 @@ h4 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#chat_container {
|
||||
width: 420px;
|
||||
height: 600px;
|
||||
}
|
||||
@media only screen and (max-width: 768px) {
|
||||
#chat_container {
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue