This commit is contained in:
AceDataCloud committed 2023-04-11 02:02:57 +08:00
1 parent c38d6ba67c
commit 62ec02e6c9
9 files changed
+202 -483

No files matched your search

+40 -2
View File
@@ -3,6 +3,12 @@
<el-image :src="author.avatar" class="icon" />
<message-content :content="content" class="content" :error="error" :state="state" />
</div>
<div class="operations">
<el-button v-if="author.type === 'bot' && content.value" class="operation" size="small" @click="onCopy">
<font-awesome-icon icon="fa-regular fa-copy" class="icon-copy" />
{{ $t('common.button.copy') }}
</el-button>
</div>
</template>
<script lang="ts">
@@ -10,13 +16,21 @@ import { IBot, IUser } from '@/operators';
import { IContent, IError, IMessageState } from '@/operators/message/models';
import { defineComponent } from 'vue';
import MessageContent from './MessageContent.vue';
import { ElImage } from 'element-plus';
import { ElImage, ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import copy from 'copy-to-clipboard';
interface IData {
copied: boolean;
}
export default defineComponent({
name: 'Message',
components: {
MessageContent,
ElImage
ElImage,
ElButton,
FontAwesomeIcon
},
props: {
content: {
@@ -42,10 +56,26 @@ export default defineComponent({
}
}
},
data(): IData {
return {
copied: false
};
},
computed: {
conversationId() {
return this.$route.params?.id?.toString();
}
},
methods: {
onCopy() {
copy(this.content.value, {
debug: true
});
this.copied = true;
setTimeout(() => {
this.copied = false;
}, 3000);
}
}
});
</script>
@@ -65,4 +95,12 @@ export default defineComponent({
flex: 1;
}
}
.operations {
width: fit-content;
margin: auto;
.fa-copy {
margin-right: 5px;
}
}
</style>
@@ -21,7 +21,9 @@ import {
ERROR_CODE_BUSY,
ERROR_CODE_BAD_REQUEST,
ERROR_CODE_NO_CONVERSATION,
ERROR_CODE_USED_UP
ERROR_CODE_USED_UP,
ERROR_CODE_UNKNOWN,
ERROR_CODE_TIMEOUT
} from '@/constants';
import AnsweringMark from './AnsweringMark.vue';
@@ -81,6 +83,12 @@ export default defineComponent({
if (this.error?.code === ERROR_CODE_NO_CONVERSATION) {
return this.$t('conversation.message.errorNoConversation');
}
if (this.error?.code === ERROR_CODE_UNKNOWN) {
return this.$t('conversation.message.errorUnknown');
}
if (this.error?.code === ERROR_CODE_TIMEOUT) {
return this.$t('conversation.message.errorTimeout');
}
return undefined;
}
},