mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Chore: Fixed ServerURL & AppPin on WebUI
This commit is contained in:
@@ -251,7 +251,7 @@ modules:
|
|||||||
sources:
|
sources:
|
||||||
- type: git
|
- type: git
|
||||||
url: https://github.com/moku-project/Moku.git
|
url: https://github.com/moku-project/Moku.git
|
||||||
commit: b170a151f0213d1ade81b7543270fbe46bd2e8c5
|
commit: baece20f467d2c7d4cebaa9ea8892980aa93aa10
|
||||||
- type: file
|
- type: file
|
||||||
path: packaging/frontend-dist.tar.gz
|
path: packaging/frontend-dist.tar.gz
|
||||||
sha256: 676ec2273ffd9a69248849c5d51dc4d59a5d5b68fbba7a4fe7e7b572a5f25f14
|
sha256: 676ec2273ffd9a69248849c5d51dc4d59a5d5b68fbba7a4fe7e7b572a5f25f14
|
||||||
|
|||||||
+8
-16
@@ -9,15 +9,6 @@ import { historyState } from '$lib/state/history.svelt
|
|||||||
import { readerState } from '$lib/state/reader.svelte'
|
import { readerState } from '$lib/state/reader.svelte'
|
||||||
import { seriesState } from '$lib/state/series.svelte'
|
import { seriesState } from '$lib/state/series.svelte'
|
||||||
|
|
||||||
const KEY_URL = 'moku_server_url'
|
|
||||||
const KEY_AUTH = 'moku_auth_config'
|
|
||||||
|
|
||||||
interface SavedAuth {
|
|
||||||
mode: 'NONE' | 'BASIC_AUTH' | 'UI_LOGIN'
|
|
||||||
user?: string
|
|
||||||
pass?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
async function boot() {
|
async function boot() {
|
||||||
try {
|
try {
|
||||||
const platformAdapter = detectAdapter()
|
const platformAdapter = detectAdapter()
|
||||||
@@ -43,20 +34,21 @@ async function boot() {
|
|||||||
readerState.markers = libraryData.markers
|
readerState.markers = libraryData.markers
|
||||||
historyState.load(libraryData.sessions, libraryData.dailyReadCounts)
|
historyState.load(libraryData.sessions, libraryData.dailyReadCounts)
|
||||||
|
|
||||||
const savedUrl = (await platformAdapter.getCredential(KEY_URL)) ?? 'http://127.0.0.1:4567'
|
const savedUrl = settingsState.settings.serverUrl ?? 'http://127.0.0.1:4567'
|
||||||
const savedAuthRaw = await platformAdapter.getCredential(KEY_AUTH)
|
const authMode = settingsState.settings.serverAuthMode ?? 'NONE'
|
||||||
const savedAuth: SavedAuth = savedAuthRaw ? JSON.parse(savedAuthRaw) : { mode: 'NONE' }
|
const authUser = settingsState.settings.serverAuthUser || undefined
|
||||||
|
const authPass = settingsState.settings.serverAuthPass || undefined
|
||||||
|
|
||||||
appState.serverUrl = savedUrl
|
appState.serverUrl = savedUrl
|
||||||
appState.authMode = savedAuth.mode
|
appState.authMode = authMode === 'SIMPLE_LOGIN' ? 'UI_LOGIN' : authMode
|
||||||
|
|
||||||
configureAuth(savedUrl, savedAuth.mode, savedAuth.user, savedAuth.pass)
|
configureAuth(savedUrl, authMode, authUser, authPass)
|
||||||
|
|
||||||
await serverAdapter.connect({
|
await serverAdapter.connect({
|
||||||
baseUrl: savedUrl,
|
baseUrl: savedUrl,
|
||||||
credentials:
|
credentials:
|
||||||
savedAuth.mode === 'BASIC_AUTH' && savedAuth.user && savedAuth.pass
|
authMode === 'BASIC_AUTH' && authUser && authPass
|
||||||
? { username: savedAuth.user, password: savedAuth.pass }
|
? { username: authUser, password: authPass }
|
||||||
: undefined,
|
: undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -91,10 +91,11 @@
|
|||||||
const PHASE2_MS = 10000
|
const PHASE2_MS = 10000
|
||||||
|
|
||||||
function triggerExit(cb?: () => void) {
|
function triggerExit(cb?: () => void) {
|
||||||
if (exitLock) return
|
console.log('[splash] triggerExit called — exitLock:', exitLock, 'mode:', mode, 'cb:', cb?.name ?? String(cb))
|
||||||
|
if (exitLock) { console.log('[splash] triggerExit blocked by exitLock'); return }
|
||||||
exitLock = true
|
exitLock = true
|
||||||
exiting = true
|
exiting = true
|
||||||
setTimeout(() => cb?.(), EXIT_MS)
|
setTimeout(() => { console.log('[splash] triggerExit timeout — calling cb'); cb?.() }, EXIT_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
let animFrame = 0
|
let animFrame = 0
|
||||||
@@ -125,11 +126,13 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
console.log('[splash] ringFull effect — ringFull:', ringFull, 'mode:', mode, 'exitLock:', exitLock)
|
||||||
if (!ringFull || mode === 'locked') { exitLock = false; exiting = false; return }
|
if (!ringFull || mode === 'locked') { exitLock = false; exiting = false; return }
|
||||||
cancelAnimationFrame(animFrame)
|
cancelAnimationFrame(animFrame)
|
||||||
animFrame = 0
|
animFrame = 0
|
||||||
ringProg = 1
|
ringProg = 1
|
||||||
setTimeout(() => triggerExit(onReady), 650)
|
const t = setTimeout(() => { console.log('[splash] ringFull timeout firing — calling triggerExit(onReady)'); triggerExit(onReady) }, 650)
|
||||||
|
return () => { console.log('[splash] ringFull effect cleanup — cancelling timeout'); clearTimeout(t) }
|
||||||
})
|
})
|
||||||
|
|
||||||
function submitPin() {
|
function submitPin() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
const entries = $derived(
|
const entries = $derived(
|
||||||
historyState.sessions
|
historyState.sessions
|
||||||
.filter((s, i, arr) => arr.findIndex(x => x.mangaId === s.mangaId) === i)
|
.filter((s, i, arr) => arr.findIndex(x => x.mangaId === s.mangaId) === i)
|
||||||
.slice(0, 10)
|
.slice(0, 5)
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ export const appState = $state({
|
|||||||
history: [] as unknown[],
|
history: [] as unknown[],
|
||||||
toasts: [] as unknown[],
|
toasts: [] as unknown[],
|
||||||
appDir: '',
|
appDir: '',
|
||||||
|
authUser: '',
|
||||||
|
authPass: '',
|
||||||
idleSplash: false,
|
idleSplash: false,
|
||||||
devSplash: false,
|
devSplash: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,11 +33,8 @@ export async function initPlatform(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pinLockEnabled(): boolean {
|
function pinLockEnabled(): boolean {
|
||||||
return (
|
const pin = settingsState.settings.appLockPin
|
||||||
settingsState.settings.appLockEnabled === true &&
|
return typeof pin === 'string' && pin.length >= 4
|
||||||
typeof settingsState.settings.appLockPin === 'string' &&
|
|
||||||
settingsState.settings.appLockPin.length >= 4
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleProbeSuccess(gen: number) {
|
function handleProbeSuccess(gen: number) {
|
||||||
@@ -56,6 +53,7 @@ function handleAuthRequired(
|
|||||||
pass: string,
|
pass: string,
|
||||||
) {
|
) {
|
||||||
if (gen !== probeGeneration) return
|
if (gen !== probeGeneration) return
|
||||||
|
if (boot.skipped) return
|
||||||
boot.failed = false
|
boot.failed = false
|
||||||
appState.authMode = authMode
|
appState.authMode = authMode
|
||||||
|
|
||||||
@@ -93,13 +91,6 @@ export async function startProbe(
|
|||||||
const baseUrl = settingsState.settings.serverUrl ?? 'http://127.0.0.1:4567'
|
const baseUrl = settingsState.settings.serverUrl ?? 'http://127.0.0.1:4567'
|
||||||
configureAuth(baseUrl, authMode, user || undefined, pass || undefined)
|
configureAuth(baseUrl, authMode, user || undefined, pass || undefined)
|
||||||
|
|
||||||
if (appState.platform === 'web') {
|
|
||||||
boot.failed = true
|
|
||||||
appState.status = 'error'
|
|
||||||
startBackgroundProbe(gen, authMode, user, pass)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let tries = 0
|
let tries = 0
|
||||||
|
|
||||||
async function probe() {
|
async function probe() {
|
||||||
@@ -191,10 +182,9 @@ export function bypassBoot(
|
|||||||
user = '',
|
user = '',
|
||||||
pass = '',
|
pass = '',
|
||||||
) {
|
) {
|
||||||
const gen = probeGeneration
|
|
||||||
boot.loginRequired = false
|
boot.loginRequired = false
|
||||||
boot.sessionExpired = false
|
boot.sessionExpired = false
|
||||||
boot.skipped = true
|
boot.skipped = true
|
||||||
appState.status = 'ready'
|
appState.status = 'ready'
|
||||||
startBackgroundProbe(gen, authMode, user, pass)
|
startBackgroundProbe(probeGeneration, authMode, user, pass)
|
||||||
}
|
}
|
||||||
+58
-45
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { page } from '$app/stores'
|
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 { boot } from '$lib/state/boot.svelte'
|
||||||
import { notifications } from '$lib/state/notifications.svelte'
|
import { notifications } from '$lib/state/notifications.svelte'
|
||||||
import { settingsState, loadSettingsIntoState, updateSettings } from '$lib/state/settings.svelte'
|
import { settingsState, loadSettingsIntoState, updateSettings } from '$lib/state/settings.svelte'
|
||||||
@@ -34,16 +34,23 @@
|
|||||||
|
|
||||||
const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
|
const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
|
||||||
|
|
||||||
let splashDismissed = $state(false)
|
appState.status = 'booting' as AppStatus
|
||||||
let themeEditorOpen = $state(false)
|
|
||||||
let themeEditorId = $state<string | null>(null)
|
let splashDismissed = $state(false)
|
||||||
|
let settingsLoaded = $state(false)
|
||||||
|
let themeEditorOpen = $state(false)
|
||||||
|
let themeEditorId = $state<string | null>(null)
|
||||||
|
|
||||||
const splashVisible = $derived(
|
const splashVisible = $derived(
|
||||||
!splashDismissed ||
|
|
||||||
appState.status === 'booting' ||
|
appState.status === 'booting' ||
|
||||||
appState.status === 'locked' ||
|
appState.status === 'locked' ||
|
||||||
appState.status === 'error' ||
|
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')
|
const ringFull = $derived(appState.status === 'ready')
|
||||||
@@ -62,51 +69,57 @@
|
|||||||
const readerContainerized = $derived(settingsState.settings.readerContainerized ?? false)
|
const readerContainerized = $derived(settingsState.settings.readerContainerized ?? false)
|
||||||
const strippedLayout = $derived(isReaderRoute && !readerContainerized)
|
const strippedLayout = $derived(isReaderRoute && !readerContainerized)
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(() => {
|
||||||
const { detectAdapter } = await import('$lib/platform-adapters')
|
async function init() {
|
||||||
const { initPlatformService } = await import('$lib/platform-service')
|
const { detectAdapter } = await import('$lib/platform-adapters')
|
||||||
const { loadSettings } = await import('$lib/core/persistence/persist')
|
const { initPlatformService } = await import('$lib/platform-service')
|
||||||
const { startProbe } = await import('$lib/state/boot.svelte')
|
const { loadSettings } = await import('$lib/core/persistence/persist')
|
||||||
|
const { startProbe } = await import('$lib/state/boot.svelte')
|
||||||
|
|
||||||
const adapter = detectAdapter()
|
const adapter = detectAdapter()
|
||||||
initPlatformService(adapter)
|
initPlatformService(adapter)
|
||||||
await adapter.init()
|
await adapter.init()
|
||||||
appState.platform = adapter.platform
|
appState.platform = adapter.platform
|
||||||
appState.version = await platformService.getVersion().catch(() => '')
|
appState.version = await platformService.getVersion().catch(() => '')
|
||||||
appState.appDir = await platformService.getAppDir().catch(() => '')
|
appState.appDir = await platformService.getAppDir().catch(() => '')
|
||||||
|
|
||||||
const persisted = await loadSettings()
|
const persisted = await loadSettings()
|
||||||
const raw = persisted?.settings ?? persisted ?? null
|
const raw = persisted?.settings ?? persisted ?? null
|
||||||
await loadSettingsIntoState(raw)
|
await loadSettingsIntoState(raw)
|
||||||
|
|
||||||
const s = (raw ?? {}) as Record<string, unknown>
|
const s = (raw ?? {}) as Record<string, unknown>
|
||||||
appState.serverUrl = (s.serverUrl as string) ?? ''
|
appState.serverUrl = (s.serverUrl as string) ?? ''
|
||||||
appState.authMode = (s.serverAuthMode as 'NONE' | 'BASIC_AUTH' | 'UI_LOGIN') ?? 'NONE'
|
appState.authMode = (s.serverAuthMode as 'NONE' | 'BASIC_AUTH' | 'UI_LOGIN') ?? 'NONE'
|
||||||
appState.authUser = (s.serverAuthUser as string) ?? ''
|
appState.authUser = (s.serverAuthUser as string) ?? ''
|
||||||
appState.authPass = (s.serverAuthPass as string) ?? ''
|
appState.authPass = (s.serverAuthPass as string) ?? ''
|
||||||
|
|
||||||
applyTheme(
|
settingsLoaded = true
|
||||||
settingsState.settings.theme ?? 'dark',
|
|
||||||
settingsState.settings.customThemes ?? [],
|
|
||||||
)
|
|
||||||
|
|
||||||
if (isTauri && settingsState.settings.autoStartServer) {
|
applyTheme(
|
||||||
platformService.launchServer({
|
settingsState.settings.theme ?? 'dark',
|
||||||
binary: settingsState.settings.serverBinary,
|
settingsState.settings.customThemes ?? [],
|
||||||
binaryArgs: settingsState.settings.serverBinaryArgs,
|
)
|
||||||
webUiEnabled: settingsState.settings.suwayomiWebUI,
|
|
||||||
}).catch(() => {})
|
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(
|
init()
|
||||||
appState.authMode ?? 'NONE',
|
|
||||||
appState.authUser ?? '',
|
|
||||||
appState.authPass ?? '',
|
|
||||||
isTauri && settingsState.settings.autoStartServer ? 2000 : 100,
|
|
||||||
)
|
|
||||||
|
|
||||||
polling = true
|
|
||||||
pollLoop()
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
polling = false
|
polling = false
|
||||||
@@ -191,7 +204,7 @@
|
|||||||
|
|
||||||
{#if splashVisible}
|
{#if splashVisible}
|
||||||
<SplashScreen
|
<SplashScreen
|
||||||
mode={appState.status === 'locked' ? 'locked' : 'loading'}
|
mode={splashMode}
|
||||||
{ringFull}
|
{ringFull}
|
||||||
failed={appState.status === 'error'}
|
failed={appState.status === 'error'}
|
||||||
notConfigured={boot.notConfigured}
|
notConfigured={boot.notConfigured}
|
||||||
|
|||||||
Reference in New Issue
Block a user