File size: 2,937 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script setup lang="ts">
import { ModelSelect, SearchEngineSelect, LocalModelSelect, LocalProviderSelect, LanguageSelect } from './';
import { RiSunLine, RiMoonLine } from '@remixicon/vue';
import { useAppStore } from '../store';
import { type SwitchValue } from 'tdesign-vue-next';
import { useI18n } from 'vue-i18n';

const appStore = useAppStore();

const { t } = useI18n();

const showSettings = defineModel<boolean>();

const onChangeTheme = (val: SwitchValue) => {
  if (val) appStore.updateTheme('dark');
  else appStore.updateTheme('light');
};

const onEnableLocalModel = (val: SwitchValue) => {
  appStore.switchLocalModel(val as boolean);
};
</script>

<script lang="ts">
export default {
  name: 'AppSettings'
};
</script>

<template>
  <!-- eslint-disable-next-line vue/no-v-model-argument -->
  <t-drawer v-model:visible="showSettings" :footer="false" :header="t('settings')">
      <div class="flex h-full flex-col justify-between gap-4">
        <div class="w-full">
          <div class="flex w-full flex-col gap-2">
            <div class="">{{ t('selectModel') }}</div>
            <ModelSelect />
          </div>
          <div class="mt-2 flex w-full flex-col gap-2">
            <div class="">{{ t('selectEngine') }}</div>
            <SearchEngineSelect />
          </div>
          <t-divider>{{ t('localModel') }}</t-divider>
          <div class="mt-2 flex w-full flex-col gap-2">
            <div class="">{{ t('enableLocalModel') }}</div>
            <t-switch class="w-12" size="large" :default-value="appStore.enableLocal" @change="onEnableLocalModel">
              <template #label="slotProps">
                <template v-if="slotProps.value">
                  on
                </template>
                <template v-else>
                  off
                </template>
              </template>
            </t-switch>
          </div>
          <div class="mt-2 flex w-full flex-col gap-2">
            <div class="">{{ t('localProvider') }}</div>
            <LocalProviderSelect />
          </div>
          <div class="mt-2 flex w-full flex-col gap-2">
            <div class="">{{ t('localModel') }}</div>
            <LocalModelSelect />
          </div>
          <t-divider>{{ t('language') }}</t-divider>
          <div class="mt-2 flex w-full flex-col gap-2">
            <LanguageSelect />
          </div>
        </div>
        <div class="mb-4 flex flex-row gap-2">
          <span>{{ t('theme') }}: </span>
          <t-switch class="w-12" size="large" :default-value="appStore.theme === 'dark'" @change="onChangeTheme">
            <template #label="slotProps">
              <template v-if="slotProps.value">
                <RiMoonLine size="14" />
              </template>
              <template v-else>
                <RiSunLine size="14" />
              </template>
            </template>
          </t-switch>
        </div>
      </div>
    </t-drawer>
</template>