From d6ee43e48b6dd66883eef9a9239877feecc2e0d3 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Wed, 12 Nov 2025 20:01:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BB=A3=E7=A0=81=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E9=99=A4=E4=BA=86=E5=86=A0=E5=86=9B=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E5=85=B6=E4=BB=96=E6=98=BE=E7=A4=BA=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config.json | 5 +- package.json | 2 +- src/App.vue | 89 ++- src/data/mockData.js | 28 +- src/main.js | 36 +- src/services/configService.js | 80 ++- src/services/testConfig.js | 47 -- src/style.css | 48 +- src/views/AdminPanel.vue | 26 +- src/views/BattleRanking.vue | 981 +++++++++++++++++++++++++++------- 10 files changed, 1048 insertions(+), 294 deletions(-) delete mode 100644 src/services/testConfig.js diff --git a/data/config.json b/data/config.json index cff99ce..1056402 100644 --- a/data/config.json +++ b/data/config.json @@ -336,6 +336,7 @@ } ], "displayConfig": { + "showBonusModule": true, "individual": { "showLevel": false, "showDepartment": false, @@ -371,8 +372,8 @@ } }, "battleEndTime": { - "date": "2026-02-01", - "time": "23:59:59" + "date": "2026-02-08", + "time": "00:00:00" }, "drumConfig": { "sound": { diff --git a/package.json b/package.json index f53d773..83ab53b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vite build", "preview": "vite preview", - "start": "node server.js" + "start": "npm run build && node server.js" }, "dependencies": { "cors": "^2.8.5", diff --git a/src/App.vue b/src/App.vue index 9d4d6b9..79214f4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,14 +3,95 @@ diff --git a/src/data/mockData.js b/src/data/mockData.js index ddc04f5..8e097b3 100644 --- a/src/data/mockData.js +++ b/src/data/mockData.js @@ -38,17 +38,17 @@ export const saveBattleEndTime = async (endTime) => { return await saveBattleEndTimeToConfig(endTime); }; -// 保存个人排名数据 +// 保存英雄排名数据 export const saveIndividualRankings = async (data) => { individualRankings = [...data]; - console.log('保存个人排名数据:', data); + console.log('保存英雄排名数据:', data); return await saveIndividualRankingsToConfig(data); }; -// 保存战队排名数据 +// 保存战区排名数据 export const saveTeamRankings = async (data) => { teamRankings = [...data]; - console.log('保存战队排名数据:', data); + console.log('保存战区排名数据:', data); return await saveTeamRankingsToConfig(data); }; @@ -62,7 +62,25 @@ export const saveDisplayConfig = async (config) => { // 保存战鼓配置 export const saveDrumConfig = async (config) => { console.log('保存战鼓配置:', config); - drumConfig = { ...drumConfig, ...config }; + + // 深度合并配置,确保嵌套对象(如sound、animation、pattern)的属性不会丢失 + drumConfig = { + ...drumConfig, + ...config, + sound: { + ...drumConfig.sound, + ...config.sound + }, + animation: { + ...drumConfig.animation, + ...config.animation + }, + pattern: { + ...drumConfig.pattern, + ...config.pattern + } + }; + return await saveDrumConfigToConfig(drumConfig); }; diff --git a/src/main.js b/src/main.js index e3b5a88..117fa57 100644 --- a/src/main.js +++ b/src/main.js @@ -2,11 +2,43 @@ import { createApp } from 'vue' import './style.css' import App from './App.vue' import router from './router' +import { getBackgroundConfig } from './services/configService' + +// 设置页面背景 +const setupBackground = async () => { + try { + const backgroundConfig = await getBackgroundConfig(); + + // 如果配置了使用背景图片 + if (backgroundConfig.useBackgroundImage && backgroundConfig.backgroundImage) { + document.body.style.backgroundImage = `url(${backgroundConfig.backgroundImage})`; + document.body.style.backgroundSize = backgroundConfig.backgroundSize || 'cover'; + document.body.style.backgroundPosition = backgroundConfig.backgroundPosition || 'center'; + document.body.style.backgroundRepeat = 'no-repeat'; + document.body.style.backgroundAttachment = 'fixed'; + } else if (backgroundConfig.backgroundColor) { + // 使用纯色背景 + document.body.style.backgroundColor = backgroundConfig.backgroundColor; + document.body.style.backgroundImage = 'none'; + } + } catch (error) { + console.error('设置背景失败:', error); + } +}; + +// 设置默认背景(立即应用) +document.body.style.backgroundImage = 'url(/battle-background.jpg)'; +document.body.style.backgroundSize = 'contain'; +document.body.style.backgroundPosition = 'center'; +document.body.style.backgroundRepeat = 'no-repeat'; +document.body.style.backgroundAttachment = 'fixed'; const app = createApp(App) // 使用路由 app.use(router) -// 挂载应用 -app.mount('#app') +// 挂载应用前设置背景 +setupBackground().then(() => { + app.mount('#app'); +}); diff --git a/src/services/configService.js b/src/services/configService.js index 18d83cc..f114b56 100644 --- a/src/services/configService.js +++ b/src/services/configService.js @@ -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); }; \ No newline at end of file diff --git a/src/services/testConfig.js b/src/services/testConfig.js deleted file mode 100644 index 6459f64..0000000 --- a/src/services/testConfig.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/src/style.css b/src/style.css index 7215d25..6f791b0 100644 --- a/src/style.css +++ b/src/style.css @@ -67,6 +67,41 @@ html, body { #app { width: 100%; min-height: 100vh; + display: flex; + justify-content: center; +} + +/* 主内容容器 - 适配1920x1080分辨率 */ +.content-container { + width: 100%; + max-width: 1920px; + min-height: 100vh; + padding: 0 20px; + position: relative; + box-sizing: border-box; +} + +/* 当屏幕宽度超过1920px时,保持内容居中且大小不变 */ +@media (min-width: 1921px) { + .content-container { + width: 1920px; + margin: 0 auto; + /* box-shadow: 0 0 50px rgba(0, 0, 0, 0.5); */ + } +} + +/* 当屏幕高度超过1080px时,保持内容垂直对齐 */ +@media (min-height: 1081px) { + #app { + align-items: flex-start; + } +} + +/* 针对1920x1080分辨率的精确调整 */ +@media (width: 1920px) and (height: 1080px) { + .content-container { + padding: 0; + } } /* 游戏化标题样式 */ @@ -332,12 +367,9 @@ table { /* 游戏化卡片样式 */ .card-game { - background: rgba(255, 255, 255, 0.05); - border: 2px solid var(--gold-primary); - border-radius: 15px; - padding: 20px; - box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), var(--glow-primary); - backdrop-filter: blur(10px); + background: transparent; + border: 0; + /* padding: 20px; */ transition: all 0.3s ease; position: relative; overflow: hidden; @@ -358,8 +390,8 @@ table { .card-game:hover { transform: translateY(-5px); - box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), var(--glow-primary); - border-color: var(--gold-tertiary); + /* box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), var(--glow-primary); */ + /* border-color: var(--gold-tertiary); */ } @keyframes shine { diff --git a/src/views/AdminPanel.vue b/src/views/AdminPanel.vue index fd3217d..374607d 100644 --- a/src/views/AdminPanel.vue +++ b/src/views/AdminPanel.vue @@ -51,7 +51,7 @@ >{{ tab.label }} -
+

⏰ 百人大战结束时间设置

@@ -259,9 +259,9 @@
排名 姓名 - {{ displayConfig.individual.scoreColumn.displayName }} - 等级 - 部门 + {{ localDisplayConfig.individual.scoreColumn.displayName }} + 等级 + 部门 奖金 操作
@@ -273,9 +273,9 @@ > {{ index + 1 }} {{ item.name }} - {{ displayConfig.individual.scoreColumn.displayStyle === 'amount' ? '¥' + item.score : item.score }} - {{ item.level }} - {{ item.department }} + {{ localDisplayConfig.individual.scoreColumn.displayStyle === 'amount' ? '¥' + item.score : item.score }} + {{ item.level }} + {{ item.department }} ¥{{ item.bonus }} @@ -294,9 +294,9 @@
排名 战队名称 - {{ displayConfig.team.totalScoreColumn.displayName }} - 人数 - 队长 + {{ localDisplayConfig.team.totalScoreColumn.displayName }} + 人数 + 队长 奖金 操作
@@ -308,9 +308,9 @@ > {{ index + 1 }} {{ item.name }} - {{ displayConfig.team.totalScoreColumn.displayStyle === 'amount' ? '¥' + item.totalScore : item.totalScore }} - {{ item.memberCount }}人 - {{ item.leader }} + {{ localDisplayConfig.team.totalScoreColumn.displayStyle === 'amount' ? '¥' + item.totalScore : item.totalScore }} + {{ item.memberCount }}人 + {{ item.leader }} ¥{{ item.bonus }} diff --git a/src/views/BattleRanking.vue b/src/views/BattleRanking.vue index dfba6aa..2804723 100644 --- a/src/views/BattleRanking.vue +++ b/src/views/BattleRanking.vue @@ -1,25 +1,15 @@