import { getConfig, writeConfig } from './configService.js'; // 测试配置服务功能 const testConfigService = async () => { try { console.log('开始测试配置服务...'); // 读取配置 const config = await getConfig(); console.log('成功读取配置:', { hasIndividualRankings: config.individualRankings?.length > 0, hasTeamRankings: config.teamRankings?.length > 0, hasSystemUsers: config.systemUsers?.length > 0, hasDisplayConfig: !!config.displayConfig, hasBattleEndTime: !!config.battleEndTime, hasDrumConfig: !!config.drumConfig }); // 写入配置(添加一个小的修改然后恢复) const testKey = 'test_timestamp'; const originalValue = config[testKey]; config[testKey] = Date.now(); await writeConfig(config); console.log('成功写入配置修改'); // 验证修改已保存 const updatedConfig = await getConfig(); console.log('修改验证成功:', updatedConfig[testKey] === config[testKey]); // 恢复原始状态 if (originalValue === undefined) { delete updatedConfig[testKey]; } else { updatedConfig[testKey] = originalValue; } await writeConfig(updatedConfig); console.log('成功恢复原始配置'); return { success: true }; } catch (error) { console.error('配置服务测试失败:', error); return { success: false, error: error.message }; } }; export default testConfigService;