mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: AI机器人支持多会话
This commit is contained in:
parent
501235ef12
commit
f0b5e0c3b9
@ -3175,6 +3175,14 @@ class DialogController extends AbstractController
|
|||||||
$sessions = WebSocketDialogSession::whereDialogId($dialog->id)
|
$sessions = WebSocketDialogSession::whereDialogId($dialog->id)
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
->paginate(Base::getPaginate(100, 10));
|
->paginate(Base::getPaginate(100, 10));
|
||||||
|
$sessions->transform(function ($item) use ($dialog) {
|
||||||
|
if ($item->id === $dialog->session_id) {
|
||||||
|
$item->is_open = 1;
|
||||||
|
} else {
|
||||||
|
$item->is_open = 0;
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
//
|
//
|
||||||
return Base::retSuccess('success', $sessions);
|
return Base::retSuccess('success', $sessions);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,9 +34,10 @@ class CreateWebSocketDialogSessionsTable extends Migration
|
|||||||
->get();
|
->get();
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$title = WebSocketDialogMsg::whereDialogId($item->id)->where('key', '!=', '')->orderBy('id')->value('key');
|
$title = WebSocketDialogMsg::whereDialogId($item->id)->where('key', '!=', '')->orderBy('id')->value('key');
|
||||||
$session = WebSocketDialogSession::create([
|
$session = WebSocketDialogSession::createInstance([
|
||||||
'dialog_id' => $item->id,
|
'dialog_id' => $item->id,
|
||||||
'title' => $title ? Base::cutStr($title, 100) : 'Unknown',
|
'title' => $title ? Base::cutStr($title, 100) : 'Unknown',
|
||||||
|
'created_at' => $item->created_at,
|
||||||
]);
|
]);
|
||||||
$session->save();
|
$session->save();
|
||||||
$item->session_id = $session->id;
|
$item->session_id = $session->id;
|
||||||
|
|||||||
@ -0,0 +1,126 @@
|
|||||||
|
<template>
|
||||||
|
<div class="dialog-session-history">
|
||||||
|
<div class="session-history-title">{{$L('与 (*) 会话历史', sessionData.name)}}</div>
|
||||||
|
<Scrollbar
|
||||||
|
ref="list"
|
||||||
|
class="session-history-list"
|
||||||
|
@on-scroll="listScroll">
|
||||||
|
<ul>
|
||||||
|
<li v-for="(item, index) in listData" :key="index" @click="onOpen(item)">
|
||||||
|
<div class="history-title">
|
||||||
|
<em v-if="item.is_open">{{$L('当前')}}</em>{{item.title || $L('新会话')}}
|
||||||
|
</div>
|
||||||
|
<div class="history-time" :title="item.created_at">
|
||||||
|
{{$A.timeFormat(item.created_at)}}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div v-if="listLoad > 0" class="session-history-load">
|
||||||
|
<Loading/>
|
||||||
|
</div>
|
||||||
|
</Scrollbar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "DialogSessionHistory",
|
||||||
|
props: {
|
||||||
|
sessionData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
openIng: false,
|
||||||
|
|
||||||
|
listData: [],
|
||||||
|
listLoad: 0,
|
||||||
|
listCurrentPage: 1,
|
||||||
|
listHasMorePages: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.getListData(1)
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
scrollE() {
|
||||||
|
if (!this.$refs.list) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
const scrollInfo = this.$refs.list.scrollInfo()
|
||||||
|
return scrollInfo.scrollE
|
||||||
|
},
|
||||||
|
|
||||||
|
getListData(page) {
|
||||||
|
this.listLoad++;
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: "dialog/session/list",
|
||||||
|
data: {
|
||||||
|
dialog_id: this.sessionData.dialog_id,
|
||||||
|
page: page,
|
||||||
|
pagesize: 50
|
||||||
|
}
|
||||||
|
}).then(({data}) => {
|
||||||
|
if (data.current_page === 1) {
|
||||||
|
this.listData = data.data
|
||||||
|
} else {
|
||||||
|
this.listData = this.listData.concat(data.data)
|
||||||
|
}
|
||||||
|
this.listCurrentPage = data.current_page;
|
||||||
|
this.listHasMorePages = data.current_page < data.last_page;
|
||||||
|
this.$nextTick(this.getListNextPage);
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
$A.modalError(msg)
|
||||||
|
}).finally(_ => {
|
||||||
|
this.listLoad--;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
listScroll() {
|
||||||
|
if (this.scrollE() < 10) {
|
||||||
|
this.getListNextPage()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getListNextPage() {
|
||||||
|
if (this.scrollE() < 10
|
||||||
|
&& this.listLoad === 0
|
||||||
|
&& this.listHasMorePages) {
|
||||||
|
this.getListData(this.listCurrentPage + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onOpen(item) {
|
||||||
|
if (item.is_open) {
|
||||||
|
this.$emit("on-close")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (this.openIng) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.openIng = true
|
||||||
|
//
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: "dialog/session/open",
|
||||||
|
data: {
|
||||||
|
session_id: item.id,
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
this.$emit("on-submit")
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
$A.modalError(msg)
|
||||||
|
}).finally(_ => {
|
||||||
|
this.openIng = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -644,6 +644,18 @@
|
|||||||
<DialogRespond v-if="respondShow" :respond-data="respondData" @on-close="respondShow=false"/>
|
<DialogRespond v-if="respondShow" :respond-data="respondData" @on-close="respondShow=false"/>
|
||||||
</DrawerOverlay>
|
</DrawerOverlay>
|
||||||
|
|
||||||
|
<!--历史会话-->
|
||||||
|
<DrawerOverlay
|
||||||
|
v-model="sessionHistoryShow"
|
||||||
|
placement="right"
|
||||||
|
:size="500">
|
||||||
|
<DialogSessionHistory
|
||||||
|
v-if="sessionHistoryShow"
|
||||||
|
:session-data="sessionHistoryData"
|
||||||
|
@on-submit="onSessionSubmit"
|
||||||
|
@on-close="sessionHistoryShow=false"/>
|
||||||
|
</DrawerOverlay>
|
||||||
|
|
||||||
<!--待办完成-->
|
<!--待办完成-->
|
||||||
<DrawerOverlay
|
<DrawerOverlay
|
||||||
v-model="todoViewShow"
|
v-model="todoViewShow"
|
||||||
@ -692,6 +704,7 @@ import DialogUpload from "./DialogUpload";
|
|||||||
import DrawerOverlay from "../../../components/DrawerOverlay";
|
import DrawerOverlay from "../../../components/DrawerOverlay";
|
||||||
import DialogGroupInfo from "./DialogGroupInfo";
|
import DialogGroupInfo from "./DialogGroupInfo";
|
||||||
import DialogRespond from "./DialogRespond";
|
import DialogRespond from "./DialogRespond";
|
||||||
|
import DialogSessionHistory from "./DialogSessionHistory";
|
||||||
import ChatInput from "./ChatInput";
|
import ChatInput from "./ChatInput";
|
||||||
|
|
||||||
import VirtualList from "vue-virtual-scroll-list-hi"
|
import VirtualList from "vue-virtual-scroll-list-hi"
|
||||||
@ -716,6 +729,7 @@ export default {
|
|||||||
UserSelect,
|
UserSelect,
|
||||||
ImgUpload,
|
ImgUpload,
|
||||||
DialogRespond,
|
DialogRespond,
|
||||||
|
DialogSessionHistory,
|
||||||
DialogItem,
|
DialogItem,
|
||||||
VirtualList,
|
VirtualList,
|
||||||
ChatInput,
|
ChatInput,
|
||||||
@ -827,6 +841,9 @@ export default {
|
|||||||
respondShow: false,
|
respondShow: false,
|
||||||
respondData: {},
|
respondData: {},
|
||||||
|
|
||||||
|
sessionHistoryShow: false,
|
||||||
|
sessionHistoryData: {},
|
||||||
|
|
||||||
todoSettingShow: false,
|
todoSettingShow: false,
|
||||||
todoSettingLoad: 0,
|
todoSettingLoad: 0,
|
||||||
todoSettingData: {
|
todoSettingData: {
|
||||||
@ -1940,6 +1957,11 @@ export default {
|
|||||||
if (!this.isAiBot) {
|
if (!this.isAiBot) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.sessionHistoryData = {
|
||||||
|
dialog_id: this.dialogId,
|
||||||
|
name: this.dialogData.name,
|
||||||
|
}
|
||||||
|
this.sessionHistoryShow = true
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 发送快捷指令
|
// 发送快捷指令
|
||||||
@ -2584,6 +2606,11 @@ export default {
|
|||||||
this.$store.dispatch("openOkr", this.dialogData.link_id);
|
this.$store.dispatch("openOkr", this.dialogData.link_id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSessionSubmit() {
|
||||||
|
this.sessionHistoryShow = false;
|
||||||
|
this.onGetMsgClear();
|
||||||
|
},
|
||||||
|
|
||||||
onGetMsgClear() {
|
onGetMsgClear() {
|
||||||
this.getMsgs({
|
this.getMsgs({
|
||||||
dialog_id: this.dialogId,
|
dialog_id: this.dialogId,
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
@import "dialog-group-info";
|
@import "dialog-group-info";
|
||||||
@import "dialog-respond";
|
@import "dialog-respond";
|
||||||
@import "dialog-select";
|
@import "dialog-select";
|
||||||
|
@import "dialog-session-history";
|
||||||
@import "dialog-wrapper";
|
@import "dialog-wrapper";
|
||||||
@import "file-content";
|
@import "file-content";
|
||||||
@import "general-operation";
|
@import "general-operation";
|
||||||
|
|||||||
113
resources/assets/sass/pages/components/dialog-session-history.scss
vendored
Normal file
113
resources/assets/sass/pages/components/dialog-session-history.scss
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
.dialog-session-history {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
|
||||||
|
.session-history-title {
|
||||||
|
text-align: center;
|
||||||
|
height: 56px;
|
||||||
|
line-height: 56px;
|
||||||
|
border-bottom: 1px solid #eeeeee;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0 24px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-history-list {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 6px;
|
||||||
|
|
||||||
|
ul {
|
||||||
|
> li {
|
||||||
|
list-style: none;
|
||||||
|
padding: 12px;
|
||||||
|
margin: 6px;
|
||||||
|
border-top-right-radius: 6px;
|
||||||
|
border-top-left-radius: 6px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
display: table;
|
||||||
|
clear: both;
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 1px;
|
||||||
|
background: #eeeeee;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba($primary-desc-color, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
&::before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-title {
|
||||||
|
float: left;
|
||||||
|
line-height: 20px;
|
||||||
|
|
||||||
|
> em {
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-right: 6px;
|
||||||
|
background: #666;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 0 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
line-height: 20px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-time {
|
||||||
|
float: right;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-history-load {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 36px;
|
||||||
|
.common-loading {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body.window-portrait {
|
||||||
|
.dialog-session-history {
|
||||||
|
.session-history-list {
|
||||||
|
> ul {
|
||||||
|
> li {
|
||||||
|
&:hover {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user