Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
令狐冲1
ChatGPT Template With Vue
提交
8e3a89c0
C
ChatGPT Template With Vue
项目概览
令狐冲1
/
ChatGPT Template With Vue
与 Fork 源项目一致
Fork自
inscode / ChatGPT Template With Vue
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ChatGPT Template With Vue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8e3a89c0
编写于
5月 15, 2023
作者:
6
64104061f23fda247c679fa8
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Mon May 15 08:55:00 UTC 2023 inscode
上级
e0d07cf1
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
105 addition
and
76 deletion
+105
-76
package.json
package.json
+1
-0
src/App.vue
src/App.vue
+104
-76
未找到文件。
package.json
浏览文件 @
8e3a89c0
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"
axios
"
:
"
^1.4.0
"
,
"
axios
"
:
"
^1.4.0
"
,
"
event-source-polyfill
"
:
"
^1.0.31
"
,
"
guess
"
:
"
^1.0.2
"
,
"
guess
"
:
"
^1.0.2
"
,
"
view-ui-plus
"
:
"
^1.3.9
"
,
"
view-ui-plus
"
:
"
^1.3.9
"
,
"
vue
"
:
"
^3.2.37
"
"
vue
"
:
"
^3.2.37
"
...
...
src/App.vue
浏览文件 @
8e3a89c0
...
@@ -8,12 +8,7 @@
...
@@ -8,12 +8,7 @@
</
template
>
</
template
>
</div>
</div>
<div
class=
"question ivu-mt"
>
<div
class=
"question ivu-mt"
>
<Input
<Input
v-model=
"question"
type=
"textarea"
:autosize=
"{ minRows: 4, maxRows: 6 }"
placeholder=
"输入你的问题"
/>
v-model=
"question"
type=
"textarea"
:autosize=
"{ minRows: 4, maxRows: 6 }"
placeholder=
"输入你的问题"
/>
<Row
class=
"ivu-mt"
>
<Row
class=
"ivu-mt"
>
<Col>
<Col>
<Button
type=
"primary"
size=
"large"
icon=
"md-send"
:loading=
"loading"
@
click=
"handleSend"
>
发送
</Button>
<Button
type=
"primary"
size=
"large"
icon=
"md-send"
:loading=
"loading"
@
click=
"handleSend"
>
发送
</Button>
...
@@ -26,13 +21,13 @@
...
@@ -26,13 +21,13 @@
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
axios
from
'
axios
'
;
import
{
EventSourcePolyfill
}
from
'
event-source-polyfill
'
;
const
token
=
'
Bearer ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjBkQ0k2TkN3aVlYVmtJam9pWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVWlMQ0pzZFNJNklrbHVjME52WkdVaUxDSmxlSEFpT2pFMk9EVTFORGczT1Rrc0luVnlJam95TENKcWRHa2lPaUpCVUVsZlZFOUxSVTVmWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVXROQ0o5LmlyLTJYa1A4dFhNaFVldnlzTFhkUlJsY1VBV0ZiaWE5em9ZdGN6VlpleFk=
'
;
const
token
=
'
Bearer ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjBkQ0k2TkN3aVlYVmtJam9pWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVWlMQ0pzZFNJNklrbHVjME52WkdVaUxDSmxlSEFpT2pFMk9EVTFORGczT1Rrc0luVnlJam95TENKcWRHa2lPaUpCVUVsZlZFOUxSVTVmWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVXROQ0o5LmlyLTJYa1A4dFhNaFVldnlzTFhkUlJsY1VBV0ZiaWE5em9ZdGN6VlpleFk=
'
;
const
api
=
'
https://api.ai100.ai/ai/api/ai/chat
'
;
const
api
=
'
https://api.ai100.ai/ai/api/ai/chat
'
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
question
:
''
,
question
:
''
,
loading
:
false
,
loading
:
false
,
...
@@ -40,7 +35,7 @@
...
@@ -40,7 +35,7 @@
}
}
},
},
methods
:
{
methods
:
{
handleSend
()
{
handleSend
()
{
if
(
this
.
loading
||
this
.
question
===
''
)
return
;
if
(
this
.
loading
||
this
.
question
===
''
)
return
;
this
.
loading
=
true
;
this
.
loading
=
true
;
...
@@ -48,16 +43,27 @@
...
@@ -48,16 +43,27 @@
this
.
question
=
''
;
this
.
question
=
''
;
this
.
dialogs
.
push
({
this
.
dialogs
.
push
({
id
:
this
.
dialogs
.
length
+
1
,
role
:
'
me
'
,
role
:
'
me
'
,
text
:
question
text
:
question
});
});
axios
.
post
(
api
,
const
aiDialogID
=
this
.
dialogs
.
length
+
1
;
{
this
.
dialogs
.
push
({
id
:
aiDialogID
,
role
:
'
ai
'
,
text
:
'
AI 思考中...
'
});
const
query
=
{
prompt
:
''
,
prompt
:
''
,
question
,
question
,
stream
:
false
stream
:
true
},
}
const
source
=
new
EventSourcePolyfill
(
`
${
api
}
?question=
${
query
.
question
}
&prompt=
${
query
.
prompt
}
&stream=
${
query
.
stream
}
`
,
{
{
headers
:
{
headers
:
{
Accept
:
'
*/*
'
,
Accept
:
'
*/*
'
,
...
@@ -65,46 +71,68 @@
...
@@ -65,46 +71,68 @@
}
}
}
}
)
)
.
then
(({
data
:
res
})
=>
{
console
.
log
(
res
);
source
.
onopen
=
event
=>
{
})
console
.
log
(
"
onopen
"
,
event
);
.
finally
(()
=>
{
const
dialog
=
this
.
dialogs
.
find
(
item
=>
item
.
id
===
aiDialogID
);
dialog
.
text
=
''
;
};
source
.
onmessage
=
event
=>
{
if
(
event
.
data
===
"
[DONE]
"
)
{
source
.
close
();
this
.
loading
=
false
;
this
.
loading
=
false
;
});
}
if
(
event
.
data
)
{
const
data
=
JSON
.
parse
(
event
.
data
);
const
text
=
data
.
message
.
content
.
parts
.
join
(
""
);
console
.
log
(
text
);
const
dialog
=
this
.
dialogs
.
find
(
item
=>
item
.
id
===
aiDialogID
);
dialog
.
text
+=
text
;
}
};
source
.
onerror
=
event
=>
{
console
.
log
(
"
error
"
,
event
);
};
},
},
handleNewChat
()
{
handleNewChat
()
{
this
.
dialogs
=
[];
this
.
dialogs
=
[];
}
}
}
}
}
}
</
script
>
</
script
>
<
style
>
<
style
>
.container
{
.container
{
height
:
100%
;
height
:
100%
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
}
}
.dialog
{
.dialog
{
flex
:
1
;
flex
:
1
;
overflow
:
auto
;
overflow
:
auto
;
}
}
.dialog-item
{
.dialog-item
{
display
:
flex
;
display
:
flex
;
}
}
.dialog-item-main
{
.dialog-item-main
{
max-width
:
80%
;
max-width
:
80%
;
padding
:
8px
;
padding
:
8px
;
word-wrap
:
break-word
;
word-wrap
:
break-word
;
margin-top
:
16px
;
margin-top
:
16px
;
border-radius
:
4px
;
border-radius
:
4px
;
}
}
.dialog-item-me
{
.dialog-item-me
{
justify-content
:
flex-end
;
justify-content
:
flex-end
;
}
}
.dialog-item-me
.dialog-item-main
{
.dialog-item-me
.dialog-item-main
{
background-color
:
antiquewhite
;
background-color
:
antiquewhite
;
}
}
.dialog-item-ai
.dialog-item-main
{
.dialog-item-ai
.dialog-item-main
{
background-color
:
#eee
;
background-color
:
#eee
;
}
}
</
style
>
</
style
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录