init commit
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
<template>
|
||||
<div id="app">
|
||||
<RouterView />
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
body,
|
||||
html,
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
|
||||
Microsoft YaHei, SimSun, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,62 @@
|
||||
import { get, post, put, del, postChat } from "../../utils/request";
|
||||
import { loadTestData } from "../test-data";
|
||||
|
||||
// 从localStorage获取设置
|
||||
function getSettings() {
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
if (settingsStr) {
|
||||
try {
|
||||
const settings = JSON.parse(settingsStr);
|
||||
if (settings.apiKey && settings.endpoint) {
|
||||
return settings;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 根据是否有设置决定是否需要加载测试数据
|
||||
async function ensureConfigured() {
|
||||
const settings = getSettings();
|
||||
// 如果没有设置APIKey和Endpoint,则加载测试数据
|
||||
if (!settings) {
|
||||
await loadTestData();
|
||||
}
|
||||
}
|
||||
|
||||
export async function createSessions(data = {}) {
|
||||
await ensureConfigured();
|
||||
return post("/api/v1/sessions", data);
|
||||
}
|
||||
|
||||
export async function getSessionsList(page: number, page_size: number) {
|
||||
await ensureConfigured();
|
||||
return get(`/api/v1/sessions?page=${page}&page_size=${page_size}`);
|
||||
}
|
||||
|
||||
export async function generateSessionsTitle(session_id: string, data: any) {
|
||||
await ensureConfigured();
|
||||
return post(`/api/v1/sessions/${session_id}/generate_title`, data);
|
||||
}
|
||||
|
||||
export async function knowledgeChat(data: { session_id: string; query: string; }) {
|
||||
await ensureConfigured();
|
||||
return postChat(`/api/v1/knowledge-chat/${data.session_id}`, { query: data.query });
|
||||
}
|
||||
|
||||
export async function getMessageList(data: { session_id: string; limit: number, created_at: string }) {
|
||||
await ensureConfigured();
|
||||
|
||||
if (data.created_at) {
|
||||
return get(`/api/v1/messages/${data.session_id}/load?before_time=${encodeURIComponent(data.created_at)}&limit=${data.limit}`);
|
||||
} else {
|
||||
return get(`/api/v1/messages/${data.session_id}/load?limit=${data.limit}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function delSession(session_id: string) {
|
||||
await ensureConfigured();
|
||||
return del(`/api/v1/sessions/${session_id}`);
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source'
|
||||
import { ref, type Ref, onUnmounted, nextTick } from 'vue'
|
||||
import { generateRandomString } from '@/utils/index';
|
||||
import { getTestData } from '@/utils/request';
|
||||
import { loadTestData } from '@/api/test-data';
|
||||
|
||||
// 从localStorage获取设置
|
||||
function getSettings() {
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
if (settingsStr) {
|
||||
try {
|
||||
const settings = JSON.parse(settingsStr);
|
||||
return settings;
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
interface StreamOptions {
|
||||
// 请求方法 (默认POST)
|
||||
method?: 'GET' | 'POST'
|
||||
// 请求头
|
||||
headers?: Record<string, string>
|
||||
// 请求体自动序列化
|
||||
body?: Record<string, any>
|
||||
// 流式渲染间隔 (ms)
|
||||
chunkInterval?: number
|
||||
}
|
||||
|
||||
export function useStream() {
|
||||
// 响应式状态
|
||||
const output = ref('') // 显示内容
|
||||
const isStreaming = ref(false) // 流状态
|
||||
const isLoading = ref(false) // 初始加载
|
||||
const error = ref<string | null>(null)// 错误信息
|
||||
let controller = new AbortController()
|
||||
|
||||
// 流式渲染缓冲
|
||||
let buffer: string[] = []
|
||||
let renderTimer: number | null = null
|
||||
|
||||
// 启动流式请求
|
||||
const startStream = async (params: { session_id: any; query: any; method: string; url: string }) => {
|
||||
// 重置状态
|
||||
output.value = '';
|
||||
error.value = null;
|
||||
isStreaming.value = true;
|
||||
isLoading.value = true;
|
||||
|
||||
// 获取设置信息
|
||||
const settings = getSettings();
|
||||
let apiUrl = '';
|
||||
let apiKey = '';
|
||||
|
||||
// 如果有设置信息,优先使用设置信息
|
||||
if (settings && settings.endpoint && settings.apiKey) {
|
||||
apiUrl = settings.endpoint;
|
||||
apiKey = settings.apiKey;
|
||||
} else {
|
||||
// 否则加载测试数据
|
||||
await loadTestData();
|
||||
const testData = getTestData();
|
||||
if (!testData) {
|
||||
error.value = "测试数据未初始化,无法进行聊天";
|
||||
stopStream();
|
||||
return;
|
||||
}
|
||||
apiUrl = import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080";
|
||||
apiKey = testData.tenant.api_key;
|
||||
}
|
||||
|
||||
try {
|
||||
let url =
|
||||
params.method == "POST"
|
||||
? `${apiUrl}${params.url}/${params.session_id}`
|
||||
: `${apiUrl}${params.url}/${params.session_id}?message_id=${params.query}`;
|
||||
await fetchEventSource(url, {
|
||||
method: params.method,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-Key": apiKey,
|
||||
"X-Request-ID": `${generateRandomString(12)}`,
|
||||
},
|
||||
body:
|
||||
params.method == "POST"
|
||||
? JSON.stringify({ query: params.query })
|
||||
: null,
|
||||
signal: controller.signal,
|
||||
openWhenHidden: true,
|
||||
|
||||
onopen: async (res) => {
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
isLoading.value = false;
|
||||
},
|
||||
|
||||
onmessage: (ev) => {
|
||||
buffer.push(JSON.parse(ev.data)); // 数据存入缓冲
|
||||
// 执行自定义处理
|
||||
if (chunkHandler) {
|
||||
chunkHandler(JSON.parse(ev.data));
|
||||
}
|
||||
},
|
||||
|
||||
onerror: (err) => {
|
||||
throw new Error(`流式连接失败: ${err}`);
|
||||
},
|
||||
|
||||
onclose: () => {
|
||||
stopStream();
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : String(err)
|
||||
stopStream()
|
||||
}
|
||||
}
|
||||
|
||||
let chunkHandler: ((data: any) => void) | null = null
|
||||
// 注册块处理器
|
||||
const onChunk = (handler: () => void) => {
|
||||
chunkHandler = handler
|
||||
}
|
||||
|
||||
|
||||
// 停止流
|
||||
const stopStream = () => {
|
||||
controller.abort();
|
||||
controller = new AbortController(); // 重置控制器(如需重新发起)
|
||||
isStreaming.value = false;
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
// 组件卸载时自动清理
|
||||
onUnmounted(stopStream)
|
||||
|
||||
return {
|
||||
output, // 显示内容
|
||||
isStreaming, // 是否在流式传输中
|
||||
isLoading, // 初始连接状态
|
||||
error,
|
||||
onChunk,
|
||||
startStream, // 启动流
|
||||
stopStream // 手动停止
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { get, post, put, del, postUpload, getDown, getTestData } from "../../utils/request";
|
||||
import { loadTestData } from "../test-data";
|
||||
|
||||
// 获取知识库ID(优先从设置中获取)
|
||||
async function getKnowledgeBaseID() {
|
||||
// 从localStorage获取设置中的知识库ID
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
let knowledgeBaseId = "";
|
||||
|
||||
if (settingsStr) {
|
||||
try {
|
||||
const settings = JSON.parse(settingsStr);
|
||||
if (settings.knowledgeBaseId) {
|
||||
return settings.knowledgeBaseId;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果设置中没有知识库ID,则使用测试数据
|
||||
await loadTestData();
|
||||
|
||||
const testData = getTestData();
|
||||
if (!testData || testData.knowledge_bases.length === 0) {
|
||||
console.error("测试数据未初始化或不包含知识库");
|
||||
throw new Error("测试数据未初始化或不包含知识库");
|
||||
}
|
||||
return testData.knowledge_bases[0].id;
|
||||
}
|
||||
|
||||
export async function uploadKnowledgeBase(data = {}) {
|
||||
const kbId = await getKnowledgeBaseID();
|
||||
return postUpload(`/api/v1/knowledge-bases/${kbId}/knowledge/file`, data);
|
||||
}
|
||||
|
||||
export async function getKnowledgeBase({page, page_size}) {
|
||||
const kbId = await getKnowledgeBaseID();
|
||||
return get(
|
||||
`/api/v1/knowledge-bases/${kbId}/knowledge?page=${page}&page_size=${page_size}`
|
||||
);
|
||||
}
|
||||
|
||||
export function getKnowledgeDetails(id: any) {
|
||||
return get(`/api/v1/knowledge/${id}`);
|
||||
}
|
||||
|
||||
export function delKnowledgeDetails(id: any) {
|
||||
return del(`/api/v1/knowledge/${id}`);
|
||||
}
|
||||
|
||||
export function downKnowledgeDetails(id: any) {
|
||||
return getDown(`/api/v1/knowledge/${id}/download`);
|
||||
}
|
||||
|
||||
export function batchQueryKnowledge(ids: any) {
|
||||
return get(`/api/v1/knowledge/batch?${ids}`);
|
||||
}
|
||||
|
||||
export function getKnowledgeDetailsCon(id: any, page) {
|
||||
return get(`/api/v1/chunks/${id}?page=${page}&page_size=25`);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { get, setTestData } from '../../utils/request';
|
||||
|
||||
export interface TestDataResponse {
|
||||
success: boolean;
|
||||
data: {
|
||||
tenant: {
|
||||
id: number;
|
||||
name: string;
|
||||
api_key: string;
|
||||
};
|
||||
knowledge_bases: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
// 是否已加载测试数据
|
||||
let isTestDataLoaded = false;
|
||||
|
||||
/**
|
||||
* 加载测试数据
|
||||
* 在API调用前调用此函数以确保测试数据已加载
|
||||
* @returns Promise<boolean> 是否成功加载
|
||||
*/
|
||||
export async function loadTestData(): Promise<boolean> {
|
||||
// 如果已经加载过,直接返回
|
||||
if (isTestDataLoaded) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('开始加载测试数据...');
|
||||
const response = await get('/api/v1/test-data');
|
||||
console.log('测试数据', response);
|
||||
|
||||
if (response && response.data) {
|
||||
// 设置测试数据
|
||||
setTestData({
|
||||
tenant: response.data.tenant,
|
||||
knowledge_bases: response.data.knowledge_bases
|
||||
});
|
||||
isTestDataLoaded = true;
|
||||
console.log('测试数据加载成功');
|
||||
return true;
|
||||
} else {
|
||||
console.warn('测试数据响应为空');
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载测试数据失败:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@font-face {
|
||||
font-family: 'TencentSans';
|
||||
src: url('fonts/TencentSans.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" class="r4oyk8abi__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 2C5.79086 2 4 3.79086 4 6C4 7.56981 4.90422 8.92935 6.22252 9.58448C6.39251 9.66896 6.5 9.84241 6.5 10.0322V11H9.5V10.0322C9.5 9.84241 9.60749 9.66896 9.77748 9.58448C11.0958 8.92935 12 7.56981 12 6C12 3.79086 10.2091 2 8 2ZM3 6C3 3.23858 5.23858 1 8 1C10.7614 1 13 3.23858 13 6C13 7.85144 11.9936 9.46702 10.5 10.331V11.5C10.5 11.7761 10.2761 12 10 12H6C5.72386 12 5.5 11.7761 5.5 11.5V10.331C4.00636 9.46702 3 7.85144 3 6Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 13.5H6V12.5H10V13.5Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 15H7V14H9V15Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.4269 5.11946L7.60516 7.94123L5.7821 6.11819L6.48921 5.41108L7.60516 6.52702L9.71982 4.41235L10.4269 5.11946Z" fill="#32CE3F"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1022 B |
|
After Width: | Height: | Size: 543 KiB |
|
After Width: | Height: | Size: 824 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="r6a8hvpwe__design-iconfont" width="128" height="128">
|
||||
<path d="M6 12V6H7V12H6Z"></path>
|
||||
<path d="M9 6V12H10V6H9Z"></path>
|
||||
<path d="M10.5 3H14V4H13V14C13 14.5523 12.5523 15 12 15H4C3.44772 15 3 14.5523 3 14V4H2V3H5.5L5.5 1.8C5.5 1.35817 5.85817 1 6.3 1H9.7C10.1418 1 10.5 1.35817 10.5 1.8V3ZM6.5 3H9.5L9.5 2L6.5 2V3ZM4 4V14H12V4H4Z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 419 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" class="wb1yuxk13__design-iconfont" width="128" height="128">
|
||||
<path d="M12.2636 5.81387L8.5 9.57746L8.49998 0.5L7.49998 0.500002L7.5 9.57746L3.73641 5.81387L3.02931 6.52098L7.64645 11.1381C7.84171 11.3334 8.15829 11.3334 8.35355 11.1381L12.9707 6.52098L12.2636 5.81387Z" fill-opacity=".9" fill="#07C05F"></path>
|
||||
<path d="M2 11V13C2 13.5523 2.44772 14 3 14H13C13.5523 14 14 13.5523 14 13V11H13V13H3V11H2Z" fill-opacity=".9" fill="#07C05F"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 515 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="g8nqf16e8__design-iconfont" width="128" height="128">
|
||||
<path d="M5 1.25C4.30482 1.25 3.75 1.80482 3.75 2.5V16.25C3.75 16.9451 4.30482 17.5 5 17.5H10.6702V16.25H5V2.5H10V7.5H15V10.6055H16.25V7.13388C16.25 6.80236 16.1183 6.48442 15.8839 6.25L15.7808 6.14692L15.7794 6.14556L11.1419 1.50806C11.036 1.40209 10.9104 1.3443 10.7858 1.32256C10.6523 1.27498 10.5105 1.25 10.3661 1.25H5ZM14.1161 6.25H11.25V3.38388L14.1161 6.25Z" fill="#07C05F"></path>
|
||||
<path d="M15 18.75V16.25H12.5V15H15V12.5H16.25V15H18.75V16.25H16.25V18.75H15Z" fill="#07C05F"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 635 B |
@@ -0,0 +1,4 @@
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5 1.25C4.30482 1.25 3.75 1.80482 3.75 2.5V16.25C3.75 16.9451 4.30482 17.5 5 17.5H10.6702V16.25H5V2.5H10V7.5H15V10.6055H16.25V7.13388C16.25 6.80236 16.1183 6.48442 15.8839 6.25L15.7808 6.14692L15.7794 6.14556L11.1419 1.50806C11.036 1.40209 10.9104 1.3443 10.7858 1.32256C10.6523 1.27498 10.5105 1.25 10.3661 1.25H5ZM14.1161 6.25H11.25V3.38388L14.1161 6.25Z" fill="#07C05F"/>
|
||||
<path d="M15 18.75V16.25H12.5V15H15V12.5H16.25V15H18.75V16.25H16.25V18.75H15Z" fill="#07C05F"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 583 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="g8nqf16e8__design-iconfont" width="128" height="128">
|
||||
<path d="M5 1.25C4.30482 1.25 3.75 1.80482 3.75 2.5V16.25C3.75 16.9451 4.30482 17.5 5 17.5H10.6702V16.25H5V2.5H10V7.5H15V10.6055H16.25V7.13388C16.25 6.80236 16.1183 6.48442 15.8839 6.25L15.7808 6.14692L15.7794 6.14556L11.1419 1.50806C11.036 1.40209 10.9104 1.3443 10.7858 1.32256C10.6523 1.27498 10.5105 1.25 10.3661 1.25H5ZM14.1161 6.25H11.25V3.38388L14.1161 6.25Z" fill="#666666"></path>
|
||||
<path d="M15 18.75V16.25H12.5V15H15V12.5H16.25V15H18.75V16.25H16.25V18.75H15Z" fill="#666666"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 635 B |
|
After Width: | Height: | Size: 128 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#07C05F" fill-opacity=".9"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#07C05F" fill-opacity=".9"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 851 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#737373" fill-opacity=".9"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#737373" fill-opacity=".9"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 851 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="45o4l8wsy__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.875 2.5C1.875 2.15483 2.15482 1.875 2.5 1.875H17.5C17.8451 1.875 18.125 2.15483 18.125 2.5V13.75C18.125 14.0951 17.8451 14.375 17.5 14.375H9.04274L6.10514 17.9001C5.93669 18.1023 5.65965 18.1773 5.41224 18.0876C5.16481 17.9981 5 17.7631 5 17.5V14.375H2.5C2.15482 14.375 1.875 14.0951 1.875 13.75V2.5ZM3.125 3.125V13.125H5.625C5.97017 13.125 6.25 13.4049 6.25 13.75V15.7738L8.26986 13.3499C8.38861 13.2074 8.56451 13.125 8.75 13.125H16.875V3.125H3.125Z" fill="#000000" fill-opacity=".9"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.375 5H10.625V8.44961L13.5154 10.762L12.7346 11.738L9.375 9.05039V5Z" fill="#000000" fill-opacity=".9"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 851 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.942 2.05808C18.1094 2.22548 18.1677 2.47308 18.093 2.69767L13.093 17.6976C13.02 17.9164 12.8328 18.0771 12.6055 18.116C12.3784 18.155 12.1482 18.0656 12.0067 17.8838L7.67964 12.3204L2.1163 7.99337C1.93436 7.85185 1.84507 7.62169 1.88399 7.3945C1.9229 7.16732 2.0837 6.97998 2.30237 6.90709L17.3024 1.90709C17.527 1.83223 17.7745 1.89068 17.942 2.05808ZM8.9571 11.9268L12.2764 16.1945L16.5118 3.48823L3.80555 7.72365L8.07321 11.0429L10.8081 8.30808L11.692 9.19197L8.9571 11.9268Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 651 B |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 12.5C11.3807 12.5 12.5 11.3807 12.5 10C12.5 8.61929 11.3807 7.5 10 7.5C8.61929 7.5 7.5 8.61929 7.5 10C7.5 11.3807 8.61929 12.5 10 12.5Z" stroke="#07C05F" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M1.66675 10.7333V9.26667C1.66675 8.4 2.37508 7.68333 3.25008 7.68333C4.75841 7.68333 5.35008 6.61667 4.59175 5.30833C4.14175 4.55833 4.38341 3.58333 5.14175 3.13333L6.58342 2.30833C7.24175 1.90833 8.09175 2.125 8.49175 2.78333L8.57508 2.92501C9.32508 4.23334 10.6751 4.23334 11.4334 2.92501L11.5167 2.78333C11.9167 2.125 12.7667 1.90833 13.4251 2.30833L14.8667 3.13333C15.6251 3.58333 15.8667 4.55833 15.4167 5.30833C14.6584 6.61667 15.2501 7.68333 16.7584 7.68333C17.6251 7.68333 18.3417 8.39167 18.3417 9.26667V10.7333C18.3417 11.6 17.6334 12.3167 16.7584 12.3167C15.2501 12.3167 14.6584 13.3833 15.4167 14.6917C15.8667 15.45 15.6251 16.4167 14.8667 16.8667L13.4251 17.6917C12.7667 18.0917 11.9167 17.875 11.5167 17.2167L11.4334 17.075C10.6834 15.7667 9.33341 15.7667 8.57508 17.075L8.49175 17.2167C8.09175 17.875 7.24175 18.0917 6.58342 17.6917L5.14175 16.8667C4.38341 16.4167 4.14175 15.4417 4.59175 14.6917C5.35008 13.3833 4.75841 12.3167 3.25008 12.3167C2.37508 12.3167 1.66675 11.6 1.66675 10.7333Z" stroke="#07C05F" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 12.5C11.3807 12.5 12.5 11.3807 12.5 10C12.5 8.61929 11.3807 7.5 10 7.5C8.61929 7.5 7.5 8.61929 7.5 10C7.5 11.3807 8.61929 12.5 10 12.5Z" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M1.66675 10.7333V9.26667C1.66675 8.4 2.37508 7.68333 3.25008 7.68333C4.75841 7.68333 5.35008 6.61667 4.59175 5.30833C4.14175 4.55833 4.38341 3.58333 5.14175 3.13333L6.58342 2.30833C7.24175 1.90833 8.09175 2.125 8.49175 2.78333L8.57508 2.92501C9.32508 4.23334 10.6751 4.23334 11.4334 2.92501L11.5167 2.78333C11.9167 2.125 12.7667 1.90833 13.4251 2.30833L14.8667 3.13333C15.6251 3.58333 15.8667 4.55833 15.4167 5.30833C14.6584 6.61667 15.2501 7.68333 16.7584 7.68333C17.6251 7.68333 18.3417 8.39167 18.3417 9.26667V10.7333C18.3417 11.6 17.6334 12.3167 16.7584 12.3167C15.2501 12.3167 14.6584 13.3833 15.4167 14.6917C15.8667 15.45 15.6251 16.4167 14.8667 16.8667L13.4251 17.6917C12.7667 18.0917 11.9167 17.875 11.5167 17.2167L11.4334 17.075C10.6834 15.7667 9.33341 15.7667 8.57508 17.075L8.49175 17.2167C8.09175 17.875 7.24175 18.0917 6.58342 17.6917L5.14175 16.8667C4.38341 16.4167 4.14175 15.4417 4.59175 14.6917C5.35008 13.3833 4.75841 12.3167 3.25008 12.3167C2.37508 12.3167 1.66675 11.6 1.66675 10.7333Z" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 334 KiB |
@@ -0,0 +1,64 @@
|
||||
<svg width="164" height="162" viewBox="0 0 164 162" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6022_51714)">
|
||||
<path d="M44.6 135C22.7296 135 5 117.238 5 95.3265C5 73.4155 22.7296 55.6531 44.6 55.6531C48.5782 55.6531 52.4203 56.2409 56.0426 57.3345C58.7553 40.1439 73.6125 27 91.5333 27C111.378 27 127.467 43.1177 127.467 63C127.467 65.7803 127.152 68.487 126.556 71.0862C126.737 71.0832 126.919 71.0816 127.1 71.0816C144.718 71.0816 159 85.3902 159 103.041C159 120.691 144.718 135 127.1 135H44.6Z" fill="url(#paint0_linear_6022_51714)"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_d_6022_51714)">
|
||||
<path d="M50.4857 131C30.8876 131 15 115.047 15 95.3673C15 75.688 30.8876 59.7347 50.4857 59.7347C54.0506 59.7347 57.4935 60.2626 60.7395 61.2448C63.1704 45.8051 76.4839 34 92.5429 34C110.326 34 124.743 48.4761 124.743 66.3333C124.743 68.8305 124.46 71.2615 123.927 73.5959C124.089 73.5932 124.252 73.5918 124.414 73.5918C140.202 73.5918 153 86.4431 153 102.296C153 118.149 140.202 131 124.414 131H50.4857Z" fill="url(#paint1_linear_6022_51714)"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_d_6022_51714)">
|
||||
<path d="M54.8571 127C37.8153 127 24 113.185 24 96.1429C24 79.1009 37.8153 65.2857 54.8571 65.2857C57.957 65.2857 60.9509 65.7429 63.7734 66.5935C65.8873 53.223 77.4643 43 91.4286 43C106.892 43 119.429 55.536 119.429 71C119.429 73.1625 119.183 75.2677 118.719 77.2893C118.86 77.2869 119.002 77.2857 119.143 77.2857C132.871 77.2857 144 88.4146 144 102.143C144 115.871 132.871 127 119.143 127H54.8571Z" fill="url(#paint2_linear_6022_51714)"/>
|
||||
</g>
|
||||
<path d="M97.8271 117.721C97.8271 116.644 98.7004 115.771 99.7775 115.771H104.978C106.056 115.771 106.929 116.644 106.929 117.721V117.721C106.929 118.799 106.056 119.672 104.978 119.672H99.7775C98.7004 119.672 97.8271 118.799 97.8271 117.721V117.721Z" fill="#1485EE"/>
|
||||
<path d="M113.431 117.721C113.431 116.644 114.304 115.771 115.381 115.771H120.582C121.659 115.771 122.532 116.644 122.532 117.721V117.721C122.532 118.799 121.659 119.672 120.582 119.672H115.381C114.304 119.672 113.431 118.799 113.431 117.721V117.721Z" fill="#07C05F"/>
|
||||
<rect x="97.8271" y="115.121" width="9.10166" height="3.90071" rx="1.95036" fill="#439DF1"/>
|
||||
<rect x="113.431" y="115.121" width="9.10166" height="3.90071" rx="1.95036" fill="#39CD80"/>
|
||||
<path d="M87.4705 71.1458L102.226 88.5665C102.926 89.3929 102.339 90.6604 101.256 90.6604L93.4597 90.6604C92.7819 90.6604 92.2232 91.1918 92.1894 91.8688L91.2554 110.568C91.2153 111.37 90.5531 112 89.7498 112L83.2502 112C82.4469 112 81.7847 111.37 81.7446 110.568L80.8106 91.8688C80.7768 91.1918 80.2181 90.6604 79.5403 90.6604L71.7441 90.6604C70.661 90.6604 70.0735 89.3929 70.7736 88.5665L85.5295 71.1458C86.0375 70.546 86.9625 70.546 87.4705 71.1458Z" fill="url(#paint3_linear_6022_51714)"/>
|
||||
<defs>
|
||||
<filter id="filter0_d_6022_51714" x="0.789706" y="24.8949" width="162.421" height="116.421" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="2.10515"/>
|
||||
<feGaussianBlur stdDeviation="2.10515"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0.192691 0 0 0 0 0.192691 0 0 0 0 0.192691 0 0 0 0.1 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6022_51714"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6022_51714" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_d_6022_51714" x="11" y="32" width="146" height="105" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="2"/>
|
||||
<feGaussianBlur stdDeviation="2"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6022_51714"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6022_51714" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter2_d_6022_51714" x="20" y="41" width="128" height="92" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="2"/>
|
||||
<feGaussianBlur stdDeviation="2"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6022_51714"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6022_51714" result="shape"/>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_6022_51714" x1="82" y1="27" x2="82" y2="134.714" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#F0FFF7"/>
|
||||
<stop offset="1" stop-color="#9EDEBD"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_6022_51714" x1="84" y1="131" x2="84" y2="34" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#DBFAE9"/>
|
||||
<stop offset="1" stop-color="#2CD87E"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_6022_51714" x1="84" y1="43" x2="84" y2="127" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#F3FFF7"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_6022_51714" x1="86.5001" y1="73.1689" x2="86.5001" y2="138.762" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#83C1FA"/>
|
||||
<stop offset="1" stop-color="#83C1FA" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,100 @@
|
||||
<svg width="162" height="162" viewBox="0 0 162 162" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6022_51731)">
|
||||
<path d="M36.875 78L20 111.75V133.047C20 140.76 26.2526 147.013 33.9655 147.013H80.75H127.534C135.247 147.013 141.5 140.76 141.5 133.047V111.75L124.625 78H80.75H36.875Z" fill="url(#paint0_linear_6022_51731)"/>
|
||||
</g>
|
||||
<path d="M37.125 111.375V77.625L20.25 111.375H37.125Z" fill="url(#paint1_linear_6022_51731)"/>
|
||||
<path d="M125 111.75V78L141.875 111.75H125Z" fill="url(#paint2_linear_6022_51731)"/>
|
||||
<path d="M77.9864 108.627L66.274 93.7436C65.4029 92.6365 66.1915 91.0125 67.6002 91.0125H72.635C73.567 91.0125 74.3292 90.2625 74.2011 89.3394C72.6754 78.3503 56.8805 59.4355 33.1007 50.8549C32.1729 50.5201 32.4067 48.9375 33.393 48.9375H125.232C126.218 48.9375 126.452 50.5201 125.524 50.8549C101.744 59.4355 85.9496 78.3503 84.4239 89.3394C84.2957 90.2625 85.058 91.0125 85.99 91.0125H91.0248C92.4335 91.0125 93.2221 92.6365 92.351 93.7436L80.6386 108.627C79.963 109.486 78.662 109.486 77.9864 108.627Z" fill="url(#paint3_linear_6022_51731)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M67.604 111.375H20.25V133.138C20.25 140.594 26.2942 146.638 33.75 146.638H128.25C135.706 146.638 141.75 140.594 141.75 133.138V111.375H94.3951C93.5647 118.034 87.8839 123.188 80.9995 123.188C74.1152 123.188 68.4344 118.034 67.604 111.375Z" fill="url(#paint4_linear_6022_51731)"/>
|
||||
<path d="M46.9366 18.5436C46.7408 18.1411 46.7129 17.6774 46.8591 17.2544L49.1102 10.7375C49.871 8.5352 52.2729 7.36661 54.4752 8.12734L68.8304 13.0861C71.0326 13.8468 72.2012 16.2488 71.4405 18.4511L67.5837 29.6162C66.8229 31.8185 64.421 32.9871 62.2187 32.2263L52.5117 28.8732C52.0887 28.7271 51.7411 28.4189 51.5453 28.0165L46.9366 18.5436Z" fill="url(#paint5_linear_6022_51731)"/>
|
||||
<mask id="mask0_6022_51731" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="46" y="7" width="26" height="26">
|
||||
<path d="M46.9366 18.5436C46.7408 18.1411 46.7129 17.6774 46.8591 17.2544L49.1102 10.7375C49.871 8.5352 52.2729 7.36661 54.4752 8.12734L68.8304 13.0861C71.0326 13.8468 72.2012 16.2488 71.4405 18.4511L67.5837 29.6162C66.8229 31.8185 64.421 32.9871 62.2187 32.2263L52.5117 28.8732C52.0887 28.7271 51.7411 28.4189 51.5453 28.0165L46.9366 18.5436Z" fill="#D9D9D9"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_6022_51731)">
|
||||
<path d="M43.876 25.8901L46.6308 17.915L51.4159 19.568C53.1777 20.1765 54.1126 22.0981 53.504 23.8599L51.8511 28.645L43.876 25.8901Z" fill="#B5ECCF"/>
|
||||
</g>
|
||||
<path d="M89.5572 16.4385C89.6665 16.1181 89.8987 15.8543 90.2025 15.7051L94.8832 13.4066C96.4649 12.6299 98.3768 13.2825 99.1535 14.8642L104.217 25.1746C104.993 26.7563 104.341 28.6682 102.759 29.445L94.7398 33.3829C93.1581 34.1596 91.2462 33.5071 90.4695 31.9253L87.0458 24.9535C86.8966 24.6496 86.8742 24.299 86.9836 23.9786L89.5572 16.4385Z" fill="url(#paint6_linear_6022_51731)"/>
|
||||
<mask id="mask1_6022_51731" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="86" y="13" width="19" height="21">
|
||||
<path d="M89.5572 16.4385C89.6665 16.1181 89.8987 15.8543 90.2025 15.7051L94.8832 13.4066C96.4649 12.6299 98.3768 13.2825 99.1535 14.8642L104.217 25.1746C104.993 26.7563 104.341 28.6682 102.759 29.445L94.7398 33.3829C93.1581 34.1596 91.2462 33.5071 90.4695 31.9253L87.0458 24.9535C86.8966 24.6496 86.8742 24.299 86.9836 23.9786L89.5572 16.4385Z" fill="#D9D9D9"/>
|
||||
</mask>
|
||||
<g mask="url(#mask1_6022_51731)">
|
||||
<path d="M84 18.751L89.728 15.9382L91.4157 19.375C92.0371 20.6403 91.515 22.1699 90.2496 22.7913L86.8128 24.479L84 18.751Z" fill="#E7E7E7"/>
|
||||
</g>
|
||||
<path d="M46.3734 57.2289C46.2502 57.6125 45.9796 57.9315 45.6213 58.1157L40.1001 60.9532C38.2344 61.9121 35.9445 61.1769 34.9857 59.3111L28.7354 47.1494C27.7766 45.2836 28.5118 42.9938 30.3775 42.0349L39.8366 37.1736C41.7024 36.2148 43.9922 36.95 44.9511 38.8157L49.1775 47.0395C49.3617 47.3979 49.3959 47.8147 49.2728 48.1984L46.3734 57.2289Z" fill="url(#paint7_linear_6022_51731)"/>
|
||||
<mask id="mask2_6022_51731" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="28" y="36" width="22" height="26">
|
||||
<path d="M46.3734 57.2289C46.2502 57.6125 45.9796 57.9315 45.6213 58.1157L40.1001 60.9532C38.2344 61.9121 35.9445 61.1769 34.9857 59.3111L28.7354 47.1494C27.7766 45.2836 28.5118 42.9938 30.3775 42.0349L39.8366 37.1736C41.7024 36.2148 43.9922 36.95 44.9511 38.8157L49.1775 47.0395C49.3617 47.3979 49.3959 47.8147 49.2728 48.1984L46.3734 57.2289Z" fill="#D9D9D9"/>
|
||||
</mask>
|
||||
<g mask="url(#mask2_6022_51731)">
|
||||
<path d="M52.9375 54.3557L46.181 57.8281L44.0976 53.7742C43.3305 52.2816 43.9186 50.4497 45.4112 49.6826L49.4651 47.5992L52.9375 54.3557Z" fill="#E7E7E7"/>
|
||||
</g>
|
||||
<path d="M120.88 37.3892C121.203 37.4758 121.479 37.6872 121.646 37.9769L124.223 42.4399C125.093 43.9481 124.577 45.8766 123.069 46.7474L113.238 52.4233C111.729 53.294 109.801 52.7773 108.93 51.2691L104.515 43.6228C103.645 42.1146 104.161 40.1861 105.67 39.3153L112.317 35.4773C112.607 35.31 112.951 35.2647 113.274 35.3513L120.88 37.3892Z" fill="url(#paint8_linear_6022_51731)"/>
|
||||
<mask id="mask3_6022_51731" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="104" y="35" width="21" height="18">
|
||||
<path d="M120.88 37.3892C121.203 37.4758 121.479 37.6872 121.646 37.9769L124.223 42.4399C125.093 43.9481 124.577 45.8766 123.069 46.7474L113.238 52.4233C111.729 53.294 109.801 52.7773 108.93 51.2691L104.515 43.6228C103.645 42.1146 104.161 40.1861 105.67 39.3153L112.317 35.4773C112.607 35.31 112.951 35.2647 113.274 35.3513L120.88 37.3892Z" fill="#D9D9D9"/>
|
||||
</mask>
|
||||
<g mask="url(#mask3_6022_51731)">
|
||||
<path d="M118.231 32.0627L121.385 37.5244L118.108 39.4164C116.901 40.113 115.358 39.6996 114.662 38.493L112.77 35.216L118.231 32.0627Z" fill="#B5ECCF"/>
|
||||
</g>
|
||||
<path d="M73.3483 45.0984C73.3478 44.8468 73.4473 44.6053 73.6248 44.427L76.3603 41.6805C77.2847 40.7524 78.7864 40.7494 79.7145 41.6738L85.7643 47.6993C86.6924 48.6237 86.6955 50.1255 85.7711 51.0536L81.0845 55.759C80.1601 56.6871 78.6584 56.6901 77.7303 55.7657L73.6394 51.6912C73.4611 51.5137 73.3607 51.2726 73.3602 51.021L73.3483 45.0984Z" fill="url(#paint9_linear_6022_51731)"/>
|
||||
<mask id="mask4_6022_51731" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="73" y="40" width="14" height="17">
|
||||
<path d="M73.3483 45.0984C73.3478 44.8468 73.4473 44.6053 73.6248 44.427L76.3603 41.6805C77.2847 40.7524 78.7864 40.7494 79.7145 41.6738L85.7643 47.6993C86.6924 48.6237 86.6955 50.1255 85.7711 51.0536L81.0845 55.759C80.1601 56.6871 78.6584 56.6901 77.7303 55.7657L73.6394 51.6912C73.4611 51.5137 73.3607 51.2726 73.3602 51.021L73.3483 45.0984Z" fill="#D9D9D9"/>
|
||||
</mask>
|
||||
<g mask="url(#mask4_6022_51731)">
|
||||
<path d="M70 48.0664L73.3475 44.7054L75.3641 46.7139C76.1066 47.4534 76.109 48.6548 75.3695 49.3973L73.361 51.4139L70 48.0664Z" fill="#07C05F"/>
|
||||
</g>
|
||||
<path d="M106.138 120.103C106.138 118.946 107.076 118.009 108.233 118.009H113.819C114.976 118.009 115.914 118.946 115.914 120.103V120.103C115.914 121.26 114.976 122.198 113.819 122.198H108.233C107.076 122.198 106.138 121.26 106.138 120.103V120.103Z" fill="#1485EE"/>
|
||||
<path d="M122.896 120.103C122.896 118.946 123.834 118.009 124.991 118.009H130.578C131.734 118.009 132.672 118.946 132.672 120.103V120.103C132.672 121.26 131.734 122.198 130.578 122.198H124.991C123.834 122.198 122.896 121.26 122.896 120.103V120.103Z" fill="#07C05F"/>
|
||||
<rect x="106.138" y="117.31" width="9.77586" height="4.18966" rx="2.09483" fill="#439DF1"/>
|
||||
<rect x="122.896" y="117.31" width="9.77586" height="4.18966" rx="2.09483" fill="#39CD80"/>
|
||||
<defs>
|
||||
<filter id="filter0_d_6022_51731" x="14.4138" y="75.2069" width="132.672" height="80.1854" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="2.7931"/>
|
||||
<feGaussianBlur stdDeviation="2.7931"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0.192691 0 0 0 0 0.192691 0 0 0 0 0.192691 0 0 0 0.1 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6022_51731"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6022_51731" result="shape"/>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_6022_51731" x1="80.75" y1="78" x2="80.75" y2="132" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#E4F9EE"/>
|
||||
<stop offset="1" stop-color="#9EDEBD"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_6022_51731" x1="28.6875" y1="77.625" x2="28.6875" y2="111.375" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#DBFAE9"/>
|
||||
<stop offset="1" stop-color="#2CD87E"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_6022_51731" x1="133.438" y1="78" x2="133.438" y2="111.75" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#DBFAE9"/>
|
||||
<stop offset="1" stop-color="#2CD87E"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_6022_51731" x1="79.3125" y1="106.312" x2="79.3125" y2="48.9375" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#83C1FA"/>
|
||||
<stop offset="1" stop-color="#83C1FA" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_6022_51731" x1="81" y1="111.375" x2="81" y2="146.638" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#F3FFF7"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_6022_51731" x1="47.1818" y1="16.32" x2="69.5121" y2="24.0336" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#07C05F"/>
|
||||
<stop offset="1" stop-color="#07C05F" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear_6022_51731" x1="90.8736" y1="15.3756" x2="98.7494" y2="31.4139" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C5C5C5"/>
|
||||
<stop offset="1" stop-color="#C5C5C5" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint7_linear_6022_51731" x1="44.8297" y1="58.5225" x2="35.1071" y2="39.6043" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C5C5C5"/>
|
||||
<stop offset="1" stop-color="#C5C5C5" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint8_linear_6022_51731" x1="121.732" y1="38.1262" x2="105.974" y2="45.8244" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#54E89A"/>
|
||||
<stop offset="1" stop-color="#07C05F" stop-opacity="0.1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint9_linear_6022_51731" x1="73.6562" y1="44.3955" x2="82.2446" y2="54.3731" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#6EE1A5"/>
|
||||
<stop offset="1" stop-color="#6EE1A5" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="cvw0hqhj9__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#07C05F"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" class="cvw0hqhj9__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#717171"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" class="gh6beppe9__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 3C2 2.17157 2.67157 1.5 3.5 1.5H12C12.2761 1.5 12.5 1.72386 12.5 2V11C12.5 11.2761 12.2761 11.5 12 11.5H4C3.44772 11.5 3 11.9477 3 12.5C3 13.0523 3.44772 13.5 4 13.5H13V2.5H14V14C14 14.2761 13.7761 14.5 13.5 14.5H4C2.89543 14.5 2 13.6046 2 12.5V3ZM3 10.7676C3.29417 10.5974 3.63571 10.5 4 10.5H11.5V2.5H3.5C3.22386 2.5 3 2.72386 3 3V10.7676ZM12.5 13H3.5V12H12.5V13Z" fill="#32CE3F"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 583 B |
@@ -0,0 +1,135 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, defineEmits, onMounted, defineProps, defineExpose } from "vue";
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
|
||||
import { onBeforeRouteUpdate } from 'vue-router';
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
let { cardList, total, getKnowled } = useKnowledgeBase()
|
||||
let query = ref("");
|
||||
const props = defineProps({
|
||||
isReplying: {
|
||||
type: Boolean,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
onMounted(() => {
|
||||
getKnowled()
|
||||
})
|
||||
const emit = defineEmits(['send-msg']);
|
||||
const createSession = (val: string) => {
|
||||
if (!val.trim()) {
|
||||
MessagePlugin.info("请先输入内容!");
|
||||
return
|
||||
}
|
||||
if (!query.value && cardList.value.length == 0) {
|
||||
MessagePlugin.info("请先上传知识库!");
|
||||
return;
|
||||
}
|
||||
if (props.isReplying) {
|
||||
return MessagePlugin.error("正在回复中,请稍后再试!");
|
||||
}
|
||||
emit('send-msg', val);
|
||||
clearvalue();
|
||||
}
|
||||
const clearvalue = () => {
|
||||
query.value = "";
|
||||
}
|
||||
const onKeydown = (val: string, event: { e: { preventDefault(): unknown; keyCode: number; shiftKey: any; ctrlKey: any; }; }) => {
|
||||
if ((event.e.keyCode == 13 && event.e.shiftKey) || (event.e.keyCode == 13 && event.e.ctrlKey)) {
|
||||
return;
|
||||
}
|
||||
if (event.e.keyCode == 13) {
|
||||
event.e.preventDefault();
|
||||
createSession(val)
|
||||
}
|
||||
}
|
||||
onBeforeRouteUpdate((to, from, next) => {
|
||||
clearvalue()
|
||||
next()
|
||||
})
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div class="answers-input">
|
||||
<t-textarea v-model="query" placeholder="基于知识库提问" name="description" :autosize="true" @keydown="onKeydown" />
|
||||
<div class="answers-input-source">
|
||||
<span>{{ total }}个来源</span>
|
||||
</div>
|
||||
<div @click="createSession(query)" class="answers-input-send"
|
||||
:class="[query.length && total ? '' : 'grey-out']">
|
||||
<img src="../assets/img/sending-aircraft.svg" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
.answers-input {
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
bottom: 60px;
|
||||
left: 50%;
|
||||
transform: translateX(-400px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 100%;
|
||||
width: 800px;
|
||||
max-height: 250px !important;
|
||||
min-height: 112px !important;
|
||||
resize: none;
|
||||
color: #000000e6;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
line-height: 24px;
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
padding: 16px 12px 12px 16px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #E7E7E7;
|
||||
box-sizing: border-box;
|
||||
background: #FFF;
|
||||
box-shadow: 0 6px 6px 0 #0000000a, 0 12px 12px -1px #00000014;
|
||||
|
||||
&:focus {
|
||||
border: 1px solid #07C05F;
|
||||
}
|
||||
|
||||
&:placeholder {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.answers-input-send {
|
||||
background-color: #07C05F;
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
right: 12px;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.answers-input-source {
|
||||
position: absolute;
|
||||
bottom: 12px;
|
||||
right: 64px;
|
||||
line-height: 32px;
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.grey-out {
|
||||
background-color: #b5eccf !important;
|
||||
cursor: no-drop !important;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,426 @@
|
||||
:deep(.md-content) {
|
||||
box-sizing: border-box !important;
|
||||
|
||||
img {
|
||||
max-width: 444px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin-top: 5px;
|
||||
font-weight: bold;
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC", "Cascadia Code";
|
||||
transition: all 0.2s ease-out;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-title.class_,
|
||||
.hljs-title.class_.inherited__,
|
||||
.hljs-title.function_ {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.proto {
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
h1 tt,
|
||||
h1 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h2 tt,
|
||||
h2 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h3 tt,
|
||||
h3 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h4 tt,
|
||||
h4 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h5 tt,
|
||||
h5 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h6 tt,
|
||||
h6 code {
|
||||
font-size: inherit !important;
|
||||
}
|
||||
|
||||
h2 a,
|
||||
h3 a {
|
||||
color: #34495e;
|
||||
}
|
||||
|
||||
p,
|
||||
blockquote,
|
||||
ul,
|
||||
ol,
|
||||
dl,
|
||||
table {
|
||||
font-size: 14px;
|
||||
margin: 10px 0;
|
||||
font-family: "PingFang SC", "Cascadia Code";
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
summary {
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
li>ol,
|
||||
li>ul {
|
||||
margin: 0 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
padding: 0;
|
||||
margin: 32px 0;
|
||||
border-top: 0.5rem dotted #0590ff57;
|
||||
overflow: hidden;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
body>h2:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
body>h1:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
body>h1:first-child+h2 {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
body>h3:first-child,
|
||||
body>h4:first-child,
|
||||
body>h5:first-child,
|
||||
body>h6:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
a:first-child h1,
|
||||
a:first-child h2,
|
||||
a:first-child h3,
|
||||
a:first-child h4,
|
||||
a:first-child h5,
|
||||
a:first-child h6 {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
h1 p,
|
||||
h2 p,
|
||||
h3 p,
|
||||
h4 p,
|
||||
h5 p,
|
||||
h6 p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
li p.first {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
ul:first-child,
|
||||
ol:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ul:last-child,
|
||||
ol:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
padding: 0.8em 1.4rem;
|
||||
margin: 1em 0;
|
||||
font-weight: 400;
|
||||
border-left: 4px solid #2196f3;
|
||||
background-color: #2196f321;
|
||||
border-radius: 0px 8px 8px 0px;
|
||||
box-shadow: rgb(149 149 149 / 13%) 0px 5px 10px;
|
||||
}
|
||||
|
||||
table {
|
||||
padding: 0;
|
||||
word-break: initial;
|
||||
/* border-radius: 4px; */
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table tr {
|
||||
border-top: 1px solid #2196f31f;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table tr:nth-child(2n),
|
||||
thead {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
table tr th {
|
||||
font-weight: bold;
|
||||
border: 1px solid #9b9b9b3b;
|
||||
border-bottom: 0;
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
|
||||
table tr td {
|
||||
border: 1px solid #9b9b9b3b;
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
|
||||
table tr th:first-child,
|
||||
table tr td:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
table tr th:last-child,
|
||||
table tr td:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
tt {
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
figure {
|
||||
border-radius: 8px;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.md-task-list-item>input {
|
||||
margin-left: -1.3em;
|
||||
}
|
||||
|
||||
@media print {
|
||||
html {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
table,
|
||||
pre {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
pre {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.md-fences {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.md-diagram-panel {
|
||||
position: static !important;
|
||||
}
|
||||
|
||||
|
||||
.mathjax-block>.code-tooltip {
|
||||
bottom: 0.375rem;
|
||||
}
|
||||
|
||||
h3.md-focus:before,
|
||||
h4.md-focus:before,
|
||||
h5.md-focus:before,
|
||||
h6.md-focus:before {
|
||||
border: 0px;
|
||||
position: unset;
|
||||
padding: 0px;
|
||||
font-size: unset;
|
||||
line-height: unset;
|
||||
float: unset;
|
||||
}
|
||||
|
||||
.md-image>.md-meta {
|
||||
border-radius: 3px;
|
||||
font-family: var(--font-monospace);
|
||||
padding: 2px 0 0 4px;
|
||||
font-size: 0.9em;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.md-tag {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.md-toc {
|
||||
margin-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.sidebar-tabs {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
|
||||
/** focus mode */
|
||||
|
||||
.on-focus-mode blockquote {
|
||||
border-left-color: rgba(85, 85, 85, 0.12);
|
||||
}
|
||||
|
||||
header,
|
||||
.context-menu,
|
||||
.megamenu-content,
|
||||
footer {
|
||||
font-family: var(--font-sans-serif);
|
||||
}
|
||||
|
||||
.file-node-content:hover .file-node-icon,
|
||||
.file-node-content:hover .file-node-open-state {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.mac-seamless-mode #typora-sidebar {
|
||||
background-color: var(--side-bar-bg-color);
|
||||
}
|
||||
|
||||
.md-lang {
|
||||
color: #b4654d;
|
||||
}
|
||||
|
||||
.html-for-mac .context-menu {
|
||||
--item-hover-bg-color: #e6f0fe;
|
||||
}
|
||||
|
||||
.pin-outline #outline-content .outline-active strong,
|
||||
.pin-outline .outline-active {
|
||||
color: #2196f3;
|
||||
}
|
||||
|
||||
.code-tooltip {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ededed;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.cm-s-inner .cm-comment,
|
||||
.cm-s-inner.cm-comment {
|
||||
color: #57a64a;
|
||||
font-style: italic;
|
||||
/* font-family: 'PingFang'; */
|
||||
}
|
||||
|
||||
h1.md-end-block.md-heading:after,
|
||||
h2.md-end-block.md-heading:after,
|
||||
h3.md-end-block.md-heading:after,
|
||||
h4.md-end-block.md-heading:after,
|
||||
h5.md-end-block.md-heading:after,
|
||||
h6.md-end-block.md-heading:after {
|
||||
color: #bfbfbf !important;
|
||||
border: 1px solid;
|
||||
border-radius: 4px;
|
||||
position: absolute;
|
||||
left: -2.5rem;
|
||||
float: left;
|
||||
font-size: 14px;
|
||||
padding-left: 4px;
|
||||
padding-right: 5px;
|
||||
vertical-align: bottom;
|
||||
font-weight: 400;
|
||||
line-height: normal;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
h1.md-end-block.md-heading:hover:after,
|
||||
h2.md-end-block.md-heading:hover:after,
|
||||
h3.md-end-block.md-heading:hover:after,
|
||||
h4.md-end-block.md-heading:hover:after,
|
||||
h5.md-end-block.md-heading:hover:after,
|
||||
h6.md-end-block.md-heading:hover:after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
h1.md-end-block.md-heading:hover:after {
|
||||
content: "h1";
|
||||
top: 1.1rem;
|
||||
}
|
||||
|
||||
h2.md-end-block.md-heading:hover:after {
|
||||
content: "h2";
|
||||
top: 0.63rem;
|
||||
}
|
||||
|
||||
h3.md-end-block.md-heading:hover:after {
|
||||
content: "h3";
|
||||
top: 0.55rem;
|
||||
}
|
||||
|
||||
h4.md-end-block.md-heading:hover:after {
|
||||
content: "h4";
|
||||
top: 0.3rem;
|
||||
}
|
||||
|
||||
h5.md-end-block.md-heading:hover:after {
|
||||
content: "h5";
|
||||
top: 0.18rem;
|
||||
}
|
||||
|
||||
h6.md-end-block.md-heading:hover:after {
|
||||
content: "h6";
|
||||
top: 0.16rem;
|
||||
}
|
||||
|
||||
.outline-label {
|
||||
font-family: "Cascadia Code", "PingFang SC";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<script setup lang="ts">
|
||||
import { marked } from "marked";
|
||||
import { onMounted, ref, nextTick, onUnmounted, onUpdated, watch } from "vue";
|
||||
import { downKnowledgeDetails } from "@/api/knowledge-base/index";
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import picturePreview from '@/components/picture-preview.vue';
|
||||
marked.use({
|
||||
mangle: false,
|
||||
headerIds: false,
|
||||
});
|
||||
const renderer = new marked.Renderer();
|
||||
let page = 1;
|
||||
let doc = null;
|
||||
let down = ref()
|
||||
let mdContentWrap = ref()
|
||||
let url = ref('')
|
||||
let reviewUrl = ref('')
|
||||
let reviewImg = ref(false)
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
doc = document.getElementsByClassName('t-drawer__body')[0]
|
||||
doc.addEventListener('scroll', handleDetailsScroll);
|
||||
})
|
||||
})
|
||||
onUpdated(() => {
|
||||
page = 1
|
||||
})
|
||||
onUnmounted(() => {
|
||||
doc.removeEventListener('scroll', handleDetailsScroll);
|
||||
})
|
||||
const checkImage = (url) => {
|
||||
return new Promise((resolve) => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve(true);
|
||||
img.onerror = () => resolve(false);
|
||||
img.src = url;
|
||||
});
|
||||
};
|
||||
renderer.image = function (href, title, text) {
|
||||
// 自定义HTML结构,图片展示带标题
|
||||
return `<figure>
|
||||
<img class="markdown-image" src="${href}" alt="${title}" title="${text}">
|
||||
<figcaption style="text-align: left;">${text}</figcaption>
|
||||
</figure>`;
|
||||
};
|
||||
const props = defineProps(["visible", "details"]);
|
||||
const emit = defineEmits(["closeDoc", "getDoc"]);
|
||||
watch(() => props.details.md, (newVal) => {
|
||||
nextTick(async () => {
|
||||
const images = mdContentWrap.value.querySelectorAll('img.markdown-image');
|
||||
if (images) {
|
||||
images.forEach(async item => {
|
||||
item.addEventListener('click', function (event) {
|
||||
reviewUrl.value = event.target.src;
|
||||
reviewImg.value = true
|
||||
})
|
||||
const isValid = await checkImage(item.src);
|
||||
if (!isValid) {
|
||||
item.remove();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}, {
|
||||
immediate: true,
|
||||
deep: true
|
||||
})
|
||||
|
||||
// 处理 Markdown 中的图片
|
||||
const processMarkdown = (markdownText) => {
|
||||
// 自定义渲染器处理图片
|
||||
marked.use({ renderer });
|
||||
let html = marked.parse(markdownText);
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
return doc.body.innerHTML;
|
||||
};
|
||||
const closePreImg = () => {
|
||||
reviewImg.value = false
|
||||
reviewUrl.value = '';
|
||||
}
|
||||
const handleClose = () => {
|
||||
emit("closeDoc", false);
|
||||
doc.scrollTop = 0;
|
||||
};
|
||||
const downloadFile = () => {
|
||||
downKnowledgeDetails(props.details.id)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
url.value = URL.createObjectURL(result);
|
||||
down.value.click();
|
||||
// const link = document.createElement("a");
|
||||
// link.style.display = "none";
|
||||
// link.setAttribute("href", url);
|
||||
// link.setAttribute("download", props.details.title);
|
||||
// link.click();
|
||||
// document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
MessagePlugin.error("获取文件失败!");
|
||||
});
|
||||
};
|
||||
const handleDetailsScroll = () => {
|
||||
if (doc) {
|
||||
let pageNum = Math.ceil(props.details.total / 20);
|
||||
const { scrollTop, scrollHeight, clientHeight } = doc;
|
||||
if (scrollTop + clientHeight >= scrollHeight) {
|
||||
page++;
|
||||
if (props.details.md.length < props.details.total && page <= pageNum) {
|
||||
emit("getDoc", page);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<div class="doc_content" ref="mdContentWrap">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" @close="handleClose">
|
||||
<template #header>{{
|
||||
details.title.substring(0, details.title.lastIndexOf("."))
|
||||
}}</template>
|
||||
<div class="doc_box">
|
||||
<a :href="url" style="display: none" ref="down" :download="details.title"></a>
|
||||
<span class="label">文档标题</span>
|
||||
<div class="download_box">
|
||||
<span class="doc_t">{{ details.title }}</span>
|
||||
<div class="icon_box" @click="downloadFile()">
|
||||
<img class="download_box" src="@/assets/img/download.svg" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content_header">
|
||||
<span class="label">文档内容</span>
|
||||
<span class="time"> 更新时间:{{ details.time }} </span>
|
||||
</div>
|
||||
<div v-if="details.md.length == 0" class="no_content">暂无数据</div>
|
||||
<div v-else class="content" v-for="(item, index) in details.md" :key="index" :style="index % 2 !== 0
|
||||
? 'background: #07c05f26;'
|
||||
: 'background: #3032360f;'
|
||||
">
|
||||
<div class="md-content" v-html="processMarkdown(item.content)"></div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<t-button @click="handleClose">确定</t-button>
|
||||
<t-button theme="default" @click="handleClose">取消</t-button>
|
||||
</template>
|
||||
</t-drawer>
|
||||
<picturePreview :reviewImg="reviewImg" :reviewUrl="reviewUrl" @closePreImg="closePreImg"></picturePreview>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
@import "./css/markdown.less";
|
||||
|
||||
:deep(.t-drawer .t-drawer__content-wrapper) {
|
||||
width: 654px !important;
|
||||
}
|
||||
|
||||
:deep(.t-drawer__header) {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
:deep(.t-drawer__body.narrow-scrollbar) {
|
||||
padding: 16px 24px;
|
||||
}
|
||||
|
||||
.content {
|
||||
word-break: break-word;
|
||||
padding: 4px;
|
||||
gap: 4px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.doc_box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: #000000e6;
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
line-height: 22px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.download_box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.doc_t {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
padding: 5px 8px;
|
||||
align-items: center;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #dcdcdc;
|
||||
background: #30323605;
|
||||
word-break: break-all;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.icon_box {
|
||||
margin-left: 18px;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
color: #07c05f;
|
||||
|
||||
.download_box {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
fill: currentColor;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.content_header {
|
||||
margin-top: 22px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin-left: 12px;
|
||||
color: #00000066;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.no_content {
|
||||
margin-top: 12px;
|
||||
color: #00000066;
|
||||
font-size: 12px;
|
||||
padding: 16px;
|
||||
background: #fbfbfb;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
<template>
|
||||
<div class="empty">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">知识为空,拖放上传</span>
|
||||
<span class="empty-type-txt">pdf、doc 格式文件,不超过10M</span>
|
||||
<span class="empty-type-txt">text、markdown格式文件,不超过200K</span>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
.empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.empty-txt {
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 26px;
|
||||
margin: 12px 0 16px 0;
|
||||
}
|
||||
|
||||
.empty-type-txt {
|
||||
color: #00000066;
|
||||
text-align: center;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
width: 217px;
|
||||
}
|
||||
|
||||
.empty-img {
|
||||
width: 162px;
|
||||
height: 162px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,453 @@
|
||||
<template>
|
||||
<div class="aside_box">
|
||||
<div class="logo_box">
|
||||
<img class="logo" src="@/assets/img/weknora.png" alt="">
|
||||
</div>
|
||||
<div class="menu_box" v-for="(item, index) in menuArr" :key="index">
|
||||
<div @click="gotopage(item.path)"
|
||||
@mouseenter="mouseenteMenu(item.path)" @mouseleave="mouseleaveMenu(item.path)"
|
||||
:class="['menu_item', item.childrenPath && item.childrenPath == currentpath ? 'menu_item_c_active' : item.path == currentpath ? 'menu_item_active' : '']">
|
||||
<div class="menu_item-box">
|
||||
<div class="menu_icon">
|
||||
<img class="icon" :src="getImgSrc(item.icon == 'zhishiku' ? knowledgeIcon : item.icon == 'setting' ? settingIcon : prefixIcon)" alt="">
|
||||
</div>
|
||||
<span class="menu_title">{{ item.title }}</span>
|
||||
</div>
|
||||
<t-popup overlayInnerClassName="upload-popup" class="placement top center" content="上传知识"
|
||||
placement="top" show-arrow destroy-on-close>
|
||||
<div class="upload-file-wrap" @click="uploadFile" variant="outline"
|
||||
v-if="item.path == 'knowledgeBase'">
|
||||
<img class="upload-file-icon" :class="[item.path == currentpath ? 'active-upload' : '']"
|
||||
:src="getImgSrc(fileAddIcon)" alt="">
|
||||
</div>
|
||||
</t-popup>
|
||||
</div>
|
||||
<div ref="submenuscrollContainer" @scroll="handleScroll" class="submenu" v-if="item.children">
|
||||
<div class="submenu_item_p" v-for="(subitem, subindex) in item.children" :key="subindex"
|
||||
@click="gotopage(subitem.path)">
|
||||
<div :class="['submenu_item', currentSecondpath == subitem.path ? 'submenu_item_active' : '']"
|
||||
@mouseenter="mouseenteBotDownr(subindex)" @mouseleave="mouseleaveBotDown">
|
||||
<i v-if="currentSecondpath == subitem.path" class="dot"></i>
|
||||
<span class="submenu_title"
|
||||
:style="currentSecondpath == subitem.path ? 'margin-left:14px;max-width:160px;' : 'margin-left:18px;max-width:173px;'">
|
||||
{{ subitem.title }}
|
||||
</span>
|
||||
<t-popup v-model:visible="subitem.isMore" @overlay-click="delCard(subindex, subitem)"
|
||||
@visible-change="onVisibleChange" overlayClassName="del-menu-popup" trigger="click"
|
||||
destroy-on-close placement="top-left">
|
||||
<div v-if="(activeSubmenu == subindex) || (currentSecondpath == subitem.path) || subitem.isMore"
|
||||
@click.stop="openMore(subindex)" variant="outline" class="menu-more-wrap">
|
||||
<t-icon name="ellipsis" class="menu-more" />
|
||||
</div>
|
||||
<template #content>
|
||||
<span class="del_submenu">删除记录</span>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="file" @change="upload" style="display: none" ref="uploadInput"
|
||||
accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onMounted, watch, computed, ref, reactive } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { getSessionsList, delSession } from "@/api/chat/index";
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
let { requestMethod } = useKnowledgeBase()
|
||||
let uploadInput = ref();
|
||||
const usemenuStore = useMenuStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const currentpath = ref('');
|
||||
const currentPage = ref(1);
|
||||
const page_size = ref(30);
|
||||
const total = ref(0);
|
||||
const currentSecondpath = ref('');
|
||||
const submenuscrollContainer = ref(null);
|
||||
// 计算总页数
|
||||
const totalPages = computed(() => Math.ceil(total.value / page_size.value));
|
||||
const hasMore = computed(() => currentPage.value < totalPages.value);
|
||||
const { menuArr } = storeToRefs(usemenuStore);
|
||||
let activeSubmenu = ref(-1);
|
||||
const loading = ref(false)
|
||||
const uploadFile = () => {
|
||||
uploadInput.value.click()
|
||||
}
|
||||
const upload = (e) => {
|
||||
requestMethod(e.target.files[0], uploadInput)
|
||||
}
|
||||
const mouseenteBotDownr = (val) => {
|
||||
activeSubmenu.value = val;
|
||||
}
|
||||
const mouseleaveBotDown = () => {
|
||||
activeSubmenu.value = -1;
|
||||
}
|
||||
const onVisibleChange = (e) => {
|
||||
}
|
||||
|
||||
const delCard = (index, item) => {
|
||||
delSession(item.id).then(res => {
|
||||
if (res && res.success) {
|
||||
menuArr.value[1].children.splice(index, 1);
|
||||
if (item.id == route.params.chatid) {
|
||||
router.push('/platform/creatChat');
|
||||
}
|
||||
} else {
|
||||
MessagePlugin.error("删除失败,请稍后再试!");
|
||||
}
|
||||
})
|
||||
}
|
||||
const debounce = (fn, delay) => {
|
||||
let timer
|
||||
return (...args) => {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => fn(...args), delay)
|
||||
}
|
||||
}
|
||||
// 滚动处理
|
||||
const checkScrollBottom = () => {
|
||||
const container = submenuscrollContainer.value
|
||||
if (!container) return
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = container[0]
|
||||
const isBottom = scrollHeight - (scrollTop + clientHeight) < 100 // 触底阈值
|
||||
if (isBottom && hasMore.value) {
|
||||
currentPage.value++;
|
||||
getMessageList();
|
||||
}
|
||||
}
|
||||
const handleScroll = debounce(checkScrollBottom, 200)
|
||||
const getMessageList = () => {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
getSessionsList(currentPage.value, page_size.value).then(res => {
|
||||
if (res.data && res.data.length) {
|
||||
res.data.forEach(item => {
|
||||
let obj = { title: item.title ? item.title : "新会话", path: `chat/${item.id}`, id: item.id, isMore: false, isNoTitle: item.title ? false : true }
|
||||
usemenuStore.updatemenuArr(obj)
|
||||
});
|
||||
loading.value = false;
|
||||
}
|
||||
if (res.total) {
|
||||
total.value = res.total;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const openMore = (e) => { }
|
||||
onMounted(() => {
|
||||
currentpath.value = route.name;
|
||||
if (route.params.chatid) {
|
||||
currentSecondpath.value = `${route.name}/${route.params.chatid}`;
|
||||
}
|
||||
getMessageList();
|
||||
});
|
||||
|
||||
watch([() => route.name, () => route.params], (newvalue) => {
|
||||
currentpath.value = newvalue[0];
|
||||
if (newvalue[1].chatid) {
|
||||
currentSecondpath.value = `${newvalue[0]}/${newvalue[1].chatid}`;
|
||||
} else {
|
||||
currentSecondpath.value = "";
|
||||
}
|
||||
|
||||
});
|
||||
let fileAddIcon = ref('file-add-green.svg');
|
||||
let knowledgeIcon = ref('zhishiku-green.svg');
|
||||
let prefixIcon = ref('prefixIcon.svg');
|
||||
let settingIcon = ref('setting.svg');
|
||||
let pathPrefix = ref(route.name)
|
||||
const getIcon = (path) => {
|
||||
fileAddIcon.value = path == 'knowledgeBase' ? 'file-add-green.svg' : 'file-add.svg';
|
||||
knowledgeIcon.value = path == 'knowledgeBase' ? 'zhishiku-green.svg' : 'zhishiku.svg';
|
||||
prefixIcon.value = path == 'creatChat' ? 'prefixIcon-green.svg' : path == 'knowledgeBase' ? 'prefixIcon-grey.svg' : 'prefixIcon.svg';
|
||||
settingIcon.value = path == 'settings' ? 'setting-green.svg' : 'setting.svg';
|
||||
}
|
||||
getIcon(route.name)
|
||||
const gotopage = (path) => {
|
||||
pathPrefix.value = path;
|
||||
router.push(`/platform/${path}`);
|
||||
getIcon(path)
|
||||
}
|
||||
|
||||
const getImgSrc = (url) => {
|
||||
return new URL(`/src/assets/img/${url}`, import.meta.url).href;
|
||||
}
|
||||
|
||||
const mouseenteMenu = (path) => {
|
||||
if (pathPrefix.value != 'knowledgeBase' && pathPrefix.value != 'creatChat' && path != 'knowledgeBase') {
|
||||
prefixIcon.value = 'prefixIcon-grey.svg';
|
||||
}
|
||||
}
|
||||
const mouseleaveMenu = (path) => {
|
||||
if (pathPrefix.value != 'knowledgeBase' && pathPrefix.value != 'creatChat' && path != 'knowledgeBase') {
|
||||
getIcon(route.name)
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.del_submenu {
|
||||
color: #fa5151;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.aside_box {
|
||||
min-width: 260px;
|
||||
padding: 8px;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
|
||||
.logo_box {
|
||||
height: 80px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.logo{
|
||||
width: 134px;
|
||||
height: auto;
|
||||
margin-left: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.logo_img {
|
||||
margin-left: 24px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-right: 7.25px;
|
||||
}
|
||||
|
||||
.logo_txt {
|
||||
transform: rotate(0.049deg);
|
||||
color: #000000;
|
||||
font-family: "TencentSans";
|
||||
font-size: 24.12px;
|
||||
font-style: normal;
|
||||
font-weight: W7;
|
||||
line-height: 21.7px;
|
||||
}
|
||||
|
||||
.menu_box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
.upload-file-wrap {
|
||||
padding: 6px;
|
||||
border-radius: 3px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.upload-file-wrap:hover {
|
||||
background-color: #dbede4;
|
||||
color: #07C05F;
|
||||
|
||||
}
|
||||
|
||||
.upload-file-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.active-upload {
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
.menu_item_active {
|
||||
border-radius: 4px;
|
||||
background: #07c05f1a !important;
|
||||
|
||||
.menu_icon,
|
||||
.menu_title {
|
||||
color: #07c05f !important;
|
||||
}
|
||||
}
|
||||
|
||||
.menu_item_c_active {
|
||||
|
||||
.menu_icon,
|
||||
.menu_title {
|
||||
color: #000000e6;
|
||||
}
|
||||
}
|
||||
|
||||
.menu_p {
|
||||
height: 56px;
|
||||
padding: 6px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.menu_item {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 48px;
|
||||
padding: 13px 8px 13px 16px;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.menu_item-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-radius: 4px;
|
||||
background: #30323605;
|
||||
color: #00000099;
|
||||
|
||||
.menu_icon,
|
||||
.menu_title {
|
||||
color: #00000099;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menu_icon {
|
||||
display: flex;
|
||||
margin-right: 10px;
|
||||
color: #00000099;
|
||||
|
||||
.icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
fill: currentColor;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.menu_title {
|
||||
color: #00000099;
|
||||
text-overflow: ellipsis;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.submenu {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
overflow-y: scroll;
|
||||
scrollbar-width: none;
|
||||
height: calc(98vh - 276px);
|
||||
}
|
||||
|
||||
.submenu_item_p {
|
||||
height: 44px;
|
||||
padding: 4px 8px 4px 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
.submenu_item {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #00000099;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
height: 36px;
|
||||
padding-left: 18px;
|
||||
padding-right: 14px;
|
||||
position: relative;
|
||||
|
||||
.submenu_title {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.menu-more-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.menu-more {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
border-radius: 50%;
|
||||
background: #07C05F;
|
||||
}
|
||||
|
||||
.sub_title {
|
||||
margin-left: 14px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #30323605;
|
||||
color: #00000099;
|
||||
border-radius: 3px;
|
||||
|
||||
.menu-more {
|
||||
color: #00000099;
|
||||
}
|
||||
|
||||
.submenu_title {
|
||||
max-width: 160px !important;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.submenu_item_active {
|
||||
background: #07c05f1a !important;
|
||||
color: #07c05f !important;
|
||||
border-radius: 3px;
|
||||
|
||||
.menu-more {
|
||||
color: #07c05f !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="less">
|
||||
.upload-popup {
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
color: #FFFFFF;
|
||||
border-color: rgba(0, 0, 0, 0.9) !important;
|
||||
box-shadow: none;
|
||||
margin-bottom: 10px !important;
|
||||
|
||||
.t-popup__arrow::before {
|
||||
border-color: rgba(0, 0, 0, 0.9) !important;
|
||||
background-color: rgba(0, 0, 0, 0.9) !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.del-menu-popup {
|
||||
z-index: 99 !important;
|
||||
|
||||
.t-popup__content {
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
line-height: 30px;
|
||||
padding-left: 14px;
|
||||
cursor: pointer;
|
||||
margin-top: 4px !important;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { watch } from "vue"
|
||||
|
||||
const props = defineProps(['reviewImg', 'reviewUrl'])
|
||||
const emit = defineEmits(['closePreImg'])
|
||||
const close = () => {
|
||||
emit('closePreImg')
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<t-image-viewer :visible="reviewImg" closeOnOverlay closeOnEscKeydown @close="close"
|
||||
:images="[{
|
||||
mainImage: reviewUrl,
|
||||
download: false
|
||||
}]">
|
||||
</t-image-viewer>
|
||||
</template>
|
||||
<style scoped lang="less"></style>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
<template>
|
||||
<div class="mask">
|
||||
<img class="upload-mask-img" src="@/assets/img/upload-mask.svg" alt="">
|
||||
<span class="drag-txt">将文件拖放到此处</span>
|
||||
<span class="drag-type-txt">pdf、doc 格式文件,不超过30M</span>
|
||||
<span class="drag-type-txt">text、markdown格式文件,不超过30M</span>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="less">
|
||||
.mask{
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.drag-txt {
|
||||
color: #07c05f;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 26px;
|
||||
display: inline-block;
|
||||
margin: 12px 0 16px 0;
|
||||
}
|
||||
|
||||
.drag-type-txt {
|
||||
width: 217px;
|
||||
color: #00000066;
|
||||
text-align: center;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.upload-img{
|
||||
width: 162px;
|
||||
height: 162px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,145 @@
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { formatStringDate, kbFileTypeVerification } from "../utils/index";
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import {
|
||||
uploadKnowledgeBase,
|
||||
getKnowledgeBase,
|
||||
getKnowledgeDetails,
|
||||
delKnowledgeDetails,
|
||||
getKnowledgeDetailsCon,
|
||||
} from "@/api/knowledge-base/index";
|
||||
import { knowledgeStore } from "@/stores/knowledge";
|
||||
const usemenuStore = knowledgeStore();
|
||||
export default function () {
|
||||
const { cardList, total } = storeToRefs(usemenuStore);
|
||||
let moreIndex = ref(-1);
|
||||
const details = reactive({
|
||||
title: "",
|
||||
time: "",
|
||||
md: [],
|
||||
id: "",
|
||||
total: 0
|
||||
});
|
||||
const getKnowled = (query = { page: 1, page_size: 35 }) => {
|
||||
getKnowledgeBase(query)
|
||||
.then((result: object) => {
|
||||
let { data, total: totalResult } = result;
|
||||
let cardList_ = data.map((item) => {
|
||||
item["file_name"] = item.file_name.substring(
|
||||
0,
|
||||
item.file_name.lastIndexOf(".")
|
||||
);
|
||||
return {
|
||||
...item,
|
||||
updated_at: formatStringDate(new Date(item.updated_at)),
|
||||
isMore: false,
|
||||
file_type: item.file_type.toLocaleUpperCase(),
|
||||
};
|
||||
});
|
||||
if (query.page == 1) {
|
||||
cardList.value = cardList_;
|
||||
} else {
|
||||
cardList.value.push(...cardList_);
|
||||
}
|
||||
total.value = totalResult;
|
||||
})
|
||||
.catch((err) => {});
|
||||
};
|
||||
const delKnowledge = (index: number, item) => {
|
||||
cardList.value[index].isMore = false;
|
||||
moreIndex.value = -1;
|
||||
delKnowledgeDetails(item.id)
|
||||
.then((result) => {
|
||||
if (result.success) {
|
||||
MessagePlugin.info("知识删除成功!");
|
||||
getKnowled();
|
||||
} else {
|
||||
MessagePlugin.error("知识删除失败!");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
MessagePlugin.error("知识删除失败!");
|
||||
});
|
||||
};
|
||||
const openMore = (index: number) => {
|
||||
moreIndex.value = index;
|
||||
};
|
||||
const onVisibleChange = (visible: boolean) => {
|
||||
if (!visible) {
|
||||
moreIndex.value = -1;
|
||||
}
|
||||
};
|
||||
const requestMethod = (file: any, uploadInput) => {
|
||||
if (file instanceof File && uploadInput) {
|
||||
if (kbFileTypeVerification(file)) {
|
||||
return;
|
||||
}
|
||||
uploadKnowledgeBase({ file })
|
||||
.then((result) => {
|
||||
if (result.success) {
|
||||
MessagePlugin.info("上传成功!");
|
||||
getKnowled();
|
||||
} else {
|
||||
MessagePlugin.error("上传失败!");
|
||||
}
|
||||
uploadInput.value.value = "";
|
||||
})
|
||||
.catch((err) => {
|
||||
MessagePlugin.error("上传失败!");
|
||||
uploadInput.value.value = "";
|
||||
});
|
||||
} else {
|
||||
MessagePlugin.error("file文件类型错误!");
|
||||
}
|
||||
};
|
||||
const getCardDetails = (item) => {
|
||||
Object.assign(details, {
|
||||
title: "",
|
||||
time: "",
|
||||
md: [],
|
||||
id: "",
|
||||
});
|
||||
getKnowledgeDetails(item.id)
|
||||
.then((result) => {
|
||||
if (result.success && result.data) {
|
||||
let { data } = result;
|
||||
Object.assign(details, {
|
||||
title: data.file_name,
|
||||
time: formatStringDate(new Date(data.updated_at)),
|
||||
id: data.id,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
getfDetails(item.id, 1);
|
||||
};
|
||||
const getfDetails = (id, page) => {
|
||||
getKnowledgeDetailsCon(id, page)
|
||||
.then((result) => {
|
||||
if (result.success && result.data) {
|
||||
let { data, total: totalResult } = result;
|
||||
if (page == 1) {
|
||||
details.md = data;
|
||||
} else {
|
||||
details.md.push(...data);
|
||||
}
|
||||
details.total = totalResult;
|
||||
}
|
||||
})
|
||||
.catch((err) => {});
|
||||
};
|
||||
return {
|
||||
cardList,
|
||||
moreIndex,
|
||||
getKnowled,
|
||||
details,
|
||||
delKnowledge,
|
||||
openMore,
|
||||
onVisibleChange,
|
||||
requestMethod,
|
||||
getCardDetails,
|
||||
total,
|
||||
getfDetails,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia";
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import "./assets/fonts.css";
|
||||
import TDesign from "tdesign-vue-next";
|
||||
// 引入组件库的少量全局样式变量
|
||||
import "tdesign-vue-next/es/style/index.css";
|
||||
import "@/assets/theme/theme.css";
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(TDesign);
|
||||
app.use(createPinia());
|
||||
app.use(router);
|
||||
|
||||
app.mount("#app");
|
||||
@@ -0,0 +1,46 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: "/",
|
||||
redirect: "/platform",
|
||||
},
|
||||
{
|
||||
path: "/knowledgeBase",
|
||||
name: "home",
|
||||
component: () => import("../views/knowledge/KnowledgeBase.vue"),
|
||||
},
|
||||
{
|
||||
path: "/platform",
|
||||
name: "Platform",
|
||||
redirect: "/platform/knowledgeBase",
|
||||
component: () => import("../views/platform/index.vue"),
|
||||
children: [
|
||||
{
|
||||
path: "knowledgeBase",
|
||||
name: "knowledgeBase",
|
||||
component: () => import("../views/knowledge/KnowledgeBase.vue"),
|
||||
},
|
||||
{
|
||||
path: "creatChat",
|
||||
name: "creatChat",
|
||||
component: () => import("../views/creatChat/creatChat.vue"),
|
||||
},
|
||||
{
|
||||
path: "chat/:chatid",
|
||||
name: "chat",
|
||||
component: () => import("../views/chat/index.vue"),
|
||||
},
|
||||
{
|
||||
path: "settings",
|
||||
name: "settings",
|
||||
component: () => import("../views/settings/Settings.vue"),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,11 @@
|
||||
import { ref, computed, reactive } from "vue";
|
||||
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const knowledgeStore = defineStore("knowledge", {
|
||||
state: () => ({
|
||||
cardList: ref([]),
|
||||
total: ref(0),
|
||||
}),
|
||||
actions: {},
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import { ref, computed, reactive } from 'vue'
|
||||
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useMenuStore = defineStore('menuStore', {
|
||||
state: () => ({
|
||||
menuArr: reactive([
|
||||
{ title: '知识库', icon: 'zhishiku', path: 'knowledgeBase' },
|
||||
{
|
||||
title: '对话',
|
||||
icon: 'prefixIcon',
|
||||
path: 'creatChat',
|
||||
childrenPath: 'chat',
|
||||
children: reactive<object[]>([]),
|
||||
},
|
||||
{ title: '系统设置', icon: 'setting', path: 'settings' }
|
||||
]),
|
||||
isFirstSession: false,
|
||||
firstQuery: ''
|
||||
}
|
||||
),
|
||||
actions: {
|
||||
updatemenuArr(obj: any) {
|
||||
this.menuArr[1].children?.push(obj);
|
||||
},
|
||||
updataMenuChildren(item: object) {
|
||||
this.menuArr[1].children?.unshift(item)
|
||||
},
|
||||
updatasessionTitle(session_id: string, title: string) {
|
||||
this.menuArr[1].children?.forEach(item => {
|
||||
if (item.id == session_id) {
|
||||
item.title = title;
|
||||
item.isNoTitle = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
changeIsFirstSession(payload: boolean) {
|
||||
this.isFirstSession = payload;
|
||||
},
|
||||
changeFirstQuery(payload: string) {
|
||||
this.firstQuery = payload;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
// 定义设置接口
|
||||
interface Settings {
|
||||
endpoint: string;
|
||||
apiKey: string;
|
||||
knowledgeBaseId: string;
|
||||
}
|
||||
|
||||
// 默认设置
|
||||
const defaultSettings: Settings = {
|
||||
endpoint: import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080",
|
||||
apiKey: "",
|
||||
knowledgeBaseId: "",
|
||||
};
|
||||
|
||||
export const useSettingsStore = defineStore("settings", {
|
||||
state: () => ({
|
||||
// 从本地存储加载设置,如果没有则使用默认设置
|
||||
settings: JSON.parse(localStorage.getItem("WeKnora_settings") || JSON.stringify(defaultSettings)),
|
||||
}),
|
||||
|
||||
actions: {
|
||||
// 保存设置
|
||||
saveSettings(settings: Settings) {
|
||||
this.settings = { ...settings };
|
||||
// 保存到localStorage
|
||||
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
|
||||
},
|
||||
|
||||
// 获取设置
|
||||
getSettings(): Settings {
|
||||
return this.settings;
|
||||
},
|
||||
|
||||
// 获取API端点
|
||||
getEndpoint(): string {
|
||||
return this.settings.endpoint || defaultSettings.endpoint;
|
||||
},
|
||||
|
||||
// 获取API Key
|
||||
getApiKey(): string {
|
||||
return this.settings.apiKey;
|
||||
},
|
||||
|
||||
// 获取知识库ID
|
||||
getKnowledgeBaseId(): string {
|
||||
return this.settings.knowledgeBaseId;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
export function generateRandomString(length: number) {
|
||||
let result = "";
|
||||
const characters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function formatStringDate(date) {
|
||||
let data = new Date(date);
|
||||
let year = data.getFullYear();
|
||||
let month = data.getMonth() + 1;
|
||||
let day = data.getDate();
|
||||
let hour = data.getHours();
|
||||
let minute = data.getMinutes();
|
||||
let second = data.getSeconds();
|
||||
return (
|
||||
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
|
||||
);
|
||||
}
|
||||
export function kbFileTypeVerification(file) {
|
||||
let validTypes = ["pdf", "txt", "md", "docx", "doc", "jpg", "jpeg", "png"];
|
||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
if (!validTypes.includes(type)) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(type == "pdf" || type == "docx" || type == "doc") &&
|
||||
file.size > 31457280
|
||||
) {
|
||||
MessagePlugin.error("pdf/doc文件不能超过30M!");
|
||||
return true;
|
||||
}
|
||||
if ((type == "txt" || type == "md") && file.size > 31457280) {
|
||||
MessagePlugin.error("txt/md文件不能超过30M!");
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
// src/utils/request.js
|
||||
import axios from "axios";
|
||||
import { generateRandomString } from "./index";
|
||||
|
||||
// 从localStorage获取设置
|
||||
function getSettings() {
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
if (settingsStr) {
|
||||
try {
|
||||
return JSON.parse(settingsStr);
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
return {
|
||||
endpoint: import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080",
|
||||
apiKey: "",
|
||||
knowledgeBaseId: "",
|
||||
};
|
||||
}
|
||||
|
||||
// API基础URL,优先使用设置中的endpoint
|
||||
const settings = getSettings();
|
||||
const BASE_URL = settings.endpoint;
|
||||
|
||||
// 测试数据
|
||||
let testData: {
|
||||
tenant: {
|
||||
id: number;
|
||||
name: string;
|
||||
api_key: string;
|
||||
};
|
||||
knowledge_bases: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
}>;
|
||||
} | null = null;
|
||||
|
||||
// 创建Axios实例
|
||||
const instance = axios.create({
|
||||
baseURL: BASE_URL, // 使用配置的API基础URL
|
||||
timeout: 30000, // 请求超时时间
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Request-ID": `${generateRandomString(12)}`,
|
||||
},
|
||||
});
|
||||
|
||||
// 设置测试数据
|
||||
export function setTestData(data: typeof testData) {
|
||||
testData = data;
|
||||
if (data) {
|
||||
// 优先使用设置中的ApiKey,如果没有则使用测试数据中的
|
||||
const apiKey = settings.apiKey || (data?.tenant?.api_key || "");
|
||||
if (apiKey) {
|
||||
instance.defaults.headers["X-API-Key"] = apiKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取测试数据
|
||||
export function getTestData() {
|
||||
return testData;
|
||||
}
|
||||
|
||||
instance.interceptors.request.use(
|
||||
(config) => {
|
||||
// 每次请求前检查是否有更新的设置
|
||||
const currentSettings = getSettings();
|
||||
|
||||
// 更新BaseURL (如果有变化)
|
||||
if (currentSettings.endpoint && config.baseURL !== currentSettings.endpoint) {
|
||||
config.baseURL = currentSettings.endpoint;
|
||||
}
|
||||
|
||||
// 更新API Key (如果有)
|
||||
if (currentSettings.apiKey) {
|
||||
config.headers["X-API-Key"] = currentSettings.apiKey;
|
||||
}
|
||||
|
||||
config.headers["X-Request-ID"] = `${generateRandomString(12)}`;
|
||||
return config;
|
||||
},
|
||||
(error) => {}
|
||||
);
|
||||
|
||||
instance.interceptors.response.use(
|
||||
(response) => {
|
||||
// 根据业务状态码处理逻辑
|
||||
const { status, data } = response;
|
||||
if (status === 200 || status === 201) {
|
||||
return data;
|
||||
} else {
|
||||
return Promise.reject(data);
|
||||
}
|
||||
},
|
||||
(error: any) => {
|
||||
if (!error.response) {
|
||||
return Promise.reject({ message: "网络错误,请检查您的网络连接" });
|
||||
}
|
||||
const { data } = error.response;
|
||||
return Promise.reject(data);
|
||||
}
|
||||
);
|
||||
|
||||
export function get(url: string) {
|
||||
return instance.get(url);
|
||||
}
|
||||
|
||||
export async function getDown(url: string) {
|
||||
let res = await instance.get(url, {
|
||||
responseType: "blob",
|
||||
});
|
||||
return res
|
||||
}
|
||||
|
||||
export function postUpload(url: string, data = {}) {
|
||||
return instance.post(url, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"X-Request-ID": `${generateRandomString(12)}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function postChat(url: string, data = {}) {
|
||||
return instance.post(url, data, {
|
||||
headers: {
|
||||
"Content-Type": "text/event-stream;charset=utf-8",
|
||||
"X-Request-ID": `${generateRandomString(12)}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function post(url: string, data = {}) {
|
||||
return instance.post(url, data);
|
||||
}
|
||||
|
||||
export function put(url: string, data = {}) {
|
||||
return instance.put(url, data);
|
||||
}
|
||||
|
||||
export function del(url: string) {
|
||||
return instance.delete(url);
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<div class="bot_msg">
|
||||
<div style="display: flex;flex-direction: column; gap:8px">
|
||||
<docInfo :session="session"></docInfo>
|
||||
<deepThink :deepSession="session" v-if="session.showThink"></deepThink>
|
||||
</div>
|
||||
<div ref="parentMd">
|
||||
<!-- 消息正在总结中则渲染加载gif -->
|
||||
<img v-if="session.thinking" class="botanswer_laoding_gif" src="@/assets/img/botanswer_loading.gif"
|
||||
alt="正在总结答案……">
|
||||
<div v-for="(item, index) in processedMarkdown" :key="index">
|
||||
<img class="ai-markdown-img" @click="preview(item)" v-if="isLink(item)" :src="item" alt="">
|
||||
<div v-else class="ai-markdown-template" v-html="processMarkdown(item)"></div>
|
||||
</div>
|
||||
<div v-if="isImgLoading" class="img_loading"><t-loading size="small"></t-loading><span>加载中...</span></div>
|
||||
</div>
|
||||
<picturePreview :reviewImg="reviewImg" :reviewUrl="reviewUrl" @closePreImg="closePreImg"></picturePreview>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, watch, computed, ref, reactive, defineProps, nextTick } from 'vue';
|
||||
import { marked } from 'marked';
|
||||
import docInfo from './docInfo.vue';
|
||||
import deepThink from './deepThink.vue';
|
||||
import picturePreview from '@/components/picture-preview.vue';
|
||||
marked.use({
|
||||
mangle: false,
|
||||
headerIds: false,
|
||||
});
|
||||
const emit = defineEmits(['scroll-bottom'])
|
||||
const renderer = new marked.Renderer();
|
||||
let parentMd = ref()
|
||||
let reviewUrl = ref('')
|
||||
let reviewImg = ref(false)
|
||||
let isImgLoading = ref(false);
|
||||
const props = defineProps({
|
||||
// 必填项
|
||||
content: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
session: {
|
||||
type: Object,
|
||||
required: false
|
||||
},
|
||||
isFirstEnter: {
|
||||
type: Boolean,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
const processedMarkdown = ref([]);
|
||||
const preview = (url) => {
|
||||
nextTick(() => {
|
||||
reviewUrl.value = url;
|
||||
reviewImg.value = true
|
||||
})
|
||||
}
|
||||
const removeImg = () => {
|
||||
nextTick(() => {
|
||||
const images = parentMd.value.querySelectorAll('img.ai-markdown-img');
|
||||
if (images) {
|
||||
images.forEach(async item => {
|
||||
const isValid = await checkImage(item.src);
|
||||
if (!isValid) {
|
||||
item.remove();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const closePreImg = () => {
|
||||
reviewImg.value = false
|
||||
reviewUrl.value = '';
|
||||
}
|
||||
const debounce = (fn, delay) => {
|
||||
let timer
|
||||
return (...args) => {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => fn(...args), delay)
|
||||
}
|
||||
}
|
||||
const checkImage = (url) => {
|
||||
return new Promise((resolve) => {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
resolve(true);
|
||||
}
|
||||
img.onerror = () => resolve(false);
|
||||
img.src = url;
|
||||
});
|
||||
};
|
||||
// 处理 Markdown 中的图片
|
||||
const processMarkdown = (markdownText) => {
|
||||
// 自定义渲染器处理图片
|
||||
const renderer = {
|
||||
image(href, title, text) {
|
||||
return `<img src="${href}" alt="${text}" title="${title || ''}" class="markdown-image" style="max-width: 708px;height: 230px;">`;
|
||||
}
|
||||
};
|
||||
|
||||
marked.use({ renderer });
|
||||
|
||||
// 第一次渲染
|
||||
let html = marked.parse(markdownText);
|
||||
|
||||
// 创建虚拟 DOM 来操作
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
|
||||
// 检查所有图片
|
||||
// const images = doc.querySelectorAll('img');
|
||||
// images.forEach(async item => {
|
||||
// const isValid = await checkImage(item.src);
|
||||
// if (!isValid) {
|
||||
// item.remove();
|
||||
// }
|
||||
// });
|
||||
// if (props.isFirstEnter) {
|
||||
// emit('scroll-bottom')
|
||||
// }
|
||||
return doc.body.innerHTML;
|
||||
};
|
||||
const handleImg = async (newVal) => {
|
||||
let index = newVal.lastIndexOf(' && str.includes(')')) {
|
||||
processedMarkdown.value = splitMarkdownByImages(newVal)
|
||||
isImgLoading.value = false;
|
||||
} else {
|
||||
processedMarkdown.value = splitMarkdownByImages(newVal.slice(0, index))
|
||||
}
|
||||
} else {
|
||||
processedMarkdown.value = splitMarkdownByImages(newVal)
|
||||
}
|
||||
removeImg()
|
||||
}
|
||||
function splitMarkdownByImages(markdown) {
|
||||
const imageRegex = /!\[.*?\]\(\s*(?:<([^>]*)>|([^)\s]*))\s*(?:["'].*?["'])?\s*\)/g;
|
||||
const result = [];
|
||||
let lastIndex = 0;
|
||||
let match;
|
||||
|
||||
while ((match = imageRegex.exec(markdown)) !== null) {
|
||||
const textBefore = markdown.slice(lastIndex, match.index);
|
||||
if (textBefore) result.push(textBefore);
|
||||
const url = match[1] || match[2];
|
||||
result.push(url);
|
||||
lastIndex = imageRegex.lastIndex;
|
||||
}
|
||||
|
||||
const remainingText = markdown.slice(lastIndex);
|
||||
if (remainingText) result.push(remainingText);
|
||||
|
||||
return result;
|
||||
}
|
||||
function isLink(str) {
|
||||
const trimmedStr = str.trim();
|
||||
// 正则表达式匹配常见链接格式
|
||||
const urlPattern = /^(https?:\/\/|ftp:\/\/|www\.)[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/i;
|
||||
return urlPattern.test(trimmedStr);
|
||||
}
|
||||
|
||||
watch(() => props.content, (newVal) => {
|
||||
debounce(handleImg(newVal), 800)
|
||||
}, {
|
||||
immediate: true
|
||||
})
|
||||
|
||||
const myMarkdown = (res) => {
|
||||
return marked.parse(res, { renderer })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
processedMarkdown.value = splitMarkdownByImages(props.content);
|
||||
removeImg()
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
@import '../../../components/css/markdown.less';
|
||||
|
||||
:deep(.ai-markdown-template) {
|
||||
contain: content;
|
||||
line-height: 28px;
|
||||
letter-spacing: 1px;
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
line-height: 14px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.ai-markdown-img {
|
||||
border-radius: 8px;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
object-fit: scale-down;
|
||||
contain: content;
|
||||
margin-left: 16px;
|
||||
border: 0.5px solid #E7E7E7;
|
||||
max-width: 708px;
|
||||
height: 230px;
|
||||
}
|
||||
|
||||
.bot_msg {
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
font-size: 16px;
|
||||
padding: 10px 12px;
|
||||
margin-right: auto;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.botanswer_laoding_gif {
|
||||
width: 24px;
|
||||
height: 18px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.img_loading {
|
||||
background: #3032360f;
|
||||
height: 230px;
|
||||
width: 230px;
|
||||
color: #00000042;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
font-size: 12px;
|
||||
gap: 4px;
|
||||
margin-left: 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
:deep(.t-loading__gradient-conic) {
|
||||
background: conic-gradient(from 90deg at 50% 50%, #fff 0deg, #676767 360deg) !important;
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<div class='deep-think'>
|
||||
<t-collapse :default-value="deepSession.thinking ? [0] : []" expand-icon-placement="right" :expand-icon="true"
|
||||
:borderless="true" @change="handlePanelChange">
|
||||
<t-collapse-panel>
|
||||
<template #expandIcon>
|
||||
<div v-if="!deepSession.thinking" class="chevron">
|
||||
<t-icon :name="!isFold ? 'chevron-up' : 'chevron-down'" />
|
||||
</div>
|
||||
</template>
|
||||
<template #header>
|
||||
<div class="deep-title">
|
||||
<div v-if="deepSession.thinking" class="thinking">
|
||||
<img class="img_gif" src="@/assets/img/think.gif" alt="">思考中···
|
||||
</div>
|
||||
<div v-else class="done">
|
||||
<img class="icon deep_icon" src="@/assets/img/Frame3718.svg" alt=""></img>已深度思考
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="content">
|
||||
<span v-html="deepSession.thinkContent.replace(/\n/g, '<br/>')"></span>
|
||||
</div>
|
||||
</t-collapse-panel>
|
||||
|
||||
</t-collapse>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, watch, computed, ref, reactive, defineProps } from 'vue';
|
||||
|
||||
const isFold = ref(true)
|
||||
const props = defineProps({
|
||||
// 必填项
|
||||
deepSession: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.deepSession,
|
||||
(newVal) => { },
|
||||
{ deep: true }
|
||||
);
|
||||
onMounted(() => {
|
||||
})
|
||||
const showHide = () => {
|
||||
isFold.value = !isFold.value;
|
||||
}
|
||||
const handlePanelChange = (val) => {
|
||||
isFold.value = !val.length ? true : false;
|
||||
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.deep-think {
|
||||
background: #30323605;
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
|
||||
:deep(.t-collapse.t--border-less .t-collapse-panel__body) {
|
||||
background: #30323605 !important;
|
||||
}
|
||||
|
||||
|
||||
:deep(.t-collapse-panel__wrapper .t-collapse-panel__header) {
|
||||
background: #30323605 !important;
|
||||
padding: 4px;
|
||||
|
||||
&:hover {
|
||||
background-color: #30323605 !important;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-collapse-panel__wrapper .t-collapse-panel__content) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.chevron {
|
||||
color: #00000099;
|
||||
font-size: 14px;
|
||||
padding: 0 2px 1px 2px;
|
||||
}
|
||||
|
||||
.deep-title {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
// padding: 4px;
|
||||
|
||||
&:hover {
|
||||
background: #30323605;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.thinking {
|
||||
font-size: 14px;
|
||||
color: #000000e6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.img_gif {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.done {
|
||||
font-size: 14px;
|
||||
color: #00000099;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.deep_icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #07c05f;
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
line-height: 23px;
|
||||
font-size: 14px;
|
||||
font-family: "PingFang SC";
|
||||
color: #00000099;
|
||||
margin: 6px 8px 4px;
|
||||
word-break: break-all;
|
||||
text-align: justify;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<div class="refer">
|
||||
<div class="refer_header" @click="referBoxSwitch" v-if="session.knowledge_references && session.knowledge_references.length">
|
||||
<div class="refer_title">
|
||||
<img src="@/assets/img/ziliao.svg" alt="" />
|
||||
<span>参考了{{ session.knowledge_references && session.knowledge_references.length }}个相关内容</span>
|
||||
</div>
|
||||
<div class="refer_show_icon">
|
||||
<t-icon :name="showReferBox ? 'chevron-up' : 'chevron-down'" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="refer_box" v-show="showReferBox">
|
||||
<div v-for="(item, index) in session.knowledge_references" :key="index">
|
||||
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400" :showArrow="false"
|
||||
trigger="click">
|
||||
<template #content>
|
||||
<div class="doc_content">
|
||||
<div v-html="item.content.replace(/\n/g, '<br/>')"></div>
|
||||
</div>
|
||||
</template>
|
||||
<span class="doc">
|
||||
{{ session.knowledge_references.length < 2 ? item.knowledge_title : `${index +
|
||||
1}.${item.knowledge_title}` }} </span>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, defineProps, computed, ref, reactive } from "vue";
|
||||
const props = defineProps({
|
||||
// 必填项
|
||||
content: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
session: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
const showReferBox = ref(false);
|
||||
const referBoxSwitch = () => {
|
||||
showReferBox.value = !showReferBox.value;
|
||||
};
|
||||
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.refer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
border-radius: 2px;
|
||||
background-color: #30323605;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
|
||||
.refer_header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px;
|
||||
color: #00000099;
|
||||
|
||||
.refer_title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #07c05f;
|
||||
fill: currentColor;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
span {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.refer_show_icon {
|
||||
font-size: 14px;
|
||||
padding: 0 2px 1px 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.refer_header:hover {
|
||||
border-radius: 2px;
|
||||
background-color: #30323605;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.refer_box {
|
||||
padding: 2px 4px 4px 4px;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.doc_content {
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
font-size: 14px;
|
||||
color: #000000e6;
|
||||
line-height: 23px;
|
||||
text-align: justify;
|
||||
border: 1px solid #07c05f33;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.doc {
|
||||
text-decoration: underline;
|
||||
color: #366ef4;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
max-width: calc(100% - 24px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
line-height: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.refer-to-layer {
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<t-textarea resize="none" :autosize="false" v-model="value" placeholder="请输入描述文案" name="description" @change="onChange" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, watch, computed, ref, reactive } from 'vue';
|
||||
|
||||
const value = ref('');
|
||||
const onChange = (value,e) => {
|
||||
console.log(value)
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.chat {
|
||||
width: 800px;
|
||||
font-size: 20px;
|
||||
margin: 0px auto
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="user_msg">
|
||||
{{ content }}
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, defineProps } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
// 必填项
|
||||
content: {
|
||||
type: String,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.user_msg {
|
||||
width: max-content;
|
||||
max-width: 776px;
|
||||
display: flex;
|
||||
padding: 10px 12px;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex: 1 0 0;
|
||||
border-radius: 4px;
|
||||
background: #8CE97F;
|
||||
margin-left: auto;
|
||||
color: #000000e6;
|
||||
font-size: 16px;
|
||||
text-align: justify;
|
||||
word-break: break-all;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,303 @@
|
||||
<template>
|
||||
<div class="chat">
|
||||
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
|
||||
<div class="msg_list">
|
||||
<div v-for="(session, id) in messagesList" :key='id'>
|
||||
<div v-if="session.role == 'user'">
|
||||
<usermsg :content="session.content"></usermsg>
|
||||
</div>
|
||||
<div v-if="session.role == 'assistant'">
|
||||
<botmsg :content="session.content" :session="session" @scroll-bottom="scrollToBottom"
|
||||
:isFirstEnter="isFirstEnter"></botmsg>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="loading"
|
||||
style="height: 41px;display: flex;align-items: center;background: #fff;width: 58px;">
|
||||
<img class="botanswer_laoding_gif" src="@/assets/img/botanswer_loading.gif" alt="正在等待答案……">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="min-height: 115px; margin: 16px auto 4px;width: 100%;max-width: 800px;">
|
||||
<InputField @send-msg="sendMsg" :isReplying="isReplying"></InputField>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ref, onMounted, onUnmounted, nextTick, watch, reactive, onBeforeUnmount } from 'vue';
|
||||
import { useRoute, useRouter, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router';
|
||||
import InputField from '../../components/Input-field.vue';
|
||||
import botmsg from './components/botmsg.vue';
|
||||
import usermsg from './components/usermsg.vue';
|
||||
import { getMessageList, generateSessionsTitle } from "@/api/chat/index";
|
||||
import { useStream } from '../../api/chat/streame'
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
const usemenuStore = useMenuStore();
|
||||
const { menuArr, isFirstSession, firstQuery } = storeToRefs(usemenuStore);
|
||||
const { output, onChunk, isStreaming, isLoading, error, startStream, stopStream } = useStream();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const session_id = ref(route.params.chatid);
|
||||
const created_at = ref('');
|
||||
const limit = ref(20);
|
||||
const messagesList = reactive([]);
|
||||
const isReplying = ref(false);
|
||||
const scrollLock = ref(false);
|
||||
const isNeedTitle = ref(false);
|
||||
const isFirstEnter = ref(true);
|
||||
const loading = ref(false);
|
||||
let fullContent = ref('')
|
||||
let userquery = ref('')
|
||||
const scrollContainer = ref(null)
|
||||
watch([() => route.params], (newvalue) => {
|
||||
isFirstEnter.value = true;
|
||||
if (newvalue[0].chatid) {
|
||||
if (!firstQuery.value) {
|
||||
scrollLock.value = false;
|
||||
}
|
||||
messagesList.splice(0);
|
||||
session_id.value = newvalue[0].chatid;
|
||||
checkmenuTitle(session_id.value)
|
||||
let data = {
|
||||
session_id: session_id.value,
|
||||
created_at: '',
|
||||
limit: limit.value
|
||||
}
|
||||
getmsgList(data);
|
||||
}
|
||||
});
|
||||
const scrollToBottom = () => {
|
||||
nextTick(() => {
|
||||
if (scrollContainer.value) {
|
||||
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
|
||||
}
|
||||
})
|
||||
}
|
||||
const debounce = (fn, delay) => {
|
||||
let timer
|
||||
return (...args) => {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(() => fn(...args), delay)
|
||||
}
|
||||
}
|
||||
const onChatScrollTop = () => {
|
||||
if (scrollLock.value) return;
|
||||
const { scrollTop, scrollHeight } = scrollContainer.value;
|
||||
isFirstEnter.value = false
|
||||
if (scrollTop == 0) {
|
||||
let data = {
|
||||
session_id: session_id.value,
|
||||
created_at: created_at.value,
|
||||
limit: limit.value
|
||||
}
|
||||
getmsgList(data, true, scrollHeight);
|
||||
}
|
||||
}
|
||||
const handleScroll = debounce(onChatScrollTop, 500);
|
||||
|
||||
const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
||||
getMessageList(data).then(res => {
|
||||
if (res && res.data?.length) {
|
||||
created_at.value = res.data[0].created_at;
|
||||
handleMsgList(res.data, isScrollType, scrollHeight);
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleMsgList = async (data, isScrollType = false, newScrollHeight) => {
|
||||
let chatlist = data.reverse()
|
||||
for (let i = 0, len = chatlist.length; i < len; i++) {
|
||||
let item = chatlist[i];
|
||||
item.thinking = false;
|
||||
if (item.content) {
|
||||
if (!item.content.includes('<think>') && !item.content.includes('<\/think>')) {
|
||||
item.thinkContent = "";
|
||||
item.content = item.content;
|
||||
item.showThink = false;
|
||||
} else if (item.content.includes('<\/think>')) {
|
||||
const arr = item.content.trim().split('<\/think>');
|
||||
item.showThink = true;
|
||||
item.thinkContent = arr[0].trim().replace('<think>', '');
|
||||
let index = item.content.trim().lastIndexOf('<\/think>')
|
||||
item.content = item.content.substring(index + 8);
|
||||
}
|
||||
}
|
||||
if (item.is_completed && !item.content) {
|
||||
item.content = "抱歉,我无法回答这个问题。";
|
||||
}
|
||||
messagesList.unshift(item);
|
||||
if (isFirstEnter.value) {
|
||||
scrollToBottom();
|
||||
} else if (isScrollType) {
|
||||
nextTick(() => {
|
||||
const { scrollHeight } = scrollContainer.value;
|
||||
scrollContainer.value.scrollTop = scrollHeight - newScrollHeight
|
||||
})
|
||||
}
|
||||
}
|
||||
if (messagesList[messagesList.length - 1] && !messagesList[messagesList.length - 1].is_completed) {
|
||||
isReplying.value = true;
|
||||
await startStream({ session_id: session_id.value, query: messagesList[messagesList.length - 1].id, method: 'GET', url: '/api/v1/sessions/continue-stream' });
|
||||
}
|
||||
|
||||
}
|
||||
const checkmenuTitle = (session_id) => {
|
||||
menuArr.value[1].children?.forEach(item => {
|
||||
if (item.id == session_id) {
|
||||
isNeedTitle.value = item.isNoTitle;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 发送消息
|
||||
const sendMsg = async (value) => {
|
||||
userquery.value = value;
|
||||
isReplying.value = true;
|
||||
loading.value = true;
|
||||
messagesList.push({ content: value, role: 'user' });
|
||||
scrollToBottom();
|
||||
await startStream({ session_id: session_id.value, query: value, method: 'POST', url: '/api/v1/knowledge-chat' });
|
||||
}
|
||||
|
||||
// 处理流式数据
|
||||
onChunk((data) => {
|
||||
loading.value = false;
|
||||
fullContent.value += data.content;
|
||||
let obj = { ...data, content: '', role: 'assistant', showThink: false };
|
||||
|
||||
if (fullContent.value.includes('<think>') && !fullContent.value.includes('<\/think>')) {
|
||||
obj.thinking = true;
|
||||
obj.showThink = true;
|
||||
obj.content = '';
|
||||
obj.thinkContent = fullContent.value.replace('<think>', '').trim();
|
||||
} else if (fullContent.value.includes('<think>') && fullContent.value.includes('<\/think>')) {
|
||||
obj.thinking = false;
|
||||
obj.showThink = true;
|
||||
const index = fullContent.value.indexOf('<\/think>');
|
||||
obj.thinkContent = fullContent.value.substring(0, index).replace('<think>', '').trim();
|
||||
obj.content = fullContent.value.substring(index + 8).trim();
|
||||
} else {
|
||||
obj.content = fullContent.value;
|
||||
}
|
||||
if (data.done) {
|
||||
if (isFirstSession.value || isNeedTitle.value) {
|
||||
generateSessionsTitle(session_id.value, {
|
||||
messages: [{ role: "user", content: userquery.value }]
|
||||
}).then(res => {
|
||||
if (res.data) {
|
||||
usemenuStore.changeIsFirstSession(false);
|
||||
usemenuStore.updatasessionTitle(session_id.value, res.data);
|
||||
isNeedTitle.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
isReplying.value = false;
|
||||
fullContent.value = "";
|
||||
}
|
||||
updateAssistantSession(obj);
|
||||
})
|
||||
const updateAssistantSession = (payload) => {
|
||||
const message = messagesList.findLast((item) => {
|
||||
if (item.request_id === payload.id) {
|
||||
return true
|
||||
}
|
||||
return item.id === payload.id;
|
||||
});
|
||||
if (message) {
|
||||
message.content = payload.content;
|
||||
message.thinking = payload.thinking;
|
||||
message.thinkContent = payload.thinkContent;
|
||||
message.showThink = payload.showThink;
|
||||
message.knowledge_references = message.knowledge_references ? message.knowledge_references : payload.knowledge_references;
|
||||
} else {
|
||||
messagesList.push(payload);
|
||||
}
|
||||
scrollToBottom();
|
||||
}
|
||||
onMounted(() => {
|
||||
messagesList.splice(0);
|
||||
// scrollContainer.value.addEventListener("scroll", () => {
|
||||
// if (scrollContainer.value.scrollTop == 0) {
|
||||
// onChatScrollTop();
|
||||
// }
|
||||
// });
|
||||
checkmenuTitle(session_id.value)
|
||||
if (firstQuery.value) {
|
||||
scrollLock.value = true;
|
||||
sendMsg(firstQuery.value);
|
||||
usemenuStore.changeFirstQuery('');
|
||||
} else {
|
||||
scrollLock.value = false;
|
||||
let data = {
|
||||
session_id: session_id.value,
|
||||
created_at: '',
|
||||
limit: limit.value
|
||||
}
|
||||
getmsgList(data)
|
||||
}
|
||||
})
|
||||
const clearData = () => {
|
||||
stopStream();
|
||||
isReplying.value = false;
|
||||
fullContent.value = '';
|
||||
userquery.value = '';
|
||||
|
||||
}
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
clearData()
|
||||
next()
|
||||
})
|
||||
onBeforeRouteUpdate((to, from, next) => {
|
||||
clearData()
|
||||
next()
|
||||
})
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.chat {
|
||||
font-size: 20px;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
max-width: calc(100vw - 260px);
|
||||
min-width: 400px;
|
||||
|
||||
:deep(.answers-input) {
|
||||
position: static;
|
||||
transform: translateX(0);
|
||||
|
||||
.t-textarea__inner {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chat_scroll_box {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
max-width: 800px;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.msg_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
max-width: 800px;
|
||||
flex: 1;
|
||||
|
||||
.botanswer_laoding_gif {
|
||||
width: 24px;
|
||||
height: 18px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,188 @@
|
||||
<template>
|
||||
<div v-show="cardList.length" class="dialogue-wrap">
|
||||
<div class="dialogue-answers">
|
||||
<div class="dialogue-title">
|
||||
<span>基于知识库内容问答</span>
|
||||
</div>
|
||||
<InputField @send-msg="sendMsg"></InputField>
|
||||
</div>
|
||||
</div>
|
||||
<EmptyKnowledge v-show="!cardList.length"></EmptyKnowledge>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onUnmounted, watch } from 'vue';
|
||||
import InputField from '@/components/Input-field.vue';
|
||||
import EmptyKnowledge from '@/components/empty-knowledge.vue';
|
||||
import { getSessionsList, createSessions, generateSessionsTitle } from "@/api/chat/index";
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
|
||||
import { getTestData } from '@/utils/request';
|
||||
|
||||
let { cardList } = useKnowledgeBase()
|
||||
const router = useRouter();
|
||||
const usemenuStore = useMenuStore();
|
||||
const sendMsg = (value: string) => {
|
||||
createNewSession(value);
|
||||
}
|
||||
|
||||
async function createNewSession(value: string) {
|
||||
// 从localStorage获取设置中的知识库ID
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
let knowledgeBaseId = "";
|
||||
|
||||
if (settingsStr) {
|
||||
try {
|
||||
const settings = JSON.parse(settingsStr);
|
||||
if (settings.knowledgeBaseId) {
|
||||
knowledgeBaseId = settings.knowledgeBaseId;
|
||||
createSessions({ knowledge_base_id: knowledgeBaseId }).then(res => {
|
||||
if (res.data && res.data.id) {
|
||||
getTitle(res.data.id, value);
|
||||
} else {
|
||||
// 错误处理
|
||||
console.error("创建会话失败");
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("创建会话出错:", error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果设置中没有知识库ID,则使用测试数据
|
||||
const testData = getTestData();
|
||||
if (!testData || testData.knowledge_bases.length === 0) {
|
||||
console.error("测试数据未初始化或不包含知识库");
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用第一个知识库ID
|
||||
knowledgeBaseId = testData.knowledge_bases[0].id;
|
||||
|
||||
createSessions({ knowledge_base_id: knowledgeBaseId }).then(res => {
|
||||
if (res.data && res.data.id) {
|
||||
getTitle(res.data.id, value)
|
||||
} else {
|
||||
// 错误处理
|
||||
console.error("创建会话失败");
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("创建会话出错:", error);
|
||||
})
|
||||
}
|
||||
|
||||
const getTitle = (session_id: string, value: string) => {
|
||||
let obj = { title: '新会话', path: `chat/${session_id}`, id: session_id, isMore: false, isNoTitle: true }
|
||||
usemenuStore.updataMenuChildren(obj);
|
||||
usemenuStore.changeIsFirstSession(true);
|
||||
usemenuStore.changeFirstQuery(value);
|
||||
router.push(`/platform/chat/${session_id}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.dialogue-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
// position: relative;
|
||||
}
|
||||
|
||||
.dialogue-answers {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
align-items: center;
|
||||
|
||||
:deep(.answers-input) {
|
||||
position: static;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
.dialogue-title {
|
||||
display: flex;
|
||||
color: #000000;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
|
||||
.icon {
|
||||
display: flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 6px;
|
||||
background: #FFF;
|
||||
box-shadow: 0 0 2px -1px #0000001f;
|
||||
margin-right: 12px;
|
||||
|
||||
.logo_img {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1250px) and (min-width: 1045px) {
|
||||
.answers-input {
|
||||
transform: translateX(-329px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 654px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1045px) {
|
||||
.answers-input {
|
||||
transform: translateX(-250px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 500px !important;
|
||||
}
|
||||
}
|
||||
@media (max-width: 750px) {
|
||||
.answers-input {
|
||||
transform: translateX(-250px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 340px !important;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.answers-input {
|
||||
transform: translateX(-250px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 300px !important;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
<style lang="less">
|
||||
.del-menu-popup {
|
||||
z-index: 99 !important;
|
||||
|
||||
.t-popup__content {
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
line-height: 30px;
|
||||
padding-left: 14px;
|
||||
cursor: pointer;
|
||||
margin-top: 4px !important;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,574 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch, reactive } from "vue";
|
||||
import DocContent from "@/components/doc-content.vue";
|
||||
import InputField from "@/components/Input-field.vue";
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import EmptyKnowledge from '@/components/empty-knowledge.vue';
|
||||
import { getSessionsList, createSessions, generateSessionsTitle } from "@/api/chat/index";
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
import { getTestData } from '@/utils/request';
|
||||
const usemenuStore = useMenuStore();
|
||||
const router = useRouter();
|
||||
import {
|
||||
batchQueryKnowledge,
|
||||
} from "@/api/knowledge-base/index";
|
||||
let { cardList, total, moreIndex, details, getKnowled, delKnowledge, openMore, onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase()
|
||||
let isCardDetails = ref(false);
|
||||
let timeout = null;
|
||||
let delDialog = ref(false)
|
||||
let knowledge = ref({})
|
||||
let knowledgeIndex = ref(-1)
|
||||
let knowledgeScroll = ref()
|
||||
let page = 1;
|
||||
let pageSize = 35;
|
||||
const getPageSize = () => {
|
||||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
|
||||
const itemHeight = 174;
|
||||
let itemsInView = Math.floor(viewportHeight / itemHeight) * 5;
|
||||
pageSize = Math.max(35, itemsInView);
|
||||
}
|
||||
getPageSize()
|
||||
onMounted(() => {
|
||||
getKnowled({ page: 1, page_size: pageSize });
|
||||
});
|
||||
watch(() => cardList.value, (newValue) => {
|
||||
let analyzeList = [];
|
||||
analyzeList = newValue.filter(item => {
|
||||
return item.parse_status == 'pending' || item.parse_status == 'processing';
|
||||
})
|
||||
clearInterval(timeout);
|
||||
timeout = null;
|
||||
if (analyzeList.length) {
|
||||
updateStatus(analyzeList)
|
||||
}
|
||||
}, { deep: true })
|
||||
const updateStatus = (analyzeList) => {
|
||||
let query = ``;
|
||||
for (let i = 0; i < analyzeList.length; i++) {
|
||||
query += `ids=${analyzeList[i].id}&`;
|
||||
}
|
||||
timeout = setInterval(() => {
|
||||
batchQueryKnowledge(query).then((result) => {
|
||||
if (result.success && result.data) {
|
||||
result.data.forEach(item => {
|
||||
if (item.parse_status == 'failed' || item.parse_status == 'completed') {
|
||||
let index = cardList.value.findIndex(card => card.id == item.id);
|
||||
if (index != -1) {
|
||||
cardList.value[index].parse_status = item.parse_status;
|
||||
cardList.value[index].description = item.description;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch((_err) => {
|
||||
// 错误处理
|
||||
});
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
const closeDoc = () => {
|
||||
isCardDetails.value = false;
|
||||
};
|
||||
const openCardDetails = (item) => {
|
||||
isCardDetails.value = true;
|
||||
getCardDetails(item);
|
||||
};
|
||||
|
||||
const delCard = (index, item) => {
|
||||
knowledgeIndex.value = index;
|
||||
knowledge.value = item;
|
||||
delDialog.value = true;
|
||||
};
|
||||
|
||||
const handleScroll = () => {
|
||||
const element = knowledgeScroll.value;
|
||||
if (element) {
|
||||
let pageNum = Math.ceil(total.value / pageSize)
|
||||
const { scrollTop, scrollHeight, clientHeight } = element;
|
||||
if (scrollTop + clientHeight >= scrollHeight) {
|
||||
page++;
|
||||
if (cardList.value.length < total.value && page <= pageNum) {
|
||||
getKnowled({ page, page_size: pageSize });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const getDoc = (page) => {
|
||||
getfDetails(details.id, page)
|
||||
};
|
||||
|
||||
const delCardConfirm = () => {
|
||||
delDialog.value = false;
|
||||
delKnowledge(knowledgeIndex.value, knowledge.value);
|
||||
};
|
||||
|
||||
const sendMsg = (value: string) => {
|
||||
createNewSession(value);
|
||||
};
|
||||
|
||||
const getTitle = (session_id: string, value: string) => {
|
||||
let obj = { title: '新会话', path: `chat/${session_id}`, id: session_id, isMore: false, isNoTitle: true };
|
||||
usemenuStore.updataMenuChildren(obj);
|
||||
usemenuStore.changeIsFirstSession(true);
|
||||
usemenuStore.changeFirstQuery(value);
|
||||
router.push(`/platform/chat/${session_id}`);
|
||||
};
|
||||
|
||||
async function createNewSession(value: string): Promise<void> {
|
||||
// 从localStorage获取设置中的知识库ID
|
||||
const settingsStr = localStorage.getItem("WeKnora_settings");
|
||||
let knowledgeBaseId = "";
|
||||
|
||||
if (settingsStr) {
|
||||
try {
|
||||
const settings = JSON.parse(settingsStr);
|
||||
if (settings.knowledgeBaseId) {
|
||||
knowledgeBaseId = settings.knowledgeBaseId;
|
||||
createSessions({ knowledge_base_id: knowledgeBaseId }).then(res => {
|
||||
if (res.data && res.data.id) {
|
||||
getTitle(res.data.id, value);
|
||||
} else {
|
||||
// 错误处理
|
||||
console.error("创建会话失败");
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("创建会话出错:", error);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("解析设置失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果设置中没有知识库ID,则使用测试数据
|
||||
const testData = getTestData();
|
||||
if (!testData || !testData.knowledge_bases || testData.knowledge_bases.length === 0) {
|
||||
console.error("测试数据未初始化或不包含知识库");
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用第一个知识库ID
|
||||
knowledgeBaseId = testData.knowledge_bases[0].id;
|
||||
|
||||
createSessions({ knowledge_base_id: knowledgeBaseId }).then(res => {
|
||||
if (res.data && res.data.id) {
|
||||
getTitle(res.data.id, value);
|
||||
} else {
|
||||
// 错误处理
|
||||
console.error("创建会话失败");
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("创建会话出错:", error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-show="cardList.length" class="knowledge-card-box" style="position: relative">
|
||||
<div class="knowledge-card-wrap" ref="knowledgeScroll" @scroll="handleScroll">
|
||||
<div class="knowledge-card" v-for="(item, index) in cardList" :key="index" @click="openCardDetails(item)">
|
||||
<div class="card-content">
|
||||
<div class="card-content-nav">
|
||||
<span class="card-content-title">{{ item.file_name }}</span>
|
||||
<t-popup v-model="item.isMore" @overlay-click="delCard(index, item)" overlayClassName="card-more"
|
||||
:on-visible-change="onVisibleChange" trigger="click" destroy-on-close placement="bottom-right">
|
||||
<div variant="outline" class="more-wrap" @click.stop="openMore(index)"
|
||||
:class="[moreIndex == index ? 'active-more' : '']">
|
||||
<img class="more" src="@/assets/img/more.png" alt="" />
|
||||
</div>
|
||||
<template #content>
|
||||
<t-icon class="icon svg-icon del-card" name="delete" />
|
||||
<span class="del-card" style="margin-left: 8px">删除文档</span>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
<div class="card-analyze" v-show="item.parse_status != 'completed'">
|
||||
<t-icon :name="item.parse_status == 'failed' ? 'close-circle' : 'loading'" class="card-analyze-loading"
|
||||
:class="[item.parse_status == 'failed' ? 'failure' : '']"></t-icon>
|
||||
<span class="card-analyze-txt" :class="[item.parse_status == 'failed' ? 'failure' : '']">{{
|
||||
item.parse_status == "failed" ? "解析失败" : "解析中..."
|
||||
}}</span>
|
||||
</div>
|
||||
<div v-show="item.parse_status == 'completed'" class="card-content-txt">
|
||||
{{ item.description }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<span class="card-time">{{ item.updated_at }}</span>
|
||||
<div class="card-type">
|
||||
<span>{{ item.file_type }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<t-dialog v-model:visible="delDialog" dialogClassName="del-knowledge" :closeBtn="false" :cancelBtn="null"
|
||||
:confirmBtn="null">
|
||||
<div class="circle-wrap">
|
||||
<div class="header">
|
||||
<img class="circle-img" src="@/assets/img/circle.png" alt="">
|
||||
<span class="circle-title">删除确认</span>
|
||||
</div>
|
||||
<span class="del-circle-txt">
|
||||
{{ `确认要删除技能"${knowledge.file_name}",删除后不可恢复` }}
|
||||
</span>
|
||||
<div class="circle-btn">
|
||||
<span class="circle-btn-txt" @click="delDialog = false">取消</span>
|
||||
<span class="circle-btn-txt confirm" @click="delCardConfirm">确认删除</span>
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</div>
|
||||
<InputField @send-msg="sendMsg"></InputField>
|
||||
<DocContent :visible="isCardDetails" :details="details" @closeDoc="closeDoc" @getDoc="getDoc"></DocContent>
|
||||
</div>
|
||||
<EmptyKnowledge v-show="!cardList.length"></EmptyKnowledge>
|
||||
</template>
|
||||
<style>
|
||||
.card-more {
|
||||
z-index: 99 !important;
|
||||
}
|
||||
|
||||
.card-more .t-popup__content {
|
||||
width: 160px;
|
||||
height: 40px;
|
||||
line-height: 30px;
|
||||
padding-left: 14px;
|
||||
cursor: pointer;
|
||||
margin-top: 4px !important;
|
||||
color: #000000e6;
|
||||
}
|
||||
.card-more .t-popup__content:hover {
|
||||
color: #FA5151 !important;
|
||||
}
|
||||
</style>
|
||||
<style scoped lang="less">
|
||||
.knowledge-card-box {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 1250px) and (min-width: 1045px) {
|
||||
.answers-input {
|
||||
transform: translateX(-329px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 654px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1045px) {
|
||||
.answers-input {
|
||||
transform: translateX(-250px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 500px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 750px) {
|
||||
.answers-input {
|
||||
transform: translateX(-182px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 340px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.answers-input {
|
||||
transform: translateX(-164px);
|
||||
}
|
||||
|
||||
:deep(.t-textarea__inner) {
|
||||
width: 300px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.knowledge-card-wrap {
|
||||
// padding: 24px 44px;
|
||||
padding: 24px 44px 80px 44px;
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
:deep(.del-knowledge) {
|
||||
padding: 0px !important;
|
||||
border-radius: 6px !important;
|
||||
|
||||
.t-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.t-dialog__body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.t-dialog__footer {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-dialog__position.t-dialog--top) {
|
||||
padding-top: 40vh !important;
|
||||
}
|
||||
|
||||
.circle-wrap {
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.circle-img {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.circle-title {
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.del-circle-txt {
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
display: inline-block;
|
||||
margin-left: 29px;
|
||||
margin-bottom: 21px;
|
||||
}
|
||||
|
||||
.circle-btn {
|
||||
height: 22px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
}
|
||||
|
||||
.circle-btn-txt {
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 22px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
color: #FA5151;
|
||||
margin-left: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.knowledge-card {
|
||||
border: 2px solid #fbfbfb;
|
||||
height: 174px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 8px 0 #00000005;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
|
||||
.card-content {
|
||||
padding: 10px 20px 23px;
|
||||
}
|
||||
|
||||
.card-analyze {
|
||||
height: 66px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.card-analyze-loading {
|
||||
display: block;
|
||||
color: #07c05f;
|
||||
font-size: 15px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.card-analyze-txt {
|
||||
color: #07c05f;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
||||
.failure {
|
||||
color: #fa5151;
|
||||
}
|
||||
|
||||
.card-content-nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.card-content-title {
|
||||
width: 200px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.more-wrap {
|
||||
display: flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.more-wrap:hover {
|
||||
background: #e7e7e7;
|
||||
}
|
||||
|
||||
.more {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.active-more {
|
||||
background: #e7e7e7;
|
||||
}
|
||||
|
||||
.card-content-txt {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
overflow: hidden;
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.card-bottom {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
padding: 0 20px;
|
||||
box-sizing: border-box;
|
||||
height: 32px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(48, 50, 54, 0.02);
|
||||
}
|
||||
|
||||
.card-time {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.card-type {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
padding: 2px 4px;
|
||||
background: #3032360f;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.knowledge-card:hover {
|
||||
border: 2px solid #07c05f;
|
||||
}
|
||||
|
||||
.knowledge-card-upload {
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
cursor: pointer;
|
||||
|
||||
.btn-upload {
|
||||
margin: 33px auto 0;
|
||||
width: 112px;
|
||||
height: 32px;
|
||||
border: 1px solid #dcdcdc;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.svg-icon-download {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-described {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
display: block;
|
||||
width: 188px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.knowledge-card-wrap {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.del-card {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 小屏幕平板 - 2列 */
|
||||
@media (min-width: 900px) {
|
||||
.knowledge-card-wrap {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 中等屏幕 - 3列 */
|
||||
@media (min-width: 1250px) {
|
||||
.knowledge-card-wrap {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 中等屏幕 - 3列 */
|
||||
@media (min-width: 1600px) {
|
||||
.knowledge-card-wrap {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 大屏幕 - 4列 */
|
||||
@media (min-width: 2000px) {
|
||||
.knowledge-card-wrap {
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="main" ref="dropzone" @dragover="dragover" @drop="drop" @dragstart="dragstart">
|
||||
<Menu></Menu>
|
||||
<RouterView />
|
||||
<div class="upload-mask" v-show="ismask">
|
||||
<input type="file" style="display: none" ref="uploadInput" accept=".pdf,.docx,.doc,.txt,.md" />
|
||||
<UploadMask></UploadMask>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import Menu from '@/components/menu.vue'
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router'
|
||||
import { storeToRefs } from "pinia";
|
||||
import { knowledgeStore } from "@/stores/knowledge";
|
||||
const usemenuStore = knowledgeStore();
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase'
|
||||
import UploadMask from '@/components/upload-mask.vue'
|
||||
let { requestMethod } = useKnowledgeBase()
|
||||
const router = useRouter();
|
||||
let ismask = ref(false)
|
||||
let dropzone = ref();
|
||||
let uploadInput = ref();
|
||||
const dragover = (event) => {
|
||||
event.preventDefault();
|
||||
ismask.value = true;
|
||||
if (((window.innerWidth - event.clientX) < 50) || ((window.innerHeight - event.clientY) < 50) || event.clientX < 50 || event.clientY < 50) {
|
||||
ismask.value = false
|
||||
}
|
||||
}
|
||||
const drop = (event) => {
|
||||
event.preventDefault();
|
||||
ismask.value = false
|
||||
const DataTransferItemList = event.dataTransfer.items;
|
||||
for (const dataTransferItem of DataTransferItemList) {
|
||||
const fileEntry = dataTransferItem.webkitGetAsEntry();
|
||||
if (fileEntry) {
|
||||
fileEntry.file((file: file) => {
|
||||
requestMethod(file, uploadInput)
|
||||
router.push('/platform/knowledgeBase?upload=true')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const dragstart = (event) => {
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
<style lang="less">
|
||||
.main {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
.upload-mask {
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
img {
|
||||
-webkit-user-drag: none;
|
||||
-khtml-user-drag: none;
|
||||
-moz-user-drag: none;
|
||||
-o-user-drag: none;
|
||||
user-drag: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="settings-container">
|
||||
<div class="settings-header">
|
||||
<h2>系统配置</h2>
|
||||
</div>
|
||||
<div class="settings-form">
|
||||
<t-form ref="form" :data="formData" :rules="rules" @submit="onSubmit">
|
||||
<t-form-item label="API 服务端点" name="endpoint">
|
||||
<t-input v-model="formData.endpoint" placeholder="请输入API服务端点,例如:http://localhost" />
|
||||
</t-form-item>
|
||||
<t-form-item label="API Key" name="apiKey">
|
||||
<t-input v-model="formData.apiKey" placeholder="请输入API Key" />
|
||||
</t-form-item>
|
||||
<t-form-item label="知识库ID" name="knowledgeBaseId">
|
||||
<t-input v-model="formData.knowledgeBaseId" placeholder="请输入知识库ID" />
|
||||
</t-form-item>
|
||||
<t-form-item>
|
||||
<t-space>
|
||||
<t-button theme="primary" type="submit">保存配置</t-button>
|
||||
<t-button theme="default" @click="resetForm">重置</t-button>
|
||||
</t-space>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
const form = ref(null);
|
||||
|
||||
const formData = reactive({
|
||||
endpoint: '',
|
||||
apiKey: '',
|
||||
knowledgeBaseId: ''
|
||||
});
|
||||
|
||||
const rules = {
|
||||
endpoint: [{ required: true, message: '请输入API服务端点', trigger: 'blur' }],
|
||||
apiKey: [{ required: true, message: '请输入API Key', trigger: 'blur' }],
|
||||
knowledgeBaseId: [{ required: true, message: '请输入知识库ID', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化表单数据
|
||||
const settings = settingsStore.getSettings();
|
||||
formData.endpoint = settings.endpoint;
|
||||
formData.apiKey = settings.apiKey;
|
||||
formData.knowledgeBaseId = settings.knowledgeBaseId;
|
||||
});
|
||||
|
||||
const onSubmit = ({ validateResult }) => {
|
||||
if (validateResult === true) {
|
||||
settingsStore.saveSettings({
|
||||
endpoint: formData.endpoint,
|
||||
apiKey: formData.apiKey,
|
||||
knowledgeBaseId: formData.knowledgeBaseId
|
||||
});
|
||||
MessagePlugin.success('配置保存成功');
|
||||
}
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
const settings = settingsStore.getSettings();
|
||||
formData.endpoint = settings.endpoint;
|
||||
formData.apiKey = settings.apiKey;
|
||||
formData.knowledgeBaseId = settings.knowledgeBaseId;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.settings-container {
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
margin: 20px;
|
||||
min-height: 80vh;
|
||||
|
||||
.settings-header {
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 16px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #000000;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-form {
|
||||
max-width: 600px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||