fix: 修复打包版背景图黑屏问题,重构数据路径逻辑

新增背景图路径归一化函数,将旧版使用的绝对路径 `/background.png` 转换为适配全环境的正确相对路径;重构Electron主进程的数据基准路径计算逻辑,修复Linux/AppImage打包版的只读目录限制
This commit is contained in:
2026-09-05 20:35:59 +08:00
parent caf52b9a3d
commit 3b627389c9
2 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -20,6 +20,7 @@ import { saveConfig, configExists, getConfig, flushConfig, configPath } from './
import { findCachedBackgroundRaw, optimizeBackgroundFile, recoverBackgroundFromDataUrl } from './core/background-image';
import { registerResourceSchemePrivileges, registerResourceProtocol } from './resource-protocol';
import { createLogger, setDebugModeProvider, installIpcLogging, registerRendererLogBridge } from './core/logger';
import { dataBasePath } from './core/paths';
const { app } = electron;
@@ -73,9 +74,8 @@ function migrateLegacyFiles(): void {
// Startup checks: .minecraft dir + config file + first launch detection
function runStartupChecks(): { isFirstLaunch: boolean; config: ReturnType<typeof getConfig> } {
const dataPath = app.isPackaged
? path.dirname(app.getPath('exe'))
: path.join(__dirname, '..');
// 数据基准:开发→项目根;Windows 打包→exe 目录;Linux/AppImage→userDataexe 目录是只读挂载)
const dataPath = dataBasePath();
// 1. Ensure .minecraft directory exists
const minecraftDir = path.join(dataPath, '.minecraft');