Enhance loading animation handling in FullScreenLoading component

- Integrated conditional rendering for loading animations based on app configuration.
- Updated default loading animation to "kunkun-dancing" in app configuration.
- Adjusted general settings to ensure proper type handling for language labels.
- Modified ui-iframe component to manage full-screen loading state more effectively.
This commit is contained in:
Huakun Shen 2025-03-28 05:39:08 -04:00
parent 36bb080e89
commit 830f3a4ea9
No known key found for this signature in database
5 changed files with 15 additions and 74 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { appState } from "@/stores" import { appConfig, appState } from "@/stores"
import { cn } from "@/utils" import { cn } from "@/utils"
import { Button } from "@kksh/svelte5" import { Button } from "@kksh/svelte5"
import { BorderBeam, Constants, Layouts, TauriLink } from "@kksh/ui" import { BorderBeam, Constants, Layouts, TauriLink } from "@kksh/ui"
@ -25,8 +25,13 @@
> >
<ArrowLeftIcon class="size-4" /> <ArrowLeftIcon class="size-4" />
</Button> </Button>
<Dance class="absolute z-50 h-screen opacity-20" /> {#if $appConfig.loadingAnimation === "kunkun-dancing"}
<LoaderCircleIcon class="h-24 w-24 animate-spin" /> <!-- <DanceTransition delay={300} autoHide={false} show={!uiControl.iframeLoaded} /> -->
<span class="font-mono">Loading</span> <Dance class="absolute z-50 h-screen opacity-20" />
{:else}
<!-- <LoadingAnimation delay={300} autoHide={false} show={!uiControl.iframeLoaded} /> -->
<LoaderCircleIcon class="h-24 w-24 animate-spin" />
<span class="font-mono">Loading</span>
{/if}
<BorderBeam size={150} duration={12} /> <BorderBeam size={150} duration={12} />
</Layouts.Center> </Layouts.Center>

View File

@ -18,7 +18,7 @@
const languages = availableLanguageTags.map((lang) => ({ const languages = availableLanguageTags.map((lang) => ({
value: lang, value: lang,
label: LanguageMap[lang] ?? lang label: LanguageMap[lang as keyof typeof LanguageMap] ?? lang
})) }))
let loadingAnimation = $state<LoadingAnimation>("spinning-circle") let loadingAnimation = $state<LoadingAnimation>("spinning-circle")
const loadingAnimations = ["spinning-circle", "kunkun-dancing"] as const const loadingAnimations = ["spinning-circle", "kunkun-dancing"] as const

View File

@ -30,7 +30,7 @@ export const defaultAppConfig: AppConfigState = {
onBoarded: false, onBoarded: false,
developerMode: false, developerMode: false,
appSearchPaths: [], appSearchPaths: [],
loadingAnimation: "spinning-circle" loadingAnimation: "kunkun-dancing"
} }
export const appConfigLoaded = writable(false) export const appConfigLoaded = writable(false)
@ -105,72 +105,6 @@ class AppConfigStore extends Store<AppConfigState> implements AppConfigAPI {
} }
} }
// function createAppConfig(): WithSyncStore<AppConfigState & { language: string }> & AppConfigAPI {
// const store = createTauriSyncStore("app-config", defaultAppConfig)
// async function init() {
// debug("Initializing app config")
// const persistStore = await load("kk-config.json", { autoSave: true })
// let loadedConfig = await persistStore.get("config")
// if (typeof loadedConfig === "object") {
// loadedConfig = { ...defaultAppConfig, ...loadedConfig }
// }
// const parseRes = v.safeParse(PersistedAppConfig, loadedConfig)
// if (parseRes.success) {
// console.log("Parse Persisted App Config Success", parseRes.output)
// const extensionsInstallDir = await getExtensionsFolder()
// store.update((config) => ({
// ...config,
// ...parseRes.output,
// isInitialized: true,
// extensionsInstallDir,
// platform: os.platform()
// }))
// } else {
// error("Failed to parse app config, going to remove it and reinitialize")
// console.error(v.flatten<typeof PersistedAppConfig>(parseRes.issues))
// await persistStore.clear()
// await persistStore.set("config", v.parse(PersistedAppConfig, defaultAppConfig))
// }
// store.subscribe(async (config) => {
// console.log("Saving app config", config)
// await persistStore.set("config", config)
// updateTheme(config.theme)
// })
// }
// return {
// ...store,
// get: () => get(store),
// setTheme: (theme: ThemeConfig) => store.update((config) => ({ ...config, theme })),
// setDevExtensionPath: (devExtensionPath: string | null) => {
// console.log("setDevExtensionPath", devExtensionPath)
// store.update((config) => ({ ...config, devExtensionPath }))
// },
// setTriggerHotkey: (triggerHotkey: string[]) => {
// store.update((config) => ({ ...config, triggerHotkey }))
// },
// setOnBoarded: (onBoarded: boolean) => {
// store.update((config) => ({ ...config, onBoarded }))
// },
// setLanguage: (language: string) => {
// store.update((config) => ({ ...config, language }))
// },
// addAppSearchPath: (appSearchPath: SearchPath) => {
// store.update((config) => ({
// ...config,
// appSearchPaths: [...config.appSearchPaths, appSearchPath]
// }))
// },
// removeAppSearchPath: (appSearchPath: SearchPath) => {
// store.update((config) => ({
// ...config,
// appSearchPaths: config.appSearchPaths.filter((path) => path.path !== appSearchPath.path)
// }))
// },
// init
// }
// }
// export const appConfig = createAppConfig() // export const appConfig = createAppConfig()
export const appConfig = new AppConfigStore() export const appConfig = new AppConfigStore()

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import DanceTransition from "@/components/dance/dance-transition.svelte" import DanceTransition from "@/components/dance/dance-transition.svelte"
import { i18n } from "@/i18n" import { i18n } from "@/i18n"
import { appConfig, winExtMap } from "@/stores" import { appConfig, appState, winExtMap } from "@/stores"
import { helperAPI } from "@/utils/helper" import { helperAPI } from "@/utils/helper"
import { paste } from "@/utils/hotkey" import { paste } from "@/utils/hotkey"
import { goBackOnEscape } from "@/utils/key" import { goBackOnEscape } from "@/utils/key"
@ -163,10 +163,12 @@
setTimeout(() => { setTimeout(() => {
iframeRef.focus() iframeRef.focus()
uiControl.iframeLoaded = true uiControl.iframeLoaded = true
appState.setFullScreenLoading(false)
}, 300) }, 300)
} }
onMount(() => { onMount(() => {
appState.setFullScreenLoading(true)
setTimeout(() => { setTimeout(() => {
appWin.show() appWin.show()
}, 200) }, 200)
@ -238,7 +240,6 @@
{/if} {/if}
<main class="h-screen"> <main class="h-screen">
<DanceTransition delay={300} autoHide={false} show={!uiControl.iframeLoaded} />
<iframe <iframe
bind:this={iframeRef} bind:this={iframeRef}
class={cn("h-full", { class={cn("h-full", {

View File

@ -11,6 +11,7 @@ import { toast } from "svelte-sonner"
import * as v from "valibot" import * as v from "valibot"
import { z } from "zod" import { z } from "zod"
import type { PageLoad } from "./$types" import type { PageLoad } from "./$types"
import { appState } from "@/stores/appState"
export const load: PageLoad = async ({ export const load: PageLoad = async ({
url, url,