Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
GibbersWU
ChatGPT
提交
75a09feb
C
ChatGPT
项目概览
GibbersWU
/
ChatGPT
与 Fork 源项目一致
Fork自
化语 / ChatGPT Template With Vue
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ChatGPT
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
75a09feb
编写于
7月 15, 2023
作者:
6
6323f46df0dd9b1fa44f49b9
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto Commit
上级
ee014299
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
38 addition
and
20 deletion
+38
-20
src/Home.vue
src/Home.vue
+38
-20
未找到文件。
src/Home.vue
浏览文件 @
75a09feb
<
template
>
<router-view/>
<!--
<div
>
<a
>
欢迎使用可爱又聪明的机器人!
</a>
<div><span
style=
"color:chartreuse;"
>
用户:
</span>
<span
style=
"color:chartreuse;"
>
{{
username
}}
</span></div>
-->
<!--
<div
class=
"dialog"
>
<div
class=
"container1 ivu-p"
>
<!--
<div><span
style=
"color:chartreuse;"
>
用户:
</span>
<span
style=
"color:chartreuse;"
>
{{
username
}}
</span></div>
-->
<div
class=
"dialog"
>
<template
v-for=
"(item, index) in dialogs"
:key=
"index"
>
<div
class=
"dialog-item"
:class=
"
{ 'dialog-item-me': item.role === 'me', 'dialog-item-ai': item.role === 'ai' }">
<div
class=
"dialog-item-main"
>
{{
item
.
text
}}
</div>
</div>
</
template
>
</div>
-->
</div>
<
!-- <
div class="question ivu-mt">
<div
class=
"question ivu-mt"
>
<Input
v-model=
"question"
type=
"textarea"
:autosize=
"{ minRows: 4, maxRows: 6 }"
placeholder=
"输入你的问题"
/>
<Row
class=
"ivu-mt"
>
<Col>
...
...
@@ -21,19 +20,19 @@
<Button
size=
"large"
class=
"ivu-ml"
icon=
"md-add"
:disabled=
"loading"
@
click=
"handleNewChat"
>
新对话
</Button>
</Col>
<Col>
<Button size="large" class="ivu-ml" icon="md-arrow-up" :disabled="loading" @click="handleHistoryChat">
历史
记录</Button>
<Button
size=
"large"
class=
"ivu-ml"
icon=
"md-arrow-up"
:disabled=
"loading"
@
click=
"handleHistoryChat"
>
记录
</Button>
</Col>
<Col>
<Button
type=
"large"
class=
"ivu-ml"
icon=
"md-log-out"
:disabled=
"loading"
@
click=
"logout"
>
退出
</Button>
</Col>
</Row>
-->
<
!-- </div> --
>
<
!--</div> --
>
</Row>
<
/div
>
<
/div
>
</template>
<
script
>
import
{
fetchEventSource
}
from
'
@microsoft/fetch-event-source
'
;
import
{
apiKey
,
apiUrl
}
from
'
./api
'
;
import
{
apiKey
,
apiUrl
}
from
'
.
.
/api
'
;
import
axios
from
'
axios
'
axios
.
defaults
.
withCredentials
=
true
;
// 发送凭据
export
default
{
...
...
@@ -54,8 +53,8 @@ export default {
// return this.username
},
methods
:
{
goto
()
{
this
.
$router
.
push
(
"
/login
"
);
create
()
{
},
handleSend
()
{
if
(
this
.
loading
||
this
.
question
===
''
)
return
;
...
...
@@ -107,6 +106,13 @@ export default {
},
onmessage
:
(
msg
)
=>
{
if
(
msg
.
data
===
'
[DONE]
'
)
{
axios
({
method
:
"
post
"
,
url
:
"
https://flask-wujiaping.inscode.cc/addhistory
"
,
data
:
dialog
.
text
,
}).
then
((
res
)
=>
{
console
.
log
(
res
.
data
)
});
this
.
loading
=
false
;
return
;
};
...
...
@@ -122,6 +128,9 @@ export default {
dialog
.
text
+=
text
;
}
},
onclose
()
{
console
.
log
(
"
close
"
);
},
onerror
:
(
err
)
=>
{
console
.
log
(
"
error
"
,
err
);
}
...
...
@@ -131,11 +140,20 @@ export default {
this
.
dialogs
=
[];
},
handleHistoryChat
()
{
if
(
JSON
.
stringify
(
this
.
dialogs
)
===
'
[]
'
)
{
alert
(
"
无对话内容!
"
);
return
;
// if (JSON.stringify(this.dialogs) === '[]') {
// alert("无对话内容!");
// return;
// }
axios
({
method
:
"
get
"
,
url
:
"
https://flask-wujiaping.inscode.cc/gethistory
"
,
}).
then
((
res
)
=>
{
console
.
log
(
res
.
data
)
if
(
200
==
res
.
data
[
'
code
'
]){
alert
(
res
.
data
[
'
data
'
]);
}
alert
(
JSON
.
stringify
(
this
.
dialogs
));
});
// alert(JSON.stringify(this.dialogs));
},
logout
(){
sessionStorage
.
removeItem
(
'
username
'
)
...
...
@@ -157,12 +175,12 @@ export default {
}
</
script
>
<
style
>
.container
222
{
.container
1
{
height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
/* background-color:gainsboro; */
background-image
:
url(../
src/
assets/background.jpg)
;
background-image
:
url(../assets/background.jpg)
;
}
.dialog
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录