mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-15 10:19:55 -05:00
Chore: Fixed ServerURL & AppPin on WebUI
This commit is contained in:
+58
-45
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import { page } from '$app/stores'
|
||||
import { appState, app } from '$lib/state/app.svelte'
|
||||
import { appState, app, type AppStatus } from '$lib/state/app.svelte'
|
||||
import { boot } from '$lib/state/boot.svelte'
|
||||
import { notifications } from '$lib/state/notifications.svelte'
|
||||
import { settingsState, loadSettingsIntoState, updateSettings } from '$lib/state/settings.svelte'
|
||||
@@ -34,16 +34,23 @@
|
||||
|
||||
const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
|
||||
|
||||
let splashDismissed = $state(false)
|
||||
let themeEditorOpen = $state(false)
|
||||
let themeEditorId = $state<string | null>(null)
|
||||
appState.status = 'booting' as AppStatus
|
||||
|
||||
let splashDismissed = $state(false)
|
||||
let settingsLoaded = $state(false)
|
||||
let themeEditorOpen = $state(false)
|
||||
let themeEditorId = $state<string | null>(null)
|
||||
|
||||
const splashVisible = $derived(
|
||||
!splashDismissed ||
|
||||
appState.status === 'booting' ||
|
||||
appState.status === 'locked' ||
|
||||
appState.status === 'error' ||
|
||||
appState.status === 'auth'
|
||||
appState.status === 'auth' ||
|
||||
(appState.status === 'ready' && !splashDismissed)
|
||||
)
|
||||
|
||||
const splashMode = $derived(
|
||||
appState.status === 'locked' && settingsLoaded ? 'locked' : 'loading'
|
||||
)
|
||||
|
||||
const ringFull = $derived(appState.status === 'ready')
|
||||
@@ -62,51 +69,57 @@
|
||||
const readerContainerized = $derived(settingsState.settings.readerContainerized ?? false)
|
||||
const strippedLayout = $derived(isReaderRoute && !readerContainerized)
|
||||
|
||||
onMount(async () => {
|
||||
const { detectAdapter } = await import('$lib/platform-adapters')
|
||||
const { initPlatformService } = await import('$lib/platform-service')
|
||||
const { loadSettings } = await import('$lib/core/persistence/persist')
|
||||
const { startProbe } = await import('$lib/state/boot.svelte')
|
||||
onMount(() => {
|
||||
async function init() {
|
||||
const { detectAdapter } = await import('$lib/platform-adapters')
|
||||
const { initPlatformService } = await import('$lib/platform-service')
|
||||
const { loadSettings } = await import('$lib/core/persistence/persist')
|
||||
const { startProbe } = await import('$lib/state/boot.svelte')
|
||||
|
||||
const adapter = detectAdapter()
|
||||
initPlatformService(adapter)
|
||||
await adapter.init()
|
||||
appState.platform = adapter.platform
|
||||
appState.version = await platformService.getVersion().catch(() => '')
|
||||
appState.appDir = await platformService.getAppDir().catch(() => '')
|
||||
const adapter = detectAdapter()
|
||||
initPlatformService(adapter)
|
||||
await adapter.init()
|
||||
appState.platform = adapter.platform
|
||||
appState.version = await platformService.getVersion().catch(() => '')
|
||||
appState.appDir = await platformService.getAppDir().catch(() => '')
|
||||
|
||||
const persisted = await loadSettings()
|
||||
const raw = persisted?.settings ?? persisted ?? null
|
||||
await loadSettingsIntoState(raw)
|
||||
const persisted = await loadSettings()
|
||||
const raw = persisted?.settings ?? persisted ?? null
|
||||
await loadSettingsIntoState(raw)
|
||||
|
||||
const s = (raw ?? {}) as Record<string, unknown>
|
||||
appState.serverUrl = (s.serverUrl as string) ?? ''
|
||||
appState.authMode = (s.serverAuthMode as 'NONE' | 'BASIC_AUTH' | 'UI_LOGIN') ?? 'NONE'
|
||||
appState.authUser = (s.serverAuthUser as string) ?? ''
|
||||
appState.authPass = (s.serverAuthPass as string) ?? ''
|
||||
const s = (raw ?? {}) as Record<string, unknown>
|
||||
appState.serverUrl = (s.serverUrl as string) ?? ''
|
||||
appState.authMode = (s.serverAuthMode as 'NONE' | 'BASIC_AUTH' | 'UI_LOGIN') ?? 'NONE'
|
||||
appState.authUser = (s.serverAuthUser as string) ?? ''
|
||||
appState.authPass = (s.serverAuthPass as string) ?? ''
|
||||
|
||||
applyTheme(
|
||||
settingsState.settings.theme ?? 'dark',
|
||||
settingsState.settings.customThemes ?? [],
|
||||
)
|
||||
settingsLoaded = true
|
||||
|
||||
if (isTauri && settingsState.settings.autoStartServer) {
|
||||
platformService.launchServer({
|
||||
binary: settingsState.settings.serverBinary,
|
||||
binaryArgs: settingsState.settings.serverBinaryArgs,
|
||||
webUiEnabled: settingsState.settings.suwayomiWebUI,
|
||||
}).catch(() => {})
|
||||
applyTheme(
|
||||
settingsState.settings.theme ?? 'dark',
|
||||
settingsState.settings.customThemes ?? [],
|
||||
)
|
||||
|
||||
if (isTauri && settingsState.settings.autoStartServer) {
|
||||
platformService.launchServer({
|
||||
binary: settingsState.settings.serverBinary,
|
||||
binaryArgs: settingsState.settings.serverBinaryArgs,
|
||||
webUiEnabled: settingsState.settings.suwayomiWebUI,
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
startProbe(
|
||||
appState.authMode ?? 'NONE',
|
||||
appState.authUser ?? '',
|
||||
appState.authPass ?? '',
|
||||
isTauri && settingsState.settings.autoStartServer ? 2000 : 100,
|
||||
)
|
||||
|
||||
polling = true
|
||||
pollLoop()
|
||||
}
|
||||
|
||||
startProbe(
|
||||
appState.authMode ?? 'NONE',
|
||||
appState.authUser ?? '',
|
||||
appState.authPass ?? '',
|
||||
isTauri && settingsState.settings.autoStartServer ? 2000 : 100,
|
||||
)
|
||||
|
||||
polling = true
|
||||
pollLoop()
|
||||
init()
|
||||
|
||||
return () => {
|
||||
polling = false
|
||||
@@ -191,7 +204,7 @@
|
||||
|
||||
{#if splashVisible}
|
||||
<SplashScreen
|
||||
mode={appState.status === 'locked' ? 'locked' : 'loading'}
|
||||
mode={splashMode}
|
||||
{ringFull}
|
||||
failed={appState.status === 'error'}
|
||||
notConfigured={boot.notConfigured}
|
||||
|
||||
Reference in New Issue
Block a user