Merge branch 'main' of github.com:maxkb-dev/maxkb

# Conflicts:
#	ui/public/embeb.js
This commit is contained in:
shaohuzhang1 2024-03-06 17:16:01 +08:00
commit 30fa4a6f2c
4 changed files with 49 additions and 13 deletions

View File

@ -1,15 +1,15 @@
function auth(token,protocol,host){ function auth(token, protocol, host) {
const XML=new XMLHttpRequest() const XML = new XMLHttpRequest()
XML.open("POST",`${protocol}//${host}/api/application/authentication`,false) XML.open('POST', `${protocol}//${host}/api/application/authentication`, false)
XML.setRequestHeader('Content-Type', 'application/json'); XML.setRequestHeader('Content-Type', 'application/json')
res=XML.send(JSON.stringify({"access_token":token})) res = XML.send(JSON.stringify({ access_token: token }))
return XML.status==200 return XML.status == 200
} }
function embedChatbot() { function embedChatbot() {
const t = window.maxkbChatConfig const t = window.maxkbChatConfig
check=auth(t.token,t.protocol, t.host) check = auth(t.token, t.protocol, t.host)
if (t && t.token && t.protocol && t.host&& check) { 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"> 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)"> <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)"/> <path d="M8 24C8 12.9543 16.9543 4 28 4H48V44H28C16.9543 44 8 35.0457 8 24Z" fill="url(#paint0_linear_349_49711)"/>
@ -37,12 +37,25 @@ function embedChatbot() {
chat_button = document.createElement('div') chat_button = document.createElement('div')
chat_button.style = 'position: fixed;bottom: 30px;right: 0;cursor: pointer;' chat_button.style = 'position: fixed;bottom: 30px;right: 0;cursor: pointer;'
chat_button.innerHTML = icon chat_button.innerHTML = icon
style=document.createElement('style')
style.type='text/css'
style.innerText= `#chat_container {
width: 420px;
height: 600px;
}
@media only screen and (max-width: 768px) {
#chat_container {
width: 100%;
height: 70%;
right: 0 !important;
}
}`
document.head.appendChild(style)
chat_container = document.createElement('div') chat_container = document.createElement('div')
chat_container.id = 'chat_container' chat_container.id = 'chat_container'
chat_container.style.cssText = `z-index:10000;position: relative; chat_container.style.cssText = `z-index:10000;position: relative;
width: 420px;
height: 600px;
border-radius: 8px; border-radius: 8px;
border: 1px solid var(--N300, #DEE0E3); 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; background: linear-gradient(188deg, rgba(235, 241, 255, 0.20) 39.6%, rgba(231, 249, 255, 0.20) 94.3%), #EFF0F1;
@ -73,8 +86,10 @@ function embedChatbot() {
chat_container.append(close_button) chat_container.append(close_button)
document.body.append(chat_container) document.body.append(chat_container)
chat_button.onclick = ($event) => { chat_button.onclick = ($event) => {
chat_container.style['display']=chat_container.style['display']=='block'?'none':'block' chat_container.style['display']=chat_container.style['display']=='block'?'none':'block'
} }
sty = document.createElement('style') sty = document.createElement('style')
sty.innerText = ` #chat_container { sty.innerText = ` #chat_container {

View File

@ -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;
}
}

View File

@ -12,7 +12,7 @@
shape="square" shape="square"
:size="32" :size="32"
/> />
<h4 class="ellipsis">{{ detail?.name }}</h4> <h4>{{ detail?.name }}</h4>
</div> </div>
<el-row :gutter="12"> <el-row :gutter="12">

View File

@ -17,11 +17,20 @@
class="mr-12" class="mr-12"
shape="square" shape="square"
:size="24" :size="24"
style="flex-shrink: 0"
/> />
<AppAvatar v-else-if="isDataset" class="mr-12" shape="square" :size="24"> <AppAvatar
v-else-if="isDataset"
class="mr-12"
shape="square"
:size="24"
style="flex-shrink: 0"
>
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" /> <img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
</AppAvatar> </AppAvatar>
<span class="ellipsis"> {{ row?.name }}</span> <auto-tooltip :content="row?.name">
{{ row?.name }}
</auto-tooltip>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>