ai-assistant-pro 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/demo/api/index.js +11 -2
- package/components/demo/src/chat-tools.vue +1 -1
- package/components/demo/src/chat.vue +5 -2
- package/components/demo/src/hot-search.vue +8 -1
- package/components/demo/src/main.vue +52 -21
- package/components/demo/utils/constants.js +2 -0
- package/components/demo/utils/request.js +3 -2
- package/dist/ai-assistant-pro.common.js +101 -80
- package/dist/ai-assistant-pro.common.js.map +1 -1
- package/dist/ai-assistant-pro.css +1 -1
- package/dist/ai-assistant-pro.umd.js +101 -80
- package/dist/ai-assistant-pro.umd.js.map +1 -1
- package/dist/ai-assistant-pro.umd.min.js +4 -4
- package/dist/ai-assistant-pro.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import request from '../utils/request'
|
|
2
2
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import constants from '../utils/constants';
|
|
4
|
+
|
|
5
|
+
const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
|
|
6
|
+
const prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
|
|
5
7
|
import cache from '../plugins/cache';
|
|
6
8
|
export const ssoAuth = (token) => {
|
|
7
9
|
return request({
|
|
@@ -84,6 +86,13 @@ export const countAccess = (resId) => {
|
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
export const checkCourseIdIsExist = (resId) => {
|
|
90
|
+
return request({
|
|
91
|
+
url: prefix + `/ia/hasPermission?courseId=${resId}`,
|
|
92
|
+
method: 'get',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
87
96
|
export async function sendMessageEventSource(params, signal, onmessage) {
|
|
88
97
|
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
|
|
89
98
|
method: 'POST',
|
|
@@ -94,7 +94,7 @@ export default {
|
|
|
94
94
|
scrollToBottom() {
|
|
95
95
|
this.$refs.chatContainer.scrollTop = this.$refs.chatContainer.scrollHeight;
|
|
96
96
|
},
|
|
97
|
-
async postMessage(list, commonKey) {
|
|
97
|
+
async postMessage(list, commonKey, parentMsgId) {
|
|
98
98
|
let reanswerParams = {};
|
|
99
99
|
if (list) {
|
|
100
100
|
reanswerParams = {
|
|
@@ -112,6 +112,7 @@ export default {
|
|
|
112
112
|
resId: this.resId,
|
|
113
113
|
chatId: this.chatId || undefined,
|
|
114
114
|
commonKey: commonKey || false,
|
|
115
|
+
parentMsgId: parentMsgId || undefined,
|
|
115
116
|
...reanswerParams,
|
|
116
117
|
}
|
|
117
118
|
]
|
|
@@ -143,7 +144,7 @@ export default {
|
|
|
143
144
|
// 结束标识
|
|
144
145
|
if (status === 2 || status === 1) {
|
|
145
146
|
if (commonKey) {
|
|
146
|
-
this.postMessage(list, commonKey);
|
|
147
|
+
this.postMessage(list, commonKey, parentMsgId);
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
currentList.finish = true;
|
|
@@ -249,6 +250,7 @@ export default {
|
|
|
249
250
|
padding: 24px 24px;
|
|
250
251
|
margin-left: 16px;
|
|
251
252
|
line-height: 24px;
|
|
253
|
+
flex: 1;
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
.user-info {
|
|
@@ -256,6 +258,7 @@ export default {
|
|
|
256
258
|
border-radius: 12px;
|
|
257
259
|
border-top-right-radius: 0;
|
|
258
260
|
background: linear-gradient(90deg, rgba(130, 136, 220, 1) 0%, rgba(48, 90, 220, 1) 100%);
|
|
261
|
+
flex: inherit;
|
|
259
262
|
}
|
|
260
263
|
|
|
261
264
|
.link {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="hot-search-contain">
|
|
3
3
|
<div class="robot">
|
|
4
|
-
<img src="../static/robot.png" alt="" style="width: 48px; height: 48px"
|
|
4
|
+
<!-- <img src="../static/robot.png" alt="" style="width: 48px; height: 48px">-->
|
|
5
|
+
<div class="robot-image-div"></div>
|
|
5
6
|
</div>
|
|
6
7
|
<div class="robot-message">
|
|
7
8
|
<p>Hi,我是学习助手。</p>
|
|
@@ -79,4 +80,10 @@ p {
|
|
|
79
80
|
right: -16px;
|
|
80
81
|
float: right;
|
|
81
82
|
}
|
|
83
|
+
.robot-image-div {
|
|
84
|
+
width: 48px;
|
|
85
|
+
height: 48px;
|
|
86
|
+
background: url("../static/robot.png");
|
|
87
|
+
background-size: 100%;
|
|
88
|
+
}
|
|
82
89
|
</style>
|
|
@@ -10,33 +10,39 @@
|
|
|
10
10
|
<i class="el-icon-close"></i>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
+
<template v-if="courseFlag">
|
|
13
14
|
<div class="ai-main-content">
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
<hot-search v-if="!chatShow" @select-module="selectModule"></hot-search>
|
|
16
|
+
<chat v-if="chatShow"
|
|
17
|
+
ref="chatRef"
|
|
18
|
+
:resId="resId"
|
|
19
|
+
:chatId="chatId"
|
|
20
|
+
:key-word="aiMessageKeyWord"
|
|
21
|
+
:message-data="messageList"
|
|
22
|
+
@on-reanser="reanserMethod"
|
|
23
|
+
@on-message-finish="messageFinish"
|
|
24
|
+
/>
|
|
24
25
|
</div>
|
|
25
26
|
<div class="tools-wrap">
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
<span @click="addNewChat">新增对话</span>
|
|
28
|
+
<span @click="clearChat">清空对话</span>
|
|
28
29
|
</div>
|
|
29
30
|
<div class="ai-message-send" @keyup.enter="goChat">
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
<el-input v-model="aiMessage"
|
|
32
|
+
placeholder="可以提出问题...">
|
|
33
|
+
</el-input>
|
|
34
|
+
<div class="ai-send-icon" @click="goChat">
|
|
35
|
+
<img src="../static/send-icon.png" alt="" style="width: 24px; height: 24px">
|
|
36
|
+
</div>
|
|
36
37
|
</div>
|
|
37
38
|
<p class="disclaimer">
|
|
38
|
-
|
|
39
|
+
此功能公测期间对正式版用户开放
|
|
39
40
|
</p>
|
|
41
|
+
</template>
|
|
42
|
+
<div v-if="!courseFlag" class="message-wrap">
|
|
43
|
+
<div class="message-line">{{message}}</div>
|
|
44
|
+
<div class="message-line">不能交流</div>
|
|
45
|
+
</div>
|
|
40
46
|
</div>
|
|
41
47
|
</template>
|
|
42
48
|
<script>
|
|
@@ -44,7 +50,7 @@ import HotSearch from './hot-search.vue';
|
|
|
44
50
|
import Chat from './chat.vue';
|
|
45
51
|
import Cookies from "js-cookie";
|
|
46
52
|
import { getUserInfo } from '../utils/config';
|
|
47
|
-
import { newChat, chartClear, getDetailList, countAccess } from '../api/index';
|
|
53
|
+
import { newChat, chartClear, getDetailList, countAccess,checkCourseIdIsExist } from '../api/index';
|
|
48
54
|
export default {
|
|
49
55
|
name: 'AiAssistant',
|
|
50
56
|
components: {
|
|
@@ -60,7 +66,18 @@ export default {
|
|
|
60
66
|
},
|
|
61
67
|
watch: {
|
|
62
68
|
visible() {
|
|
63
|
-
|
|
69
|
+
if (this.visible){
|
|
70
|
+
checkCourseIdIsExist(this.resId).then(res=>{
|
|
71
|
+
if (res.flag ==true){
|
|
72
|
+
this.courseFlag = true;
|
|
73
|
+
this.queryList();
|
|
74
|
+
}else{
|
|
75
|
+
this.courseFlag = false;
|
|
76
|
+
this.message = res.message;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
64
81
|
},
|
|
65
82
|
},
|
|
66
83
|
data() {
|
|
@@ -68,6 +85,8 @@ export default {
|
|
|
68
85
|
aiMessage: '', // 页面显示值
|
|
69
86
|
aiMessageKeyWord: '', // 传入组件值
|
|
70
87
|
chatShow: false,
|
|
88
|
+
courseFlag: false,
|
|
89
|
+
message:'',
|
|
71
90
|
messageList: [],
|
|
72
91
|
chatId: undefined, // 对话id
|
|
73
92
|
stop: false
|
|
@@ -289,4 +308,16 @@ export default {
|
|
|
289
308
|
}
|
|
290
309
|
}
|
|
291
310
|
}
|
|
311
|
+
.message-wrap {
|
|
312
|
+
height: calc(100% - 53px );
|
|
313
|
+
align-items: center;
|
|
314
|
+
justify-content: center;
|
|
315
|
+
display: flex;
|
|
316
|
+
flex-direction: column;
|
|
317
|
+
}
|
|
318
|
+
.message-line {
|
|
319
|
+
color: red;
|
|
320
|
+
font-size: 25px;
|
|
321
|
+
margin: 8px 0; /* 上下各 8px 的间距 */
|
|
322
|
+
}
|
|
292
323
|
</style>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
2
|
import cache from '../plugins/cache'
|
|
3
3
|
import { Message } from 'element-ui'
|
|
4
|
-
const door = sessionStorage.getItem('
|
|
4
|
+
const door = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL');
|
|
5
5
|
import { decrypt } from './aes-utils';
|
|
6
|
+
import constants from '../utils/constants';
|
|
6
7
|
|
|
7
8
|
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
|
8
9
|
|
|
9
10
|
const service = axios.create({
|
|
10
11
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
|
11
|
-
baseURL: door ||
|
|
12
|
+
baseURL: door || constants.publicPath,
|
|
12
13
|
// 超时
|
|
13
14
|
timeout: 80000
|
|
14
15
|
})
|