mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-11 17:29:44 +00:00
Add loading animation to general settings
This commit is contained in:
parent
48e2e47f96
commit
7375122d40
@ -11,6 +11,7 @@
|
|||||||
} from "@/paraglide/runtime"
|
} from "@/paraglide/runtime"
|
||||||
import { appConfig } from "@/stores"
|
import { appConfig } from "@/stores"
|
||||||
import { Select, Switch } from "@kksh/svelte5"
|
import { Select, Switch } from "@kksh/svelte5"
|
||||||
|
import type { LoadingAnimation } from "@kksh/types"
|
||||||
import * as autoStart from "@tauri-apps/plugin-autostart"
|
import * as autoStart from "@tauri-apps/plugin-autostart"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { toast } from "svelte-sonner"
|
import { toast } from "svelte-sonner"
|
||||||
@ -19,12 +20,15 @@
|
|||||||
value: lang,
|
value: lang,
|
||||||
label: LanguageMap[lang] ?? lang
|
label: LanguageMap[lang] ?? lang
|
||||||
}))
|
}))
|
||||||
|
let loadingAnimation = $state<LoadingAnimation>("spinning-circle")
|
||||||
|
const loadingAnimations = ["spinning-circle", "kunkun-dancing"] as const
|
||||||
let launchAtLogin = $state(false)
|
let launchAtLogin = $state(false)
|
||||||
let language = $state(languageTag())
|
let language = $state(languageTag())
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
autoStart.isEnabled().then((enabled) => {
|
autoStart.isEnabled().then((enabled) => {
|
||||||
launchAtLogin = enabled
|
launchAtLogin = enabled
|
||||||
})
|
})
|
||||||
|
loadingAnimation = $appConfig.loadingAnimation
|
||||||
})
|
})
|
||||||
const triggerContent = $derived(languages.find((f) => f.value === language)?.label ?? "Language")
|
const triggerContent = $derived(languages.find((f) => f.value === language)?.label ?? "Language")
|
||||||
</script>
|
</script>
|
||||||
@ -101,6 +105,31 @@
|
|||||||
</Select.Content>
|
</Select.Content>
|
||||||
</Select.Root>
|
</Select.Root>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<span>Loading Animation</span>
|
||||||
|
|
||||||
|
<Select.Root type="single" name="loadingAnimation" bind:value={loadingAnimation}>
|
||||||
|
<Select.Trigger class="w-fit">
|
||||||
|
{loadingAnimation}
|
||||||
|
</Select.Trigger>
|
||||||
|
<Select.Content>
|
||||||
|
<Select.Group>
|
||||||
|
<Select.GroupHeading>Loading Animation</Select.GroupHeading>
|
||||||
|
{#each loadingAnimations as anim}
|
||||||
|
<Select.Item
|
||||||
|
onclick={() => {
|
||||||
|
appConfig.setLoadingAnimation(anim)
|
||||||
|
}}
|
||||||
|
value={anim}
|
||||||
|
label={anim}
|
||||||
|
>
|
||||||
|
{anim}
|
||||||
|
</Select.Item>
|
||||||
|
{/each}
|
||||||
|
</Select.Group>
|
||||||
|
</Select.Content>
|
||||||
|
</Select.Root>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getExtensionsFolder } from "@/constants"
|
import { getExtensionsFolder } from "@/constants"
|
||||||
import type { SearchPath } from "@kksh/api/models"
|
import type { SearchPath } from "@kksh/api/models"
|
||||||
import { updateTheme, type ThemeConfig } from "@kksh/svelte5"
|
import { updateTheme, type ThemeConfig } from "@kksh/svelte5"
|
||||||
import { PersistedAppConfig, type AppConfigState } from "@kksh/types"
|
import { LoadingAnimation, PersistedAppConfig, type AppConfigState } from "@kksh/types"
|
||||||
import { debug, error, info } from "@tauri-apps/plugin-log"
|
import { debug, error, info } from "@tauri-apps/plugin-log"
|
||||||
import * as os from "@tauri-apps/plugin-os"
|
import * as os from "@tauri-apps/plugin-os"
|
||||||
import { load } from "@tauri-apps/plugin-store"
|
import { load } from "@tauri-apps/plugin-store"
|
||||||
@ -29,7 +29,8 @@ export const defaultAppConfig: AppConfigState = {
|
|||||||
joinBetaProgram: false,
|
joinBetaProgram: false,
|
||||||
onBoarded: false,
|
onBoarded: false,
|
||||||
developerMode: false,
|
developerMode: false,
|
||||||
appSearchPaths: []
|
appSearchPaths: [],
|
||||||
|
loadingAnimation: "spinning-circle"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appConfigLoaded = writable(false)
|
export const appConfigLoaded = writable(false)
|
||||||
@ -99,6 +100,9 @@ class AppConfigStore extends Store<AppConfigState> implements AppConfigAPI {
|
|||||||
appSearchPaths: config.appSearchPaths.filter((path) => path.path !== appSearchPath.path)
|
appSearchPaths: config.appSearchPaths.filter((path) => path.path !== appSearchPath.path)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
setLoadingAnimation(loadingAnimation: LoadingAnimation) {
|
||||||
|
this.update((config) => ({ ...config, loadingAnimation }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// function createAppConfig(): WithSyncStore<AppConfigState & { language: string }> & AppConfigAPI {
|
// function createAppConfig(): WithSyncStore<AppConfigState & { language: string }> & AppConfigAPI {
|
||||||
|
@ -2,6 +2,9 @@ import { LightMode, SearchPath } from "@kksh/api/models"
|
|||||||
import type { Platform } from "@tauri-apps/plugin-os"
|
import type { Platform } from "@tauri-apps/plugin-os"
|
||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
|
|
||||||
|
export const LoadingAnimation = v.union([v.literal("spinning-circle"), v.literal("kunkun-dancing")])
|
||||||
|
export type LoadingAnimation = v.InferOutput<typeof LoadingAnimation>
|
||||||
|
|
||||||
export const PersistedAppConfig = v.object({
|
export const PersistedAppConfig = v.object({
|
||||||
theme: v.object({
|
theme: v.object({
|
||||||
theme: v.string(),
|
theme: v.string(),
|
||||||
@ -18,7 +21,8 @@ export const PersistedAppConfig = v.object({
|
|||||||
joinBetaProgram: v.boolean(),
|
joinBetaProgram: v.boolean(),
|
||||||
onBoarded: v.boolean(),
|
onBoarded: v.boolean(),
|
||||||
developerMode: v.boolean(),
|
developerMode: v.boolean(),
|
||||||
appSearchPaths: v.array(SearchPath)
|
appSearchPaths: v.array(SearchPath),
|
||||||
|
loadingAnimation: LoadingAnimation
|
||||||
})
|
})
|
||||||
|
|
||||||
export type PersistedAppConfig = v.InferOutput<typeof PersistedAppConfig>
|
export type PersistedAppConfig = v.InferOutput<typeof PersistedAppConfig>
|
||||||
|
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@ -1391,7 +1391,7 @@ importers:
|
|||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
valibot:
|
valibot:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0-beta.10
|
||||||
version: 1.0.0(typescript@5.6.3)
|
version: 1.0.0(typescript@5.6.3)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@rollup/plugin-typescript':
|
'@rollup/plugin-typescript':
|
||||||
@ -1457,8 +1457,8 @@ importers:
|
|||||||
specifier: ^5.3.3
|
specifier: ^5.3.3
|
||||||
version: 5.6.3
|
version: 5.6.3
|
||||||
valibot:
|
valibot:
|
||||||
specifier: 1.0.0
|
specifier: 1.0.0-beta.9
|
||||||
version: 1.0.0(typescript@5.6.3)
|
version: 1.0.0-beta.9(typescript@5.6.3)
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@ -11934,6 +11934,14 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
valibot@1.0.0-beta.9:
|
||||||
|
resolution: {integrity: sha512-yEX8gMAZ2R1yI2uwOO4NCtVnJQx36zn3vD0omzzj9FhcoblvPukENIiRZXKZwCnqSeV80bMm8wNiGhQ0S8fiww==}
|
||||||
|
peerDependencies:
|
||||||
|
typescript: '>=5'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
typescript:
|
||||||
|
optional: true
|
||||||
|
|
||||||
validate-npm-package-name@5.0.1:
|
validate-npm-package-name@5.0.1:
|
||||||
resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==}
|
resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==}
|
||||||
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
|
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
|
||||||
@ -25757,6 +25765,10 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 5.7.3
|
typescript: 5.7.3
|
||||||
|
|
||||||
|
valibot@1.0.0-beta.9(typescript@5.6.3):
|
||||||
|
optionalDependencies:
|
||||||
|
typescript: 5.6.3
|
||||||
|
|
||||||
validate-npm-package-name@5.0.1: {}
|
validate-npm-package-name@5.0.1: {}
|
||||||
|
|
||||||
validator@13.12.0:
|
validator@13.12.0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user