feat: integrate PWA support with vite-plugin-pwa and remove legacy service worker files

- Added vite-plugin-pwa for enhanced PWA capabilities, including automatic service worker registration and caching strategies.
- Updated manifest configuration directly in vite.config.ts, removing the need for a separate manifest.json file.
- Removed legacy service worker and associated versioning plugin, streamlining the PWA setup.
- Adjusted UI components to reflect the new update handling mechanism for service workers.
This commit is contained in:
AdingApkgg
2026-01-09 21:10:47 +08:00
parent d61c45a640
commit 04c802a84f
15 changed files with 3333 additions and 467 deletions

View File

@@ -7,7 +7,6 @@ import type { PlatformData, VndbInfo } from '@/stores/search'
const STORAGE_KEY = 'searchgal_state'
const STORAGE_VERSION = '1.0'
const MAX_HISTORY_SIZE = 10 // 最多保存 10 条搜索历史
export interface SearchState {
version: string
@@ -106,11 +105,6 @@ export function saveSearchHistory(history: SearchHistory): void {
// 添加新搜索到开头
historyList.unshift(history)
// 限制历史记录数量
if (historyList.length > MAX_HISTORY_SIZE) {
historyList = historyList.slice(0, MAX_HISTORY_SIZE)
}
localStorage.setItem(HISTORY_KEY, JSON.stringify(historyList))
} catch (error) {
// 静默处理
@@ -149,6 +143,18 @@ export function clearSearchHistory(): void {
}
}
/**
* 覆盖保存整个搜索历史列表
*/
export function saveAllSearchHistory(historyList: SearchHistory[]): void {
try {
const HISTORY_KEY = 'searchgal_history'
localStorage.setItem(HISTORY_KEY, JSON.stringify(historyList))
} catch (error) {
// 静默处理
}
}
/**
* 获取 localStorage 使用情况
*/