1
0
Fork 0
This commit is contained in:
yunyun 2026-06-02 16:40:25 +08:00
parent 8b0656c133
commit b8ff90fe9e
6 changed files with 105 additions and 42 deletions

10
main.js
View File

@ -65,7 +65,9 @@ const DEFAULT_SETTINGS = {
},
appearance: {
theme: 'light',
scale: '110'
scale: '110',
playStartupAnimation: true,
skipSplash: false
},
download: {
maxConcurrent: 64,
@ -78,7 +80,6 @@ const DEFAULT_SETTINGS = {
autoClearLogs: true,
logRetentionValue: 7,
logRetentionUnit: 'day',
playStartupAnimation: true,
developerMode: false
}
};
@ -403,8 +404,9 @@ app.whenReady().then(() => {
return;
}
// 提前初始化 BASE_DIR 以读取配置文件
// 提前初始化 BASE_DIR 和日志路径,确保所有 writeLog 都写入文件
BASE_DIR = app.getPath('userData');
initPaths();
// 检查是否启用防止多次启动
let preventMultipleLaunch = true;
@ -430,8 +432,6 @@ app.whenReady().then(() => {
}
}
initPaths();
cleanupExpiredLogs();
try {

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "gpcl",
"version": "1.4.2",
"version": "1.4.3",
"lockfileVersion": 3,
"requires": true,
"packages": {

View File

@ -1,6 +1,6 @@
{
"name": "gpcl",
"version": "1.4.2",
"version": "1.4.3",
"description": "GoodPlanCraftLauncher",
"main": "main.js",
"scripts": {

View File

@ -1,4 +1,4 @@
<!--
<!--
CaelLab BY-SA Code License
Copyright (c) 2026 Yunyun(云云) By 虚舟实验室(CaelLab) / CaelLabGameTS
@ -571,6 +571,36 @@
</div>
</div>
</div>
<div class="setting-card">
<div class="setting-row">
<div class="setting-left">
<div class="setting-label">播放启动动画</div>
<div class="setting-desc">启动游戏时全屏播放 Minecraft 欢迎动画</div>
</div>
<div class="setting-control">
<label class="switch">
<input type="checkbox" id="play-startup-animation">
<span class="slider"></span>
</label>
</div>
</div>
</div>
<div class="setting-card">
<div class="setting-row">
<div class="setting-left">
<div class="setting-label">不渲染Splash</div>
<div class="setting-desc">尝试在启动时不渲染Splash直接进入主界面但可能延长白屏时间同时对于预编译不友好</div>
</div>
<div class="setting-control">
<label class="switch">
<input type="checkbox" id="skip-splash">
<span class="slider"></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
@ -667,21 +697,6 @@
</div>
</div>
<div class="setting-card">
<div class="setting-row">
<div class="setting-left">
<div class="setting-label">播放启动动画</div>
<div class="setting-desc">启动游戏时全屏播放 Minecraft 欢迎动画</div>
</div>
<div class="setting-control">
<label class="switch">
<input type="checkbox" id="play-startup-animation">
<span class="slider"></span>
</label>
</div>
</div>
</div>
<div class="setting-card">
<div class="setting-row">
<div class="setting-left">

View File

@ -866,7 +866,12 @@ async function reloadAllSettingsToUI() {
const playStartupAnimationEl = document.getElementById('play-startup-animation');
if (playStartupAnimationEl) {
playStartupAnimationEl.checked = settings.advanced?.playStartupAnimation === true;
playStartupAnimationEl.checked = settings.appearance?.playStartupAnimation === true;
}
const skipSplashEl = document.getElementById('skip-splash');
if (skipSplashEl) {
skipSplashEl.checked = settings.appearance?.skipSplash === true;
}
const developerModeEl = document.getElementById('developer-mode');
@ -1723,12 +1728,12 @@ async function launchGame() {
let windowMode = settings.game?.windowMode || 'windowed';
let welcomeAnimPlaying = false;
if (settings.advanced?.playStartupAnimation && window.gpcl && window.gpcl.playStartupAnimation) {
if (settings.appearance?.playStartupAnimation && window.gpcl && window.gpcl.playStartupAnimation) {
setStatus('[启动动画] 正在播放欢迎动画...');
welcomeAnimPlaying = true;
windowMode = 'fullscreen';
settings.advanced.playStartupAnimation = false;
settings.appearance.playStartupAnimation = false;
await gpcl.saveSettings(settings);
const playStartupEl = document.getElementById('play-startup-animation');
if (playStartupEl) playStartupEl.checked = false;
@ -2582,12 +2587,28 @@ launchBtn.addEventListener('click', launchGame);
if (playStartupAnimation) {
(async () => {
const settings = await loadSettings();
playStartupAnimation.checked = settings.advanced?.playStartupAnimation === true;
playStartupAnimation.checked = settings.appearance?.playStartupAnimation === true;
})();
playStartupAnimation.addEventListener('change', async () => {
const settings = await loadSettings();
settings.advanced.playStartupAnimation = playStartupAnimation.checked;
if (!settings.appearance) settings.appearance = {};
settings.appearance.playStartupAnimation = playStartupAnimation.checked;
await gpcl.saveSettings(settings);
});
}
const skipSplash = document.getElementById('skip-splash');
if (skipSplash) {
(async () => {
const settings = await loadSettings();
skipSplash.checked = settings.appearance?.skipSplash === true;
})();
skipSplash.addEventListener('change', async () => {
const settings = await loadSettings();
if (!settings.appearance) settings.appearance = {};
settings.appearance.skipSplash = skipSplash.checked;
await gpcl.saveSettings(settings);
});
}
@ -2708,6 +2729,18 @@ launchBtn.addEventListener('click', launchGame);
setCustomSelectValue('settings-scale', scale);
applyScale(scale);
// 播放启动动画
const playStartupAnimSync = document.getElementById('play-startup-animation');
if (playStartupAnimSync) {
playStartupAnimSync.checked = settings.appearance?.playStartupAnimation === true;
}
// 不渲染Splash
const skipSplashSync = document.getElementById('skip-splash');
if (skipSplashSync) {
skipSplashSync.checked = settings.appearance?.skipSplash === true;
}
// Java镜像
const javaMirror = settings.download?.javaMirror || 'tsinghua';
setCustomSelectValue('java-mirror-select', javaMirror);
@ -3172,7 +3205,9 @@ async function loadSettings() {
},
appearance: {
theme: 'light',
scale: '100'
scale: '100',
playStartupAnimation: true,
skipSplash: false
},
download: {
maxConcurrent: 64,
@ -3185,7 +3220,6 @@ async function loadSettings() {
autoClearLogs: true,
logRetentionValue: 7,
logRetentionUnit: 'day',
playStartupAnimation: true,
developerMode: false
}
};

View File

@ -1,4 +1,4 @@
<!--
<!--
CaelLab BY-SA Code License
Copyright (c) 2026 Yunyun(云云) By 虚舟实验室(CaelLab) / CaelLabGameTS
@ -168,6 +168,17 @@
createParticles();
window.addEventListener('DOMContentLoaded', () => {
const checkSkipSplash = async () => {
try {
if (window.gpcl && window.gpcl.getSettings) {
const settings = await window.gpcl.getSettings();
if (settings && settings.appearance && settings.appearance.skipSplash === true) {
window.location.href = 'index.html';
return;
}
}
} catch (e) {}
if (window.gpcl && window.gpcl.getAppVersion) {
window.gpcl.getAppVersion().then(version => {
document.getElementById('version-info').textContent = 'v' + version;
@ -181,6 +192,9 @@
window.location.href = 'index.html';
}, 500);
}, 2000);
};
checkSkipSplash();
});
</script>
</body>