chore: 代码保存,除了冠军模块,其他显示正常

This commit is contained in:
2025-11-12 20:01:21 +08:00
parent 391c489fb5
commit d6ee43e48b
10 changed files with 1048 additions and 294 deletions

View File

@@ -64,6 +64,7 @@ const getDefaultConfig = () => ({
bonusRules: [],
systemUsers: [],
displayConfig: {
showBonusModule: true, // 控制奖金设置模块的显示,默认不显示
individual: {
showLevel: false,
showDepartment: false,
@@ -71,26 +72,46 @@ const getDefaultConfig = () => ({
displayName: '分数',
displayStyle: 'number'
},
columnWidths: {}
teamColumn: {
displayName: '战区',
displayStyle: 'text'
},
columnWidths: {
rank: '80px',
name: '150px',
dept: '150px',
team: '120px',
score: '100px',
level: '80px',
bonus: '100px'
}
},
team: {
showMemberCount: false,
showLeader: false,
totalScoreColumn: {
displayName: '总分',
displayName: '业绩',
displayStyle: 'number'
},
columnWidths: {}
columnWidths: {
rank: '80px',
name: '150px',
score: '100px',
memberCount: '120px',
bonus: '100px'
}
}
},
battleEndTime: {
date: new Date().toISOString().split('T')[0],
time: '23:59:59'
time: '00:00:00'
},
drumConfig: {
showDrum: false, // 控制战鼓的显示,默认不显示
sound: {
volume: 1.0,
enabled: false
enabled: false, // 控制声音播放,默认不播放
soundSrc: '' // 战鼓声音来源文件路径
},
animation: {
enabled: false
@@ -99,12 +120,19 @@ const getDefaultConfig = () => ({
strongBeats: [1],
totalBeats: 4
}
},
backgroundConfig: {
useBackgroundImage: true,
backgroundImage: '/battle-background.jpg', // 默认战旗背景图片
backgroundSize: 'contain',
backgroundPosition: 'center',
backgroundColor: '#1a1a1a' // 备选背景色
}
});
/**
* 获取个人排名数据
* @returns {Array} 个人排名数组
* 获取英雄排名数据
* @returns {Array} 英雄排名数组
*/
export const getIndividualRankings = async () => {
const config = await readConfig();
@@ -112,8 +140,8 @@ export const getIndividualRankings = async () => {
};
/**
* 保存个人排名数据
* @param {Array} rankings 个人排名数组
* 保存英雄排名数据
* @param {Array} rankings 英雄排名数组
* @returns {boolean} 是否保存成功
*/
export const saveIndividualRankings = async (rankings) => {
@@ -123,8 +151,8 @@ export const saveIndividualRankings = async (rankings) => {
};
/**
* 获取战排名数据
* @returns {Array} 战排名数组
* 获取战排名数据
* @returns {Array} 战排名数组
*/
export const getTeamRankings = async () => {
const config = await readConfig();
@@ -132,8 +160,8 @@ export const getTeamRankings = async () => {
};
/**
* 保存战排名数据
* @param {Array} rankings 战排名数组
* 保存战排名数据
* @param {Array} rankings 战排名数组
* @returns {boolean} 是否保存成功
*/
export const saveTeamRankings = async (rankings) => {
@@ -270,7 +298,7 @@ export const updateSystemUser = async (userId, updatedData) => {
*/
export const getDisplayConfig = async () => {
const config = await readConfig();
return config.displayConfig || {};
return config.displayConfig || getDefaultConfig().displayConfig;
};
/**
@@ -290,7 +318,7 @@ export const saveDisplayConfig = async (displayConfig) => {
*/
export const getBattleEndTime = async () => {
const config = await readConfig();
return config.battleEndTime || {};
return config.battleEndTime || getDefaultConfig().battleEndTime;
};
/**
@@ -310,7 +338,7 @@ export const saveBattleEndTime = async (endTime) => {
*/
export const getDrumConfig = async () => {
const config = await readConfig();
return config.drumConfig || {};
return config.drumConfig || getDefaultConfig().drumConfig;
};
/**
@@ -322,4 +350,24 @@ export const saveDrumConfig = async (drumConfig) => {
const config = await readConfig();
config.drumConfig = drumConfig;
return await writeConfig(config);
};
/**
* 获取背景配置
* @returns {Object} 背景配置
*/
export const getBackgroundConfig = async () => {
const config = await readConfig();
return config.backgroundConfig || getDefaultConfig().backgroundConfig;
};
/**
* 保存背景配置
* @param {Object} backgroundConfig 背景配置
* @returns {boolean} 是否保存成功
*/
export const saveBackgroundConfig = async (backgroundConfig) => {
const config = await readConfig();
config.backgroundConfig = backgroundConfig;
return await writeConfig(config);
};

View File

@@ -1,47 +0,0 @@
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;