refactor: 重构存储管理Tab

This commit is contained in:
digua
2025-12-24 21:08:06 +08:00
parent de5172649e
commit 4cd5374ca3
5 changed files with 49 additions and 36 deletions
+14 -7
View File
@@ -2,7 +2,8 @@
import { ref, watch } from 'vue'
import AIConfigTab from './settings/AIConfigTab.vue'
import AIPromptConfigTab from './settings/AIPromptConfigTab.vue'
import CacheManageTab from './settings/CacheManageTab.vue'
import BasicSettingsTab from './settings/BasicSettingsTab.vue'
import StorageTab from './settings/StorageTab.vue'
import AboutTab from './settings/AboutTab.vue'
// Props
@@ -21,12 +22,13 @@ const tabs = [
{ id: 'settings', label: '基础设置', icon: 'i-heroicons-cog-6-tooth' },
{ id: 'ai-config', label: '模型配置', icon: 'i-heroicons-sparkles' },
{ id: 'ai-prompt', label: 'AI 对话配置', icon: 'i-heroicons-document-text' },
{ id: 'storage', label: '存储管理', icon: 'i-heroicons-folder-open' },
{ id: 'about', label: '关于', icon: 'i-heroicons-information-circle' },
]
const activeTab = ref('settings')
const aiConfigRef = ref<InstanceType<typeof AIConfigTab> | null>(null)
const cacheManageRef = ref<InstanceType<typeof CacheManageTab> | null>(null)
const storageTabRef = ref<InstanceType<typeof StorageTab> | null>(null)
// AI 配置变更回调
function handleAIConfigChanged() {
@@ -44,8 +46,8 @@ watch(
(newVal) => {
if (newVal) {
activeTab.value = 'settings' // 默认打开基础设置 Tab
// 刷新缓存管理
cacheManageRef.value?.refresh()
// 刷新存储管理(如果需要的话,或者在切换到 storage tab 时刷新)
storageTabRef.value?.refresh()
}
}
)
@@ -54,8 +56,8 @@ watch(
watch(
() => activeTab.value,
(newTab) => {
if (newTab === 'settings') {
cacheManageRef.value?.refresh()
if (newTab === 'storage') {
storageTabRef.value?.refresh()
}
}
)
@@ -105,7 +107,12 @@ watch(
<!-- 设置 Tab -->
<div v-show="activeTab === 'settings'">
<CacheManageTab ref="cacheManageRef" />
<BasicSettingsTab />
</div>
<!-- 存储管理 Tab -->
<div v-show="activeTab === 'storage'">
<StorageTab ref="storageTabRef" />
</div>
<!-- 关于 Tab -->
@@ -30,7 +30,7 @@ const globalMaxMessages = computed({
},
})
// 历史轮数限制
// AI上下文限制
const globalMaxHistoryRounds = computed({
get: () => aiGlobalSettings.value.maxHistoryRounds ?? 10,
set: (val: number) => {
@@ -106,18 +106,18 @@ function isActivePreset(presetId: string, chatType: 'group' | 'private'): boolea
<div class="flex-1 pr-4">
<p class="text-sm font-medium text-gray-900 dark:text-white">发送条数限制</p>
<p class="text-xs text-gray-500 dark:text-gray-400">
每次发送给 AI 的最大消息条数数值越大 Token 消耗越多
每次发送给 AI 的最大消息条数数值越大 Token 消耗越多回复也更准确
</p>
</div>
<UInput v-model.number="globalMaxMessages" type="number" min="1" max="5000" class="w-24" />
</div>
<!-- 历史轮数限制 -->
<!-- AI上下文限制 -->
<div class="flex items-center justify-between">
<div class="flex-1 pr-4">
<p class="text-sm font-medium text-gray-900 dark:text-white">历史轮数限制</p>
<p class="text-sm font-medium text-gray-900 dark:text-white">AI上下文限制</p>
<p class="text-xs text-gray-500 dark:text-gray-400">
保留最近的对话轮数1 = 用户提问 + AI回复防止上下文过长消耗 Token
每次对话保留最近的对话轮数1 = 用户提问 + AI回复防止上下文过长消耗 Token
</p>
</div>
<UInput v-model.number="globalMaxHistoryRounds" type="number" min="1" max="50" class="w-24" />
@@ -0,0 +1,29 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import { useLayoutStore } from '@/stores/layout'
// Store
const layoutStore = useLayoutStore()
const { screenshotMobileAdapt } = storeToRefs(layoutStore)
</script>
<template>
<div class="space-y-6">
<!-- 截图设置 -->
<div>
<h3 class="mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white">
<UIcon name="i-heroicons-camera" class="h-4 w-4 text-blue-500" />
截图设置
</h3>
<div class="rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50">
<div class="flex items-center justify-between">
<div class="flex-1 pr-4">
<p class="text-sm font-medium text-gray-900 dark:text-white">移动端适配</p>
<p class="text-xs text-gray-500 dark:text-gray-400">截图时自动缩放宽度适合移动端查看</p>
</div>
<USwitch v-model="screenshotMobileAdapt" />
</div>
</div>
</div>
</div>
</template>
@@ -1,11 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { storeToRefs } from 'pinia'
import { useLayoutStore } from '@/stores/layout'
// Store
const layoutStore = useLayoutStore()
const { screenshotMobileAdapt } = storeToRefs(layoutStore)
//
interface CacheDirectoryInfo {
@@ -193,23 +187,6 @@ defineExpose({
</div>
</div>
<!-- 截图设置 -->
<div>
<h3 class="mb-3 flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white">
<UIcon name="i-heroicons-camera" class="h-4 w-4 text-blue-500" />
截图设置
</h3>
<div class="rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/50">
<div class="flex items-center justify-between">
<div class="flex-1 pr-4">
<p class="text-sm font-medium text-gray-900 dark:text-white">移动端适配</p>
<p class="text-xs text-gray-500 dark:text-gray-400">截图时自动缩放宽度适合移动端查看</p>
</div>
<USwitch v-model="screenshotMobileAdapt" />
</div>
</div>
</div>
<!-- 提示信息 -->
<div class="rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-800/50 dark:bg-amber-900/20">
<div class="flex items-start gap-2">
+1 -1
View File
@@ -28,7 +28,7 @@ export const usePromptStore = defineStore(
const aiConfigVersion = ref(0)
const aiGlobalSettings = ref({
maxMessagesPerRequest: 200,
maxHistoryRounds: 5, // 历史对话轮数限制
maxHistoryRounds: 5, // AI上下文会话轮数限制
})
const customKeywordTemplates = ref<KeywordTemplate[]>([])
const deletedPresetTemplateIds = ref<string[]>([])