msg-row.vue 1.8 KB
Newer Older
6
628c9f991a7e4862742d8a2f 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<template>
  <div class="msg">
    <div class="msg-ctx">
        <div class="msg-ctx-user" :class="{ 'msg-ctx-user__role': data.role === 'user' }">
            <template v-if="data.role === 'user'">

            </template>
            <img v-else src="../assets/ChatGPT.svg" alt="">
        </div>
        <div class="msg-ctx-msg">
            <template v-if="data.loading">
                loading
            </template>
            <template v-else>
                <vue-markdown-it :source="data.content"/>
            </template>
        </div>
    </div>
  </div>
</template>

<script>
import VueMarkdownIt from 'vue3-markdown-it'
import 'highlight.js/styles/a11y-dark.css'

export default {
    components: {
        VueMarkdownIt
    },
    props: {
        data: {
            type: Object,
            default: () => {
                return {
                    loading: true
                }
            }
        }
    }
}
</script>

<style lang="less">
.msg {
    width: 100%;
    &-ctx {
        box-sizing: border-box;
        padding: 24px;
        display: flex;
        max-width: 760px;
        margin: 0 auto;
        &-user {
            display: flex;
            color: #FFF;
            align-items: center;
            justify-content: center;
            background: #F73048;
            border-radius: 3px;
            width: 36px;
            height: 36px;
            & > img {
                width: 24px;
                height: 24px;
            }
        }
        &-user__role {
            background: #507999;
        }
        &-msg {
            margin: 0 0 0 20px;
            flex: 1;
            color: #FFF;
            font-size: 16px;
            line-height: 32px;
        }
    }
}
.msg:nth-child(even) {
    background: rgba(70, 72, 84, 1);
}
</style>