diff --git a/public/index.html b/public/index.html index 5871172..e1edd88 100644 --- a/public/index.html +++ b/public/index.html @@ -22,25 +22,5 @@ - diff --git a/public/settings/index.html b/public/settings/index.html index da9e946..2eea89b 100644 --- a/public/settings/index.html +++ b/public/settings/index.html @@ -70,10 +70,10 @@ -
+
diff --git a/public/updates/index.html b/public/updates/index.html index 242be13..3ac9464 100644 --- a/public/updates/index.html +++ b/public/updates/index.html @@ -51,7 +51,6 @@
MineXLauncher 1.5 -
  • The launcher can now be downloaded for offline use
  • You can now install the launcher as a PWA web app

  • MineXLauncher 1.4 diff --git a/public/welcome/index.html b/public/welcome/index.html index 0f3789a..400e718 100644 --- a/public/welcome/index.html +++ b/public/welcome/index.html @@ -39,8 +39,8 @@ - - +
    diff --git a/src/resources/scripts/main.ts b/src/resources/scripts/main.ts index 4a9ad03..ce12026 100644 --- a/src/resources/scripts/main.ts +++ b/src/resources/scripts/main.ts @@ -284,19 +284,43 @@ const serviceworker = { }; if (window.location.pathname === '/') { + const lastPage = storage.session.get('lastPage'); + const isMobile = detect.mobile(); + const iframe = document.createElement('iframe'); + iframe.id = 'main_frame'; + + iframe.style.display = 'none'; + iframe.addEventListener('load', () => { + iframe.style.display = ''; + }); + + if (storage.local.get('lastVersion') === null) { + iframe.src = '/welcome/'; + } else if (lastPage !== null) { + iframe.src = lastPage; + } else if (isMobile) { + iframe.src = '/mobile/'; + } else { + iframe.src = '/home/game/'; + } + + document.addEventListener('DOMContentLoaded', () => { + document.body.appendChild(iframe); + }); + window.addEventListener('beforeinstallprompt', (event) => { - const mainFrame = document.getElementById('main_frame') as HTMLIFrameElement; - if (mainFrame.contentWindow) { + if (iframe.contentWindow) { // @ts-expect-error - mainFrame.contentWindow.installPwaEvent = event; + iframe.contentWindow.installPwaEvent = event; } }); - if (storage.local.get('offlineCache') === true) { + /* if (storage.local.get('offlineCache') === true) { serviceworker.register('/sw-full.js'); } else { serviceworker.register('/sw.js'); - } + } */ + serviceworker.register('/sw.js'); } else { document.addEventListener('DOMContentLoaded', () => { const profileName = document.getElementById('profile-name'); @@ -311,7 +335,6 @@ if (window.location.pathname === '/') { alert(`MineXLauncher has been updated to v${launcherVersion}! Changes in v${launcherVersion}: - - The launcher can now be downloaded for offline use - You can now install the launcher as a PWA web app`); storage.local.set('lastVersion', launcherVersion); } diff --git a/src/resources/scripts/settings.ts b/src/resources/scripts/settings.ts index 4c0d28c..9148c36 100644 --- a/src/resources/scripts/settings.ts +++ b/src/resources/scripts/settings.ts @@ -3,11 +3,11 @@ if (window.location.pathname === '/settings/') { const profileName = document.getElementById('profile-name'); const usernameInput = document.getElementById('username-input') as HTMLInputElement; const themeSelect = document.getElementById('theme-select') as HTMLSelectElement; - const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement; + // const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement; usernameInput.placeholder = storage.local.get('username') ?? ''; themeSelect.value = storage.local.get('theme') ?? ''; - offlineCheckbox.checked = storage.local.get('offlineCache') ?? false; + // offlineCheckbox.checked = storage.local.get('offlineCache') ?? false; usernameInput.addEventListener('input', () => { let username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16); @@ -25,7 +25,7 @@ if (window.location.pathname === '/settings/') { theme.set(themeSelect.value); }); - offlineCheckbox.addEventListener('change', () => { + /* offlineCheckbox.addEventListener('change', () => { storage.local.set('offlineCache', offlineCheckbox.checked); if (offlineCheckbox.checked) { serviceworker.register('/sw-full.js'); @@ -36,7 +36,7 @@ if (window.location.pathname === '/settings/') { serviceworker.register('/sw.js'); alert('Offline cache has been deleted.'); } - }); + }); */ }); } @@ -45,7 +45,7 @@ if (window.location.pathname === '/welcome/') { const setupForm = document.getElementById('setup-form') as HTMLFormElement; const usernameInput = document.getElementById('username-input') as HTMLInputElement; const themeSelect = document.getElementById('theme-select') as HTMLSelectElement; - const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement; + // const offlineCheckbox = document.getElementById('offline-checkbox') as HTMLInputElement; usernameInput.addEventListener('input', () => { const username = usernameInput.value.replace(/[^A-Za-z0-9]/g, '_').substring(0, 16); @@ -72,10 +72,10 @@ if (window.location.pathname === '/welcome/') { storage.local.set('username', username); storage.local.set('theme', themeSelect.value); - storage.local.set('offlineCache', offlineCheckbox.checked); + // storage.local.set('offlineCache', offlineCheckbox.checked); storage.local.set('lastVersion', launcherVersion); - if (offlineCheckbox.checked) { + /* if (offlineCheckbox.checked) { serviceworker.register('/sw-full.js'); alert( 'Offline cache is now downloading.\nThe download size is about 1GB, so it may take a while.\n\nPlease do not leave this page while the download is in progress.\nYou will be notified when the download is complete.' @@ -88,7 +88,7 @@ if (window.location.pathname === '/welcome/') { } } else { serviceworker.register('/sw.js'); - } + } */ // @ts-expect-error window.top.location.href = '/';