App.vue 1.7 KB
Newer Older
6
UPDATE  
64104061f23fda247c679fa8 已提交
1
<template>
6
update  
64104061f23fda247c679fa8 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  <div class="container ivu-p">
    <div class="dialog">
      <template v-for="(item, index) in dialogs" :key="index">
        <div class="dialog-item" :class="{ 'dialog-item-me': item.role === 'me', 'dialog-item-ai': item.role === 'ai' }">
          <div class="dialog-item-main">{{ item.text }}</div>
        </div>
      </template>
    </div>
    <div class="prompt ivu-mt">
      <Input
       v-model="prompt" 
       type="textarea" 
       :autosize="{ minRows: 4, maxRows: 6 }" 
       placeholder="输入你的问题" 
      />
      <Button class="ivu-mt" type="primary" size="large" :loading="loading" @click="handleSend">发送</Button>
    </div>
6
622eda98dfef6c4fdb84ccca 已提交
19
  </div>
6
UPDATE  
64104061f23fda247c679fa8 已提交
20
</template>
6
update  
64104061f23fda247c679fa8 已提交
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
<script>
  export default {
    data () {
      return {
        prompt: '',
        loading: false,
        dialogs: [
          {
            role: 'me',
            text: 'vscode 的'
          },
          {
            role: 'ai',
            text: 'dshjfjksdhfkjsdhkjfdsjkhfksdhdfjkjkdsfjkhsdkjfhsddshjfjksdhfkjsdhkjfdsjkhfksdhdfjkjkdsfjkhsdkjfhsddshjfjksdhfkjsdhkjfdsjkhfksdhdfjkjkdsfjkhsdkjfhsd'
          }
        ]
      }
    },
    methods: {
      handleSend () {
        if (this.loading) return;
        this.loading = true;
      }
    }
  }
6
622eda98dfef6c4fdb84ccca 已提交
46
</script>
6
update  
64104061f23fda247c679fa8 已提交
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
<style>
  .container{
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .dialog{
    flex: 1;
    overflow: auto;
  }
  .dialog-item{
    display: flex;
  }
  .dialog-item-main{
    max-width: 80%;
    padding: 8px;
    word-wrap: break-word;
    margin-top: 16px;
    border-radius: 4px;
  }
  .dialog-item-me{
    justify-content: flex-end;
  }
  .dialog-item-me .dialog-item-main{
    background-color: antiquewhite;
  }
  .dialog-item-ai .dialog-item-main{
    background-color: #eee;
  }
</style>