feat(components): chatgpt
feat(components): chatgpt
This commit is contained in:
commit
1db04fade9
@ -94,6 +94,7 @@
|
|||||||
<el-dropdown-item command="answer" v-else :disabled="true">每日一题<small>(开通钱包账号激活)</small></el-dropdown-item>
|
<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="drafts" divided>我的草稿</el-dropdown-item>
|
||||||
<el-dropdown-item command="wallet">我的钱包</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="user-info" divided>设置</el-dropdown-item>
|
||||||
<el-dropdown-item command="admin-dashboard" v-if="hasPermissions">系统管理</el-dropdown-item>
|
<el-dropdown-item command="admin-dashboard" v-if="hasPermissions">系统管理</el-dropdown-item>
|
||||||
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
|
<el-dropdown-item command="logout" divided>退出登录</el-dropdown-item>
|
||||||
@ -233,6 +234,11 @@ export default {
|
|||||||
path: '/user/settings/account'
|
path: '/user/settings/account'
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
|
case 'yuumi':
|
||||||
|
_ts.$router.push({
|
||||||
|
path: '/chats/yuumi'
|
||||||
|
})
|
||||||
|
break;
|
||||||
case 'logout':
|
case 'logout':
|
||||||
_ts.$auth.logout()
|
_ts.$auth.logout()
|
||||||
item = 'login';
|
item = 'login';
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="2" style="text-align: right;">
|
<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>
|
</el-col>
|
||||||
<el-col v-else>
|
<el-col v-else>
|
||||||
<el-col :span="2">
|
<el-col :span="2">
|
||||||
<el-avatar :src="to.avatarURL"></el-avatar>
|
<el-avatar :src="to.avatarUrl"></el-avatar>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="22" style="text-align: left;">
|
<el-col :span="22" style="text-align: left;">
|
||||||
<div class="to-message">
|
<div class="to-message">
|
||||||
@ -38,7 +38,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
import sockClient from '~/plugins/sockjs';
|
|
||||||
import apiConfig from '~/config/api.config';
|
import apiConfig from '~/config/api.config';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -169,15 +168,26 @@ export default {
|
|||||||
}
|
}
|
||||||
_ts.messages.push(message);
|
_ts.messages.push(message);
|
||||||
_ts.contentEditor.setValue('')
|
_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() {
|
async mounted() {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
_ts.$store.commit('setActiveMenu', 'post-article');
|
_ts.$store.commit('setActiveMenu', 'chat');
|
||||||
|
|
||||||
let to = {
|
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);
|
_ts.$set(_ts, 'to', to);
|
||||||
@ -191,6 +201,14 @@ export default {
|
|||||||
linkToImageURL: responseData.linkToImageURL || ''
|
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) {
|
if (!_ts.initEditor) {
|
||||||
@ -211,7 +229,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@import "~vditor/src/assets/less/index.less";
|
@import "~vditor/src/assets/less/index.less";
|
||||||
|
|
||||||
.from-message {
|
.from-message {
|
||||||
float: right;
|
float: right;
|
||||||
|
Loading…
Reference in New Issue
Block a user