Skip to content

Commit a5de6a8

Browse files
author
Taois
committed
feat:聚搜备份还原
1 parent 1cd91c1 commit a5de6a8

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

dashboard/src/services/backupService.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ const BACKUP_KEYS = {
2929
LIVE_CONFIG_URL: 'drplayer_live_config_url',
3030
CURRENT_SITE: 'drplayer_current_site',
3131

32+
// 聚合搜索相关
33+
SEARCH_AGGREGATION_SETTINGS: 'searchAggregationSettings', // 聚合搜索源选择设置
34+
SEARCH_AGGREGATION_PAGE_STATE: 'pageState_searchAggregation', // 聚合搜索页面状态
35+
SEARCH_HISTORY: 'drplayer_search_history', // 搜索历史记录
36+
3237
// 其他功能设置
3338
SKIP_SETTINGS: 'skipSettings',
3439
PARSER_CONFIG: 'parserConfig',
@@ -146,6 +151,8 @@ export const collectBackupData = () => {
146151
parserConfig: getLocalStorageData(BACKUP_KEYS.PARSER_CONFIG, {}),
147152
// 解析器数据
148153
parsers: getLocalStorageData(BACKUP_KEYS.PARSERS, []),
154+
// 聚合搜索设置
155+
searchAggregationSettings: getLocalStorageData(BACKUP_KEYS.SEARCH_AGGREGATION_SETTINGS, {}),
149156
// 侧边栏状态
150157
sidebarCollapsed: getLocalStorageData(BACKUP_KEYS.SIDEBAR_COLLAPSED, false),
151158
// 页面状态
@@ -160,6 +167,10 @@ export const collectBackupData = () => {
160167
watchHistory: getLocalStorageData(BACKUP_KEYS.WATCH_HISTORY, []),
161168
// 历史页面数据(historyStore使用)
162169
histories: getLocalStorageData(BACKUP_KEYS.HISTORIES, []),
170+
// 搜索历史记录
171+
searchHistory: getLocalStorageData(BACKUP_KEYS.SEARCH_HISTORY, []),
172+
// 聚合搜索页面状态
173+
searchAggregationPageState: getLocalStorageData(BACKUP_KEYS.SEARCH_AGGREGATION_PAGE_STATE, {}),
163174
// 每日统计
164175
dailyStats: getLocalStorageData(BACKUP_KEYS.DAILY_STATS, {}),
165176
// 周统计
@@ -283,6 +294,14 @@ export const restoreBackupData = (backupData) => {
283294
failedCount++
284295
errors.push(`解析器数据`)
285296
}
297+
} else if (key === 'searchAggregationSettings') {
298+
// 特殊处理聚合搜索设置
299+
if (setLocalStorageData(BACKUP_KEYS.SEARCH_AGGREGATION_SETTINGS, value)) {
300+
restoredCount++
301+
} else {
302+
failedCount++
303+
errors.push(`聚合搜索设置`)
304+
}
286305
} else {
287306
const storageKey = Object.values(BACKUP_KEYS).find(k => k.includes(key) || key.includes(k.split('_').pop()))
288307
if (storageKey) {
@@ -312,7 +331,9 @@ export const restoreBackupData = (backupData) => {
312331
watchHistory: BACKUP_KEYS.WATCH_HISTORY,
313332
dailyStats: BACKUP_KEYS.DAILY_STATS,
314333
weeklyStats: BACKUP_KEYS.WEEKLY_STATS,
315-
histories: BACKUP_KEYS.HISTORIES // 历史页面数据
334+
histories: BACKUP_KEYS.HISTORIES, // 历史页面数据
335+
searchHistory: BACKUP_KEYS.SEARCH_HISTORY, // 搜索历史记录
336+
searchAggregationPageState: BACKUP_KEYS.SEARCH_AGGREGATION_PAGE_STATE // 聚合搜索页面状态
316337
}
317338

318339
for (const [key, value] of Object.entries(backupData.userData)) {

dashboard/src/services/resetService.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const DEFAULT_CONFIGS = {
3232
autoLive: false,
3333
secureDns: false,
3434
cspBypass: true,
35-
referrerPolicy: 'no-referrer'
35+
referrerPolicy: 'no-referrer',
36+
searchAggregation: false // 聚合搜索功能默认关闭
3637
},
3738

3839
// CSP配置默认值
@@ -50,6 +51,11 @@ const DEFAULT_CONFIGS = {
5051
// 页面状态默认值
5152
pageState: {},
5253

54+
// 聚合搜索设置默认值
55+
searchAggregationSettings: {
56+
selectedSources: [] // 默认没有选中任何搜索源
57+
},
58+
5359
// 侧边栏状态默认值
5460
sidebarCollapsed: false
5561
}
@@ -64,6 +70,11 @@ const CLEAR_DATA_KEYS = [
6470
'drplayer_weekly_stats', // 周统计
6571
'drplayer_parsers', // 解析器数据
6672

73+
// 聚合搜索相关
74+
'searchAggregationSettings', // 聚合搜索源选择设置
75+
'pageState_searchAggregation', // 聚合搜索页面状态
76+
'drplayer_search_history', // 搜索历史记录
77+
6778
// 站点数据
6879
'siteStore', // 站点存储
6980
'drplayer_config_url', // 配置地址

0 commit comments

Comments
 (0)