File size: 2,468 Bytes
a45f02e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
82
83
84
85
86
87
88
89
90
<template>

  <div id="home" class="flex size-full items-center justify-center dark:bg-black">

    <div class="mt-36 flex w-full flex-col gap-4 p-4 sm:-mt-28 lg:max-w-3xl xl:max-w-4xl">

      <div class="flex items-center justify-center gap-2">

        <img :src="logoUrl" class="w-10" />

        <span class="text-3xl font-bold dark:text-gray-100">AI Search</span>

      </div>

      <SearchInputBar :autofocus="true" :loading="false" @search="search" />

      <div class="my-2 flex flex-wrap items-center justify-center gap-4">

        <SearchMode />

        <SearCategory v-if="enableAdvanced" />

      </div>

      <div class="flex w-full justify-center">

        <div class="flex flex-wrap justify-center gap-2">

          <t-tag

            v-for="(item, index) in list"

            :key="index" shape="round" 

            variant="outline"

            size="medium"

            class="cursor-pointer hover:opacity-80"

            @click="onQuickSearch(item)"

          >

            {{ item }} <RiSearch2Line class="ml-1" size="12"/>

          </t-tag>

        </div>

      </div>

      <div class="mt-4">

        <PageFooter />

      </div>

    </div>

  </div>

</template>



<script setup lang="tsx">

import router from '../router';

import { RiSearch2Line } from '@remixicon/vue';

import { PageFooter, SearchInputBar, SearCategory, SearchMode } from '../components';

import logoUrl from '../assets/logo.png';

import { useI18n } from 'vue-i18n';

import { computed } from 'vue';

import { useAppStore } from '../store';



const { locale } = useI18n();

const appStore = useAppStore();



const enableAdvanced = computed(() => appStore.engine === 'SEARXNG');



const quickly: Record<string, string[]> = {

  zh: [

    '刘亦菲《玫瑰的故事》',

    '怎么使用Ollama在本地部署大模型?',

    'llama3-70b需要什么硬件配置?',

    '小米su7体验怎么样?',

    '《庆余年2》大结局'

  ],

  en: [

    'What is LLM?',

    'What is RAG?',

    'How to use LLM in enterprise?'

  ]

};



const list = computed(() => {

  const key = locale.value;

  return quickly[key];

});



const search = (val: string) => {

  if (!val) {

    return;

  }

  router.push({

    name: 'SearchPage',

    query: {

      q: val

    }

  });

};



const onQuickSearch = (val: string) => {

  search(val);

};

</script>



<script lang="tsx">

export default {

  name: 'HomePage'

};

</script>