Compare commits

..

2 Commits

Author SHA1 Message Date
Rafi
002db29717 Improved the style of the chat window, using message bubbles. 2023-03-04 20:25:52 +08:00
Rafi
6402f156dd Add the try_files directive to the nginx configuration 2023-03-04 14:45:29 +08:00
6 changed files with 42 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
<p align="center">
<img alt="demo" src="./demos/demo.gif?v=1">
<img alt="demo" src="./demos/demo.png?v=1">
</p>
# ChatGPT UI

View File

@@ -20,6 +20,7 @@ const contentHtml = computed(() => {
<template>
<div
v-html="contentHtml"
class="text-body-1 text-justify"
></div>
</template>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

BIN
demos/demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

View File

@@ -6,6 +6,8 @@ server {
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api/

View File

@@ -3,6 +3,7 @@ definePageMeta({
middleware: ["auth"]
})
import {EventStreamContentType, fetchEventSource} from '@microsoft/fetch-event-source'
import { nextTick } from 'vue'
const { $i18n, $auth } = useNuxtApp()
const runtimeConfig = useRuntimeConfig()
@@ -49,7 +50,7 @@ const fetchReply = async (message, parentMessageId) => {
onerror(err) {
throw err;
},
onmessage(message) {
async onmessage(message) {
// console.log(message)
const event = message.event
const data = JSON.parse(message.data)
@@ -119,6 +120,7 @@ const showSnackbar = (text) => {
snackbar.value = true
}
</script>
<template>
@@ -126,21 +128,41 @@ const showSnackbar = (text) => {
v-if="currentConversation.messages.length > 0"
ref="chatWindow"
>
<v-card
rounded="0"
elevation="0"
v-for="(conversation, index) in currentConversation.messages"
:key="index"
:variant="conversation.is_bot ? 'tonal' : 'text'"
>
<v-container>
<v-card-text class="text-caption text-disabled">{{ $t(`roles.${conversation.is_bot?'ai':'me'}`) }}</v-card-text>
<v-card-text>
<MsgContent :content="conversation.message" />
</v-card-text>
</v-container>
<v-divider></v-divider>
</v-card>
<v-container>
<v-row>
<v-col
v-for="(message, index) in currentConversation.messages" :key="index"
cols="12"
>
<div
class="d-flex"
:class="message.is_bot ? 'justify-start mr-16' : 'justify-end ml-16'"
>
<v-card
:color="message.is_bot ? '' : 'primary'"
rounded="lg"
elevation="2"
>
<v-card-text>
<MsgContent :content="message.message" />
</v-card-text>
<!-- <v-card-actions-->
<!-- v-if="message.is_bot"-->
<!-- >-->
<!-- <v-spacer></v-spacer>-->
<!-- <v-tooltip text="Copy">-->
<!-- <template v-slot:activator="{ props }">-->
<!-- <v-btn v-bind="props" icon="content_copy"></v-btn>-->
<!-- </template>-->
<!-- </v-tooltip>-->
<!-- </v-card-actions>-->
</v-card>
</div>
</v-col>
</v-row>
</v-container>
<div ref="grab" class="w-100" style="height: 200px;"></div>
</div>
<Welcome v-else />