This commit is contained in:
wangdan-fit2cloud 2023-12-26 16:56:14 +08:00
parent 05cd6c2cb0
commit dfc80486b8
12 changed files with 78 additions and 65 deletions

View File

@ -9,5 +9,13 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script>
window.maxkbChatConfig = {
token: 'ae91f8122813b571',
host: 'localhost:3000',
protocol: 'http:'
}
</script>
<script src="http://localhost:3000/ui/embeb.js"></script>
</body>
</html>

View File

@ -1,6 +1,6 @@
function embedChatbot() {
const t = window.maxkbChatConfig
if (t && t.token&&t.protocol&&t.host) {
function embedChatbot() {
const t = window.maxkbChatConfig
if (t && t.token && t.protocol && t.host) {
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)"/>
@ -24,53 +24,54 @@
<stop offset="1" stop-color="#3370FF"/>
</linearGradient>
</defs>
</svg>`;
chat_button = document.createElement("div");
chat_button.style =
"position: fixed;bottom: 40px;right: 20px;cursor: pointer;";
chat_button.innerHTML = icon;
chat_container = document.createElement("div");
chat_container.id = "chat_container";
chat_container.style.cssText = `z-index:10000;position: relative;
</svg>`
chat_button = document.createElement('div')
chat_button.style = 'position: fixed;bottom: 30px;right: 0;cursor: pointer;'
chat_button.innerHTML = icon
chat_container = document.createElement('div')
chat_container.id = 'chat_container'
chat_container.style.cssText = `z-index:10000;position: relative;
width: 420px;
height: 600px;
border: none;
border-radius: 7px 7px 7px 7px;
position: fixed;bottom: 40px;right: 20px`;
chat_container.style["display"] = "none";
chat = document.createElement("iframe");
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;
box-shadow: 0px 4px 8px 0px rgba(31, 35, 41, 0.10);
position: fixed;bottom: 20px;right: 45px;overflow: hidden;`
chat_container.style['display'] = 'none'
chat.src = `${window.maxkbChatConfig.protocol}//${window.maxkbChatConfig.host}/ui/chat/${window.maxkbChatConfig.token}`;
chat.id = "chat";
chat_container.append(chat);
chat.style.cssText = `border: none;height:100%;width:100%`;
close_button = document.createElement("div");
close_button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
chat = document.createElement('iframe')
chat.src = `${window.maxkbChatConfig.protocol}//${window.maxkbChatConfig.host}/ui/chat/${window.maxkbChatConfig.token}`
chat.id = 'chat'
chat_container.append(chat)
chat.style.cssText = `border: none;height:100%;width:100%`
close_button = document.createElement('div')
close_button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M9.95317 8.73169L15.5511 3.13376C15.7138 2.97104 15.9776 2.97104 16.1403 3.13376L16.7296 3.72301C16.8923 3.88573 16.8923 4.14955 16.7296 4.31227L11.1317 9.9102L16.7296 15.5081C16.8923 15.6708 16.8923 15.9347 16.7296 16.0974L16.1403 16.6866C15.9776 16.8494 15.7138 16.8494 15.5511 16.6866L9.95317 11.0887L4.35524 16.6866C4.19252 16.8494 3.9287 16.8494 3.76598 16.6866L3.17673 16.0974C3.01401 15.9347 3.01401 15.6708 3.17673 15.5081L8.77465 9.9102L3.17673 4.31227C3.01401 4.14955 3.01401 3.88573 3.17673 3.72301L3.76598 3.13376C3.9287 2.97104 4.19252 2.97104 4.35524 3.13376L9.95317 8.73169Z" fill="#646A73"/>
</svg>`;
close_button.style.cssText = `position: absolute;
top: 10px;
</svg>`
close_button.style.cssText = `position: absolute;
top: 15px;
right: 10px;
cursor: pointer;
`;
close_button.onclick = () => {
chat_container.style["display"] = "none";
chat_button.style["display"] = "block";
};
chat_container.append(close_button);
document.body.append(chat_container);
chat_button.onclick = ($event) => {
chat_container.style["display"] = "block";
chat_button.style["display"] = "none";
};
sty=document.createElement("style")
sty.innerText=` #chat_container {
`
close_button.onclick = () => {
chat_container.style['display'] = 'none'
chat_button.style['display'] = 'block'
}
chat_container.append(close_button)
document.body.append(chat_container)
chat_button.onclick = ($event) => {
chat_container.style['display'] = 'block'
chat_button.style['display'] = 'block'
}
sty = document.createElement('style')
sty.innerText = ` #chat_container {
animation: appear .4s ease-in-out;
}
@keyframes appear {
@ -81,9 +82,10 @@
to {
height: 600px;
}
}`
document.head.append(sty)
document.body.append(chat_button);
} else console.error('invalid parameter')
}
}
`
document.head.append(sty)
document.body.append(chat_button)
} else console.error('invalid parameter')
}
window.onload = embedChatbot

BIN
ui/src/assets/login.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

View File

@ -135,7 +135,6 @@ import applicationApi from '@/api/application'
import { ChatManagement, type chatType } from '@/api/type/application'
import { randomId } from '@/utils/utils'
import useStore from '@/stores'
import { MdPreview } from 'md-editor-v3'
import MdRenderer from '@/components/markdown-renderer/MdRenderer.vue'
defineOptions({ name: 'AiChat' })
const route = useRoute()

View File

@ -39,7 +39,7 @@ onMounted(() => {
height: 100vh;
.login-image {
background: url(@/assets/login.png) no-repeat;
background: url(@/assets/login.jpg) no-repeat;
background-size: 100% 100%;
width: 100%;
height: 100%;

View File

@ -3,7 +3,8 @@
ref="editorRef"
editorId="preview-only"
:modelValue="item"
v-for="item in md_view_list"
v-for="(item, index) in md_view_list"
:key="index"
/>
</template>
<script setup lang="ts">

View File

@ -3,7 +3,8 @@
<el-row :gutter="12">
<el-col :span="12">
<div class="border">
<img src="@/assets/window1.png" alt="" />
<p class="title p-16 bold">全屏模式</p>
<img src="@/assets/window1.png" alt="" class="ml-8" />
<div class="code border-t p-16">
<div class="flex-between">
<span class="bold">复制以下代码进行嵌入</span>
@ -19,7 +20,8 @@
</el-col>
<el-col :span="12">
<div class="border">
<img src="@/assets/window2.png" alt="" />
<p class="title p-16 bold">浮窗模式</p>
<img src="@/assets/window2.png" alt="" class="ml-8" />
<div class="code border-t p-16">
<div class="flex-between">
<span class="bold">复制以下代码进行嵌入</span>
@ -82,6 +84,10 @@ defineExpose({ open })
</script>
<style lang="scss" scope>
.embed-dialog {
.title {
color: var(--app-text-color) !important;
}
.code {
color: var(--app-text-color) !important;
background: var(--app-layout-bg-color);

View File

@ -41,9 +41,10 @@ onMounted(() => {
getAccessToken(accessToken)
})
</script>
<style lang="scss" scoped>
<style lang="scss">
.chat {
background-color: var(--app-layout-bg-color);
overflow: hidden;
&__header {
background: var(--app-header-bg-color);
position: fixed;
@ -54,11 +55,11 @@ onMounted(() => {
height: var(--app-header-height);
line-height: var(--app-header-height);
box-sizing: border-box;
padding: var(--app-header-padding);
}
&__main {
padding-top: calc(var(--app-header-height) + 24px);
height: calc(100vh - var(--app-header-height) - 24px);
overflow: hidden;
}
&__footer {
background: #f3f7f9;
@ -68,6 +69,7 @@ onMounted(() => {
left: 0;
width: 100%;
box-sizing: border-box;
border-radius: 8px !important;
&:before {
background: linear-gradient(0deg, #f3f7f9 0%, rgba(243, 247, 249, 0) 100%);
content: '';

View File

@ -1,9 +1,5 @@
<template>
<LayoutContainer
:header="isCreate ? '创建知识库' : '上传文档'"
back-to="-1"
class="create-dataset"
>
<LayoutContainer :header="isCreate ? '创建知识库' : '上传文档'" class="create-dataset">
<template #backButton>
<back-button @click="back"></back-button>
</template>
@ -70,9 +66,8 @@ const baseInfo = computed(() => dataset.baseInfo)
const router = useRouter()
const route = useRoute()
const {
query: { id, type }
params: { id, type }
} = route
const isCreate = type === 'create'
const steps = [
{

View File

@ -84,7 +84,7 @@ function searchHandle() {
function deleteDateset(row: any) {
MsgConfirm(
`是否删除知识库:${row.name} ?`,
`此知识库关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
`此知识库关联 ${row.application_mapping_count} 个应用,删除后无法恢复,请谨慎操作。`,
{
confirmButtonText: '删除',
confirmButtonClass: 'danger'

View File

@ -81,7 +81,7 @@
<el-table-column label="操作" align="center">
<template #default="{ row }">
<span v-if="row.status === '2'" class="mr-4">
<el-tooltip effect="dark" content="刷新" placement="top">
<el-tooltip effect="dark" content="重试" placement="top">
<el-button type="primary" text @click.stop="refreshDocument(row)">
<el-icon><RefreshRight /></el-icon>
</el-button>