update hub
This commit is contained in:
1 parent
731a219527
commit
2e7d636f0f
9 files changed
+109
-379
No files matched your search
@@ -64,12 +64,21 @@ import { defineComponent } from 'vue';
|
|||||||
import { ElSkeleton, ElInput } from 'element-plus';
|
import { ElSkeleton, ElInput } from 'element-plus';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
import { ROUTE_CHAT_CONVERSATION } from '@/router/constants';
|
import { ROUTE_CHAT_CONVERSATION } from '@/router/constants';
|
||||||
import { apiUsageOperator, IApplication, chatOperator } from '@/operators';
|
import { apiUsageOperator, IApplication, chatOperator, applicationOperator } from '@/operators';
|
||||||
import { IChatConversation } from '@/operators/chat/models';
|
import { IChatConversation } from '@/operators/chat/models';
|
||||||
|
import {
|
||||||
|
CHAT_MODEL_CHATGPT,
|
||||||
|
CHAT_MODEL_CHATGPT4,
|
||||||
|
CHAT_MODEL_CHATGPT4_BROWSING,
|
||||||
|
CHAT_MODEL_CHATGPT_16K,
|
||||||
|
CHAT_MODEL_CHATGPT_BROWSING
|
||||||
|
} from '@/operators';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
|
initializing: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
conversations: IChatConversation[] | undefined;
|
conversations: IChatConversation[] | undefined;
|
||||||
|
applications: IApplication[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -79,45 +88,61 @@ export default defineComponent({
|
|||||||
FontAwesomeIcon,
|
FontAwesomeIcon,
|
||||||
ElSkeleton
|
ElSkeleton
|
||||||
},
|
},
|
||||||
props: {
|
props: {},
|
||||||
applications: {
|
|
||||||
type: Object as () => IApplication[],
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
emits: ['click'],
|
emits: ['click'],
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
|
initializing: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
conversations: undefined
|
conversations: undefined,
|
||||||
|
applications: undefined
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
applications(val) {
|
applications(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.onFetchAllConversations();
|
this.onFetchConversations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {},
|
async mounted() {
|
||||||
|
await this.onFetchApplications();
|
||||||
|
await this.onFetchConversations();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async onFetchApplications() {
|
||||||
|
this.initializing = true;
|
||||||
|
const { data: applications } = await applicationOperator.getAll({
|
||||||
|
user_id: this.$store.state.user.id,
|
||||||
|
api_id: [
|
||||||
|
CHAT_MODEL_CHATGPT.apiId,
|
||||||
|
CHAT_MODEL_CHATGPT_16K.apiId,
|
||||||
|
CHAT_MODEL_CHATGPT_BROWSING.apiId,
|
||||||
|
CHAT_MODEL_CHATGPT4.apiId,
|
||||||
|
CHAT_MODEL_CHATGPT4_BROWSING.apiId
|
||||||
|
]
|
||||||
|
});
|
||||||
|
this.initializing = false;
|
||||||
|
this.applications = applications?.items;
|
||||||
|
},
|
||||||
async onConfirm(conversation: IChatConversation) {
|
async onConfirm(conversation: IChatConversation) {
|
||||||
if (conversation?.deleting) {
|
if (conversation?.deleting) {
|
||||||
await chatOperator.deleteConversation(conversation.id);
|
await chatOperator.deleteConversation(conversation.id);
|
||||||
await this.onFetchAllConversations();
|
await this.onFetchConversations();
|
||||||
} else if (conversation?.editing) {
|
} else if (conversation?.editing) {
|
||||||
await chatOperator.updateConversation(conversation);
|
await chatOperator.updateConversation(conversation);
|
||||||
this.onFetchAllConversations();
|
this.onFetchConversations();
|
||||||
} else {
|
} else {
|
||||||
conversation.editing = true;
|
conversation.editing = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onFetchAllConversations() {
|
async onFetchConversations() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const {
|
const {
|
||||||
data: { items: apiUsages }
|
data: { items: apiUsages }
|
||||||
} = await apiUsageOperator.getAll({
|
} = await apiUsageOperator.getAll({
|
||||||
user_id: this.$store.state.user.id,
|
user_id: this.$store.state.user.id,
|
||||||
|
// @ts-ignore
|
||||||
application_id: this.applications?.map((application) => application.id),
|
application_id: this.applications?.map((application) => application.id),
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 30,
|
limit: 30,
|
||||||
|
|||||||
@@ -1,116 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="navigator">
|
|
||||||
<div class="conversations">
|
|
||||||
<navigator-item icon="fa-solid fa-plus" :title="$t('common.nav.newChat')" @click="onNewConversation" />
|
|
||||||
<conversation-navigator-item
|
|
||||||
v-for="(conversation, conversationIndex) in conversations"
|
|
||||||
:key="conversationIndex"
|
|
||||||
:title="conversation.title"
|
|
||||||
icon="fa-regular fa-comment"
|
|
||||||
@update:title="onUpdateTitle(conversation, $event)"
|
|
||||||
@delete="onDeleteConversation(conversation.id)"
|
|
||||||
@click="onSelectConversation(conversation.id)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="operators">
|
|
||||||
<navigator-item icon="fa-solid fa-gear" :title="$t('common.nav.setting')" @click="setting = true" />
|
|
||||||
<setting-panel :visible="setting" @close="setting = false" />
|
|
||||||
<navigator-item
|
|
||||||
v-show="!confirming"
|
|
||||||
icon="fa-solid fa-trash"
|
|
||||||
:title="$t('common.nav.clearConversations')"
|
|
||||||
@click="confirming = true"
|
|
||||||
/>
|
|
||||||
<navigator-item
|
|
||||||
v-show="confirming"
|
|
||||||
icon="fa-solid fa-check"
|
|
||||||
:title="$t('common.nav.confirmClearConversations')"
|
|
||||||
@click="onClearConversations"
|
|
||||||
/>
|
|
||||||
<navigator-item icon="fa-solid fa-arrow-right-from-bracket" :title="$t('common.nav.logOut')" @click="onLogout" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { ROUTE_CONVERSATION_DETAIL, ROUTE_CONVERSATION_NEW } from '@/router';
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import NavigatorItem from './NavigatorItem.vue';
|
|
||||||
import ConversationNavigatorItem from '../conversation/ConversationNavigatorItem.vue';
|
|
||||||
import { IConversation } from '@/operators/conversation/models';
|
|
||||||
import SettingPanel from './SettingPanel.vue';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'LeftNavigator',
|
|
||||||
components: {
|
|
||||||
NavigatorItem,
|
|
||||||
ConversationNavigatorItem,
|
|
||||||
SettingPanel
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
confirming: false,
|
|
||||||
setting: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
conversations() {
|
|
||||||
return this.$store.getters.conversations;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onNewConversation() {
|
|
||||||
this.$router.push({
|
|
||||||
name: ROUTE_CONVERSATION_NEW
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onClearConversations() {
|
|
||||||
this.$store.dispatch('setConversations', []);
|
|
||||||
this.confirming = false;
|
|
||||||
this.onNewConversation();
|
|
||||||
},
|
|
||||||
onSelectConversation(id: string) {
|
|
||||||
this.$router.push({
|
|
||||||
name: ROUTE_CONVERSATION_DETAIL,
|
|
||||||
params: {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onLogout() {
|
|
||||||
this.$store.dispatch('resetAuth');
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 1000);
|
|
||||||
},
|
|
||||||
onUpdateTitle(conversation: IConversation, val: string) {
|
|
||||||
conversation.title = val;
|
|
||||||
this.$store.dispatch('setConversations', this.conversations);
|
|
||||||
},
|
|
||||||
onDeleteConversation(id: string) {
|
|
||||||
const newConversations = this.conversations.filter((i: IConversation) => i.id !== id);
|
|
||||||
this.$store.dispatch('setConversations', newConversations);
|
|
||||||
this.onNewConversation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.navigator {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background-color: #202123;
|
|
||||||
color: white;
|
|
||||||
height: 100%;
|
|
||||||
padding: 15px 5px;
|
|
||||||
font-size: 14px;
|
|
||||||
.conversations {
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
.operators {
|
|
||||||
height: fit-content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="navigation-item">
|
|
||||||
<div class="icon">
|
|
||||||
<font-awesome-icon :icon="icon" class="icon-rotate" />
|
|
||||||
</div>
|
|
||||||
<div class="title">
|
|
||||||
{{ title }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'NavigatorItem',
|
|
||||||
components: {
|
|
||||||
FontAwesomeIcon
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
icon: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.navigation-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
cursor: pointer;
|
|
||||||
height: 44px;
|
|
||||||
margin-top: 5px;
|
|
||||||
padding: 0 15px;
|
|
||||||
line-height: 44px;
|
|
||||||
border-radius: 3px;
|
|
||||||
&:hover {
|
|
||||||
background-color: hsla(240, 9%, 59%, 0.1);
|
|
||||||
}
|
|
||||||
.icon {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
min-width: 30px;
|
|
||||||
}
|
|
||||||
.title {
|
|
||||||
flex: 1;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<template>
|
||||||
|
<div class="wrapper">
|
||||||
|
<div class="left">
|
||||||
|
<navigator />
|
||||||
|
</div>
|
||||||
|
<div class="main">
|
||||||
|
<sidebar class="sidebar" />
|
||||||
|
<router-view />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import Navigator from '@/components/common/Navigator.vue';
|
||||||
|
import Sidebar from '@/components/chat/Sidebar.vue';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'LayoutChat',
|
||||||
|
components: {
|
||||||
|
Sidebar,
|
||||||
|
Navigator
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.wrapper {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
.left {
|
||||||
|
width: 60px;
|
||||||
|
height: 100%;
|
||||||
|
border-right: 1px solid var(--el-border-color);
|
||||||
|
}
|
||||||
|
.main {
|
||||||
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
display: block;
|
||||||
|
width: 300px;
|
||||||
|
height: 100%;
|
||||||
|
border-right: 1px solid #eee;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<el-aside class="aside">
|
|
||||||
<left-navigator />
|
|
||||||
</el-aside>
|
|
||||||
<el-main class="main"> <router-view /> </el-main>
|
|
||||||
<el-button round class="menu" @click="drawer = true">
|
|
||||||
<font-awesome-icon icon="fa-solid fa-bars" class="icon-menu" />
|
|
||||||
</el-button>
|
|
||||||
<el-drawer v-model="drawer" :with-header="false" size="50%" class="drawer">
|
|
||||||
<left-navigator />
|
|
||||||
</el-drawer>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
import { ElMain, ElAside, ElButton, ElDrawer } from 'element-plus';
|
|
||||||
import LeftNavigator from '@/components/common/LeftNavigator.vue';
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'LayoutConversation',
|
|
||||||
components: {
|
|
||||||
ElMain,
|
|
||||||
ElAside,
|
|
||||||
ElDrawer,
|
|
||||||
ElButton,
|
|
||||||
LeftNavigator,
|
|
||||||
FontAwesomeIcon
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
drawer: false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.drawer {
|
|
||||||
.el-drawer__body {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
height: 100vh;
|
|
||||||
width: 100%;
|
|
||||||
max-width: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
$width: 300px;
|
|
||||||
.aside {
|
|
||||||
width: $width;
|
|
||||||
height: 100%;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main {
|
|
||||||
width: calc(100% - $width);
|
|
||||||
background-color: #f3f5f6;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
|
||||||
.container {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.aside {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: block;
|
|
||||||
background: white;
|
|
||||||
padding: 15px;
|
|
||||||
padding-top: 50px;
|
|
||||||
height: fit-content;
|
|
||||||
overflow: hidden;
|
|
||||||
.logo {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.main {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu {
|
|
||||||
display: block;
|
|
||||||
position: fixed;
|
|
||||||
right: 20px;
|
|
||||||
top: 10px;
|
|
||||||
z-index: 2000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<sidebar class="left" :applications="applications" @click="onFetchHistory" />
|
|
||||||
<div class="main">
|
|
||||||
<model-selector v-model="model" class="model-selector" @select="onSelectModel" />
|
<model-selector v-model="model" class="model-selector" @select="onSelectModel" />
|
||||||
<api-status
|
<api-status
|
||||||
:initializing="initializing"
|
:initializing="initializing"
|
||||||
@@ -19,7 +17,6 @@
|
|||||||
<input-box v-model="question" @submit="onSubmitQuestion" />
|
<input-box v-model="question" @submit="onSubmitQuestion" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -47,12 +44,11 @@ import ModelSelector from '@/components/chat/ModelSelector.vue';
|
|||||||
import { ERROR_CODE_CANCELED, ERROR_CODE_UNKNOWN } from '@/constants/errorCode';
|
import { ERROR_CODE_CANCELED, ERROR_CODE_UNKNOWN } from '@/constants/errorCode';
|
||||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
|
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
|
||||||
import Sidebar from '@/components/chat/Sidebar.vue';
|
|
||||||
|
|
||||||
export interface IData {
|
export interface IData {
|
||||||
messages: IChatMessage[];
|
messages: IChatMessage[];
|
||||||
model: IChatModel;
|
model: IChatModel;
|
||||||
applications: IApplication[];
|
applications: IApplication[] | undefined;
|
||||||
question: '';
|
question: '';
|
||||||
initializing: boolean;
|
initializing: boolean;
|
||||||
applied: boolean | undefined;
|
applied: boolean | undefined;
|
||||||
@@ -64,8 +60,7 @@ export default defineComponent({
|
|||||||
InputBox,
|
InputBox,
|
||||||
ModelSelector,
|
ModelSelector,
|
||||||
Message,
|
Message,
|
||||||
ApiStatus,
|
ApiStatus
|
||||||
Sidebar
|
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
@@ -73,7 +68,7 @@ export default defineComponent({
|
|||||||
question: '',
|
question: '',
|
||||||
initializing: false,
|
initializing: false,
|
||||||
applied: undefined,
|
applied: undefined,
|
||||||
applications: [],
|
applications: undefined,
|
||||||
messages: []
|
messages: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -82,11 +77,17 @@ export default defineComponent({
|
|||||||
return this.$route.params.id?.toString();
|
return this.$route.params.id?.toString();
|
||||||
},
|
},
|
||||||
application() {
|
application() {
|
||||||
return this.applications.find((application) => application.api?.id === this.model.apiId);
|
return this.applications?.find((application) => application.api?.id === this.model.apiId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
conversationId(val) {
|
||||||
|
if (val) {
|
||||||
|
this.onFetchHistory(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
console.log('mounted');
|
|
||||||
await this.onFetchApplications();
|
await this.onFetchApplications();
|
||||||
await this.onFetchHistory();
|
await this.onFetchHistory();
|
||||||
},
|
},
|
||||||
@@ -203,21 +204,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page {
|
.page {
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
.left {
|
|
||||||
display: block;
|
|
||||||
width: 300px;
|
|
||||||
height: 100%;
|
|
||||||
border-right: 1px solid #eee;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main {
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
@@ -243,7 +229,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.bottom {
|
.bottom {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
|
|||||||
@@ -1,73 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<sidebar class="left" :applications="applications" />
|
|
||||||
<div class="main">
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="title">{{ $t('chat.title.chat') }}</h2>
|
<h2 class="title">{{ $t('chat.title.chat') }}</h2>
|
||||||
<p class="description">{{ $t('chat.message.startNewChat') }}</p>
|
<p class="description">{{ $t('chat.message.startNewChat') }}</p>
|
||||||
<el-button type="primary" @click="onStart">{{ $t('common.button.new') }}</el-button>
|
<el-button type="primary" @click="onStart">{{ $t('common.button.new') }}</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { ElButton } from 'element-plus';
|
import { ElButton } from 'element-plus';
|
||||||
import Sidebar from '@/components/chat/Sidebar.vue';
|
|
||||||
import { ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
import { ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
|
||||||
import { IApplication } from '@/operators/application/models';
|
|
||||||
import { applicationOperator } from '@/operators/application/operator';
|
|
||||||
import {
|
|
||||||
CHAT_MODEL_CHATGPT,
|
|
||||||
CHAT_MODEL_CHATGPT4,
|
|
||||||
CHAT_MODEL_CHATGPT4_BROWSING,
|
|
||||||
CHAT_MODEL_CHATGPT_16K,
|
|
||||||
CHAT_MODEL_CHATGPT_BROWSING
|
|
||||||
} from '@/operators/chat/constants';
|
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
model: string;
|
model: string;
|
||||||
drawer: boolean;
|
|
||||||
question: string;
|
question: string;
|
||||||
initializing: boolean;
|
|
||||||
applications: IApplication[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ChatIndex',
|
name: 'ChatIndex',
|
||||||
components: {
|
components: {
|
||||||
Sidebar,
|
|
||||||
ElButton
|
ElButton
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
model: 'chatgpt',
|
model: 'chatgpt',
|
||||||
initializing: false,
|
question: ''
|
||||||
drawer: false,
|
|
||||||
question: '',
|
|
||||||
applications: []
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.onFetchApplications();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async onFetchApplications() {
|
|
||||||
this.initializing = true;
|
|
||||||
const { data: applications } = await applicationOperator.getAll({
|
|
||||||
user_id: this.$store.state.user.id,
|
|
||||||
api_id: [
|
|
||||||
CHAT_MODEL_CHATGPT.apiId,
|
|
||||||
CHAT_MODEL_CHATGPT_16K.apiId,
|
|
||||||
CHAT_MODEL_CHATGPT_BROWSING.apiId,
|
|
||||||
CHAT_MODEL_CHATGPT4.apiId,
|
|
||||||
CHAT_MODEL_CHATGPT4_BROWSING.apiId
|
|
||||||
]
|
|
||||||
});
|
|
||||||
this.initializing = false;
|
|
||||||
this.applications = applications?.items;
|
|
||||||
},
|
|
||||||
onStart() {
|
onStart() {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: ROUTE_CHAT_CONVERSATION_NEW
|
name: ROUTE_CHAT_CONVERSATION_NEW
|
||||||
@@ -79,17 +41,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page {
|
.page {
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
.left {
|
|
||||||
display: block;
|
|
||||||
width: 300px;
|
|
||||||
height: 100%;
|
|
||||||
border-right: 1px solid #eee;
|
|
||||||
}
|
|
||||||
.main {
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -116,6 +67,5 @@ export default defineComponent({
|
|||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
+1
-1
@@ -2,7 +2,7 @@ import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW, ROUTE_CHAT_INDEX
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
path: '/chat',
|
path: '/chat',
|
||||||
component: () => import('@/layouts/Main.vue'),
|
component: () => import('@/layouts/Chat.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
|
|||||||
+4
-2
@@ -37,6 +37,9 @@ const store = createStore({
|
|||||||
...payload
|
...payload
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
resetToken(state: IState): void {
|
||||||
|
state.token = {};
|
||||||
|
},
|
||||||
setSetting(state: IState, payload: ISetting): void {
|
setSetting(state: IState, payload: ISetting): void {
|
||||||
state.setting = {
|
state.setting = {
|
||||||
...state.setting,
|
...state.setting,
|
||||||
@@ -61,8 +64,7 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
resetToken({ commit }) {
|
resetToken({ commit }) {
|
||||||
commit('setToken', {});
|
commit('resetToken');
|
||||||
removeCookies();
|
|
||||||
},
|
},
|
||||||
setUser({ commit }: ActionContext<IState, IState>, payload: IUser) {
|
setUser({ commit }: ActionContext<IState, IState>, payload: IUser) {
|
||||||
commit('setUser', payload);
|
commit('setUser', payload);
|
||||||
|
|||||||
Reference in new issue
Block a user