mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
refactor: 将上游模型缓存从前端迁移到后端 Redis
- 后端:定时任务刷新时将上游模型写入 Redis 缓存 - 后端:provider_query 优先从缓存读取,支持 force_refresh 参数 - 后端:auto_fetch_models 开启时改为同步获取,确保前端能立即看到数据 - 前端:移除本地缓存,只保留并发请求去重逻辑 - 前端:KeyAllowedModelsEditDialog 添加刷新上游模型按钮
This commit is contained in:
@@ -257,7 +257,7 @@ const emit = defineEmits<{
|
||||
'changed': []
|
||||
}>()
|
||||
|
||||
const { fetchModels: fetchCachedModels, clearCache, getCachedModels } = useUpstreamModelsCache()
|
||||
const { fetchModels: fetchCachedModels } = useUpstreamModelsCache()
|
||||
|
||||
const { error: showError, success } = useToast()
|
||||
const { confirmWarning } = useConfirm()
|
||||
@@ -633,24 +633,8 @@ async function loadData() {
|
||||
// 同步全局模型选择状态
|
||||
syncGlobalModelSelection()
|
||||
|
||||
// 检查缓存
|
||||
const cachedModels = getCachedModels(props.providerId)
|
||||
if (cachedModels && cachedModels.length > 0) {
|
||||
upstreamModels.value = cachedModels
|
||||
upstreamModelsLoaded.value = true
|
||||
// 同步上游模型选择状态
|
||||
syncUpstreamModelSelection()
|
||||
// 有多个分组时全部折叠
|
||||
const allGroups = new Set(['global'])
|
||||
for (const model of cachedModels) {
|
||||
if (model.api_format) {
|
||||
allGroups.add(model.api_format)
|
||||
}
|
||||
}
|
||||
collapsedGroups.value = allGroups
|
||||
} else {
|
||||
collapsedGroups.value = new Set()
|
||||
}
|
||||
// 初始折叠状态
|
||||
collapsedGroups.value = new Set()
|
||||
}
|
||||
|
||||
// 加载全局模型列表
|
||||
@@ -677,13 +661,9 @@ async function loadExistingModels() {
|
||||
|
||||
// 从提供商获取模型
|
||||
async function fetchUpstreamModels(forceRefresh = false) {
|
||||
if (forceRefresh) {
|
||||
clearCache(props.providerId)
|
||||
}
|
||||
|
||||
try {
|
||||
fetchingUpstreamModels.value = true
|
||||
const result = await fetchCachedModels(props.providerId, forceRefresh)
|
||||
const result = await fetchCachedModels(props.providerId, undefined, forceRefresh)
|
||||
if (result) {
|
||||
if (result.error) {
|
||||
showError(result.error, '错误')
|
||||
|
||||
Reference in New Issue
Block a user