HistoryList.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="conversation-history-list-section">
  3. <div :class="container_klass">
  4. <HistoryItem
  5. v-for="(item, index) of list"
  6. :key="item.id"
  7. :history="item"
  8. :index="index"
  9. :agent_icon="agent_icon"
  10. @active="handleItemClick"
  11. @delete="handleItemDelete"
  12. />
  13. <HistoryLoadMore :can_loadmore="can_loadmore" @loadmore="handleLoadMore" />
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { computed } from 'vue';
  19. import HistoryItem from './HistoryItem.vue';
  20. import HistoryLoadMore from './HistoryLoadMore.vue';
  21. const props = defineProps({
  22. list: Array,
  23. // 是否可以加载更多
  24. can_loadmore: Boolean,
  25. agent_icon: String
  26. });
  27. const emit = defineEmits(['active', 'delete', 'loadmore']);
  28. const container_klass = computed(() => {
  29. return `conversation-history-list`;
  30. });
  31. /**
  32. * 点击事件
  33. * @param history_id - string
  34. */
  35. const handleItemClick = (history_id) => {
  36. emit('active', history_id);
  37. };
  38. /**
  39. * 删除某个记录
  40. * @param history_id
  41. */
  42. const handleItemDelete = (history_id) => {
  43. emit('delete', history_id);
  44. };
  45. const handleLoadMore = () => {
  46. emit('loadmore');
  47. };
  48. </script>
  49. <style lang="css" scoped>
  50. .conversation-history-list-section {
  51. margin-top: 20px;
  52. }
  53. .conversation-history-section-title {
  54. font-size: 20px;
  55. font-weight: bold;
  56. margin-top: 16px;
  57. margin-bottom: 16px;
  58. color: var(--color-text-1);
  59. }
  60. </style>