File size: 2,411 Bytes
755dd12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<script lang="ts">
export default {
  name: 'ChatSources'
};
</script>

<script setup lang="ts">
import { useI18n } from 'vue-i18n';

interface IProps {
  sources?: Record<string, any>[]
  loading: boolean
}
defineProps<IProps>();
const rowCol = [
  [
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
  ],
  [
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
  ],
  [
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
    { width: '32%', height: '42px', borderRadius: '6px' },
  ]
];
const { t } = useI18n();
</script>

<template>
  <div class="w-full">
    <t-skeleton :row-col="rowCol" animation="flashed" :loading="!sources?.length && loading"></t-skeleton>
    <div v-if="sources?.length === 0 && !loading" class="">
      <t-alert theme="info" :message="t('message.sourceError')" close>
        <template #operation>
        </template>
      </t-alert>
    </div>
    <div class="mt-4 grid grid-cols-1 gap-2 text-xs text-gray-500 md:grid-cols-2">
      <div 
        v-for="item in sources"
        :key="item.id"
        class="relative overflow-hidden rounded-md bg-gray-100 p-2 transition-all hover:opacity-80 xl:p-3 dark:bg-zinc-800"
      >
        <t-popup>
          <template #content>
            <div class="flex w-80 flex-col gap-2 p-2">
              <div class="text-lg font-bold leading-7">{{ item.name }}</div>
              <div class="leading-6 text-zinc-400">{{ item.snippet }}</div>
              <a :href="item.url" target="_blank" class="block size-full truncate text-zinc-400">{{ item.url }}</a>
            </div>
          </template>
          <div class="leading-5">
            <a :href="item.url" target="_blank" class="absolute block size-full"></a>
            <div class="truncate break-words text-sm text-black dark:text-gray-400">{{ item.name }}</div>
            <div class="mt-1 flex items-center gap-1">
              <t-tag size="small" theme="default">{{ item.id }}</t-tag>
              <div class="truncate break-words">{{ item.url }}</div>
            </div>
          </div>
        </t-popup>
      </div>
    </div>
  </div>
</template>