feat(webui): add search provider settings panel

- Add config-search-provider.vue component for managing search sources
- Support CRUD operations for custom search providers
- Default providers (mikan, nyaa, dmhy) cannot be deleted
- URL template validation ensures %s placeholder is present
- Add backend API endpoints GET/PUT /search/provider/config
- Add i18n translations for zh-CN and en

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Estrella Pan
2026-01-25 22:27:33 +01:00
parent 5e0efc01b9
commit a0a21a71e5
7 changed files with 490 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
from fastapi import APIRouter, Depends, Query
from sse_starlette.sse import EventSourceResponse
from module.conf.search_provider import get_provider, save_provider
from module.models import Bangumi
from module.searcher import SEARCH_CONFIG, SearchTorrent
from module.security.api import UNAUTHORIZED, get_current_user
@@ -32,3 +33,24 @@ async def search_torrents(site: str = "mikan", keywords: str = Query(None)):
)
async def search_provider():
return list(SEARCH_CONFIG.keys())
@router.get(
"/provider/config",
response_model=dict[str, str],
dependencies=[Depends(get_current_user)],
)
async def get_search_provider_config():
"""Get all search providers with their URL templates."""
return get_provider()
@router.put(
"/provider/config",
response_model=dict[str, str],
dependencies=[Depends(get_current_user)],
)
async def update_search_provider_config(providers: dict[str, str]):
"""Update search providers configuration."""
save_provider(providers)
return get_provider()