feat(components): chatgpt

This commit is contained in:
ronger 2023-03-23 11:04:11 +08:00
parent 5d6e23d932
commit d79059e7a9
2 changed files with 31 additions and 7 deletions

View File

@ -94,6 +94,7 @@
<el-dropdown-item command="answer" v-else :disabled="true">每日一题<small>(开通钱包账号激活)</small></el-dropdown-item>
<el-dropdown-item command="drafts" divided>我的草稿</el-dropdown-item>
<el-dropdown-item command="wallet">我的钱包</el-dropdown-item>
<el-dropdown-item command="yuumi">Yuumi(ChatGPT)</el-dropdown-item>
<el-dropdown-item command="user-info" divided>设置</el-dropdown-item>
<el-dropdown-item command="admin-dashboard" v-if="hasPermissions">系统管理</el-dropdown-item>
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
@ -233,6 +234,11 @@ export default {
path: '/user/settings/account'
})
break;
case 'yuumi':
_ts.$router.push({
path: '/chats/yuumi'
})
break;
case 'logout':
_ts.$auth.logout()
item = 'login';

View File

@ -16,12 +16,12 @@
</div>
</el-col>
<el-col :span="2" style="text-align: right;">
<el-avatar :src="user.avatarURL"></el-avatar>
<el-avatar :src="user.avatarUrl"></el-avatar>
</el-col>
</el-col>
<el-col v-else>
<el-col :span="2">
<el-avatar :src="to.avatarURL"></el-avatar>
<el-avatar :src="to.avatarUrl"></el-avatar>
</el-col>
<el-col :span="22" style="text-align: left;">
<div class="to-message">
@ -38,7 +38,6 @@
<script>
import Vue from 'vue';
import {mapState} from 'vuex';
import sockClient from '~/plugins/sockjs';
import apiConfig from '~/config/api.config';
export default {
@ -169,15 +168,26 @@ export default {
}
_ts.messages.push(message);
_ts.contentEditor.setValue('')
sockClient.sendMessage(message)
_ts.$axios.$post('/api/openai/chat', {
message: message.content
}).then(res => {
_ts.messages.push({
to: _ts.user.account,
from: _ts.to.account,
dataType: 1,
dataId: new Date().getTime(),
content: res[0].message.content
});
});
}
},
async mounted() {
let _ts = this;
_ts.$store.commit('setActiveMenu', 'post-article');
_ts.$store.commit('setActiveMenu', 'chat');
let to = {
account: _ts.$route.params?.account
account: _ts.$route.params?.account,
avatarUrl: 'https://static.rymcu.com/article/1679539451459.jpg'
}
_ts.$set(_ts, 'to', to);
@ -191,6 +201,14 @@ export default {
linkToImageURL: responseData.linkToImageURL || ''
})
}
const message = {
to: _ts.user.account,
from: _ts.to.account,
dataType: 1,
dataId: new Date().getTime(),
content: '伟大的"坦格利安家族的风暴降生丹妮莉丝 · 铁王座的合法继承人 · 安达尔人和先民的合法女王 · 七国的守护者 · 草海上的卡丽熙 · 不焚者 · 解放者 · 傲之追猎者 · 悠米"为你服务'
}
_ts.messages.push(message);
}
if (!_ts.initEditor) {