Skip to content

Commit

Permalink
update index
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Oct 3, 2023
1 parent 91c7417 commit 457945a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 40 deletions.
41 changes: 28 additions & 13 deletions src/components/chat/Message.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<template>
<div :class="'message ' + message.role">
<div :class="'message ' + message.role" :role="message.role">
<div class="content">
<markdown-renderer :content="message?.content" />
<answering-mark v-if="message.state === messageState.PENDING" />
</div>
<div class="operations">
<copy-to-clipboard :content="message.content" class="btn-copy" />
</div>
</div>
</template>

Expand All @@ -17,7 +20,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import copy from 'copy-to-clipboard';
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
import { IChatMessage, IChatMessageState } from '@/operators';
import CopyToClipboard from '../common/CopyToClipboard.vue';
interface IData {
copied: boolean;
messageState: typeof IChatMessageState;
Expand All @@ -28,8 +31,9 @@ export default defineComponent({
components: {
// MessageContent,
// ElImage,
// ElButton,
// FontAwesomeIcon
ElButton,
CopyToClipboard,
// FontAwesomeIcon,
AnsweringMark,
MarkdownRenderer
},
Expand All @@ -52,15 +56,15 @@ export default defineComponent({
// }
},
methods: {
// onCopy() {
// copy(this.content.value, {
// debug: true
// });
// this.copied = true;
// setTimeout(() => {
// this.copied = false;
// }, 3000);
// },
onCopy() {
copy(this.message.content, {
debug: true
});
this.copied = true;
setTimeout(() => {
this.copied = false;
}, 3000);
}
// onStop() {
// this.$emit('stop');
// }
Expand All @@ -72,6 +76,9 @@ export default defineComponent({
.message {
display: flex;
flex-direction: column;
&[role='system'] {
display: none;
}
&.assistant {
align-items: start;
.content {
Expand All @@ -94,5 +101,13 @@ export default defineComponent({
max-width: 800px;
// background-color: aqua;
}
.operations {
display: block;
.btn-copy {
color: var(--el-text-color-regular);
font-size: 14px;
}
}
}
</style>
1 change: 1 addition & 0 deletions src/components/common/CopyToClipboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export default defineComponent({
.icon-copy {
margin-left: 5px;
cursor: pointer;
color: inherit;
}
</style>
29 changes: 2 additions & 27 deletions src/pages/chat/Index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<template>
<div class="page">
<div class="left">3</div>
<div class="main">
<model-selector v-model="model" class="model-selector" />
<introduction />
<input-box v-model="question" class="input-box" />
</div>
</div>
<div class="page"></div>
</template>

<script lang="ts">
Expand All @@ -19,11 +12,7 @@ import InputBox from '@/components/chat/InputBox.vue';
import ModelSelector from '@/components/chat/ModelSelector.vue';
export default defineComponent({
name: 'ChatIndex',
components: {
Introduction,
InputBox,
ModelSelector
},
components: {},
data() {
return {
model: 'chatgpt',
Expand All @@ -49,20 +38,6 @@ export default defineComponent({
flex: 1;
overflow: hidden;
position: relative;
.input-box {
display: block;
position: absolute;
bottom: 10px;
right: 10px;
left: 10px;
}
.model-selector {
position: absolute;
top: 30px;
left: 50%;
transform: translate(-50%, 0);
z-index: 100;
}
}
}
</style>

0 comments on commit 457945a

Please sign in to comment.