diff --git a/src/App.vue b/src/App.vue index dd3a7ca..e7d7630 100644 --- a/src/App.vue +++ b/src/App.vue @@ -8,12 +8,19 @@ /> - - + + + + @@ -22,12 +29,14 @@ import { computed, onMounted, onUnmounted, ref } from "vue"; import { imageDB } from "@/utils/imageDB"; import { useSearchStore } from "@/stores/search"; +import StatsCorner from "@/components/StatsCorner.vue"; import TopToolbar from "@/components/TopToolbar.vue"; import SearchHeader from "@/components/SearchHeader.vue"; import SearchResults from "@/components/SearchResults.vue"; import FloatingButtons from "@/components/FloatingButtons.vue"; import CommentsModal from "@/components/CommentsModal.vue"; import VndbPanel from "@/components/VndbPanel.vue"; +import SettingsModal from "@/components/SettingsModal.vue"; const searchStore = useSearchStore(); const randomImageUrl = ref(""); @@ -38,6 +47,9 @@ const shuffledQueue = ref([]); let fetchInterval: number | null = null; let displayInterval: number | null = null; +// 设置模态框 +const isSettingsOpen = ref(false); + const MAX_CACHE_SIZE = 10000; // 最大缓存 10000 张图片 const CLEANUP_BATCH_SIZE = 2000; // 每次清理 2000 张 const FETCH_INTERVAL = 5000; // 5秒获取一次 @@ -368,6 +380,20 @@ onUnmounted(() => { // 关闭数据库连接 imageDB.close(); }); + +// 设置相关函数 +function openSettings() { + isSettingsOpen.value = true; +} + +function closeSettings() { + isSettingsOpen.value = false; +} + +function saveSettings(customApi: string) { + // 保存自定义 API 到 store + searchStore.setCustomApi(customApi); +} diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue new file mode 100644 index 0000000..8f7cbeb --- /dev/null +++ b/src/components/SettingsModal.vue @@ -0,0 +1,203 @@ + + + + + + + + + + + 设置 + + + + + + + + + + + + + API 设置 + + + + + + + 自定义 API 地址 + + + + + + + 留空使用默认 API 地址。例如: https://cfapi.searchgal.homes 或 http://127.0.0.1:8787 + + + + + + + + + 关于自定义 API + 您可以使用自己部署的后端 API 进行搜索。API 需要兼容 SearchGal 的接口规范。 + + + + + + + + + + + + + + + 重置 + + + + 保存 + + + + + + + + + + + + diff --git a/src/components/StatsCorner.vue b/src/components/StatsCorner.vue new file mode 100644 index 0000000..c262b1e --- /dev/null +++ b/src/components/StatsCorner.vue @@ -0,0 +1,50 @@ + + + + + + + - + + + + + - + + + + + + + + + diff --git a/src/components/TopToolbar.vue b/src/components/TopToolbar.vue index ea679ad..85be1c2 100644 --- a/src/components/TopToolbar.vue +++ b/src/components/TopToolbar.vue @@ -22,6 +22,26 @@ + + + + + + + + + + () +// Emits +const emit = defineEmits<{ + openSettings: [] +}>() + // 状态 const showSaveTip = ref(false) const showCopiedTip = ref(false) @@ -178,6 +203,11 @@ async function shareSearch() { } } +// 打开设置 +function openSettings() { + emit('openSettings') +} + // 保存背景图(使用源格式和文件名) async function saveBackgroundImage() { if (!props.currentBackgroundUrl) return @@ -331,6 +361,24 @@ watch(themeMode, () => { transform: scale(0.95); } +/* GitHub 按钮特殊样式 */ +.github-button { + color: rgb(31, 41, 55); + text-decoration: none; +} + +.dark .github-button { + color: rgb(226, 232, 240); +} + +.github-button:hover { + border-color: rgba(31, 41, 55, 0.5); +} + +.dark .github-button:hover { + border-color: rgba(226, 232, 240, 0.5); +} + /* 主题按钮特殊样式 */ .theme-button:hover { border-color: rgba(245, 158, 11, 0.5);
+ 留空使用默认 API 地址。例如: https://cfapi.searchgal.homes 或 http://127.0.0.1:8787 +
关于自定义 API
您可以使用自己部署的后端 API 进行搜索。API 需要兼容 SearchGal 的接口规范。