feat: move all pages to app folder, add splashscreen

This commit is contained in:
Huakun Shen 2024-12-20 08:54:05 -05:00
parent 80ad705f7c
commit aa512af074
No known key found for this signature in database
26 changed files with 387 additions and 331 deletions

View File

@ -2,7 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main*"],
"windows": ["main*", "splashscreen"],
"permissions": [
{
"identifier": "http:default",

View File

@ -53,7 +53,13 @@ impl<R: Runtime> WindowExt for WebviewWindow<R> {
}
pub fn setup_window<R: Runtime>(app: &AppHandle<R>) {
let window = app.get_webview_window("main").unwrap();
#[cfg(target_os = "macos")]
window.set_transparent_titlebar(true, true);
{
app.get_webview_window("main")
.unwrap()
.set_transparent_titlebar(true, true);
app.get_webview_window("splashscreen")
.unwrap()
.set_transparent_titlebar(true, true);
}
}

View File

@ -4,9 +4,17 @@
"windows": [
{
"hiddenTitle": true,
"url": "/app",
"title": "Kunkun",
"width": 800,
"height": 600,
"visible": false,
"decorations": false
},
{
"url": "/splashscreen",
"label": "splashscreen",
"visible": false,
"decorations": false
}
]

View File

@ -4,9 +4,16 @@
"windows": [
{
"hiddenTitle": true,
"url": "/app",
"title": "Kunkun",
"width": 800,
"visible": false,
"height": 600
},
{
"url": "/splashscreen",
"visible": false,
"label": "splashscreen"
}
]
}

View File

@ -4,9 +4,17 @@
"windows": [
{
"hiddenTitle": true,
"url": "/app",
"title": "Kunkun",
"width": 800,
"height": 600,
"visible": false,
"decorations": false
},
{
"url": "/splashscreen",
"label": "splashscreen",
"visible": false,
"decorations": false
}
]

View File

@ -13,7 +13,6 @@ import { derived } from "svelte/store"
import * as clipboard from "tauri-plugin-clipboard-api"
import { open } from "tauri-plugin-shellx-api"
import { v4 as uuidv4 } from "uuid"
import { hexColor } from "valibot"
export const rawBuiltinCmds: BuiltinCmd[] = [
{
@ -25,7 +24,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Go to Extension Store",
function: async () => {
appState.clearSearchTerm()
goto("/extension/store")
goto("/appextension/store")
}
},
{
@ -36,7 +35,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "",
function: async () => {
goto("/auth")
goto("/appauth")
}
},
{
@ -81,7 +80,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "",
function: async () => {
goto("/extension/file-transfer")
goto("/appextension/file-transfer")
appState.clearSearchTerm()
}
},
@ -95,7 +94,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/settings/add-dev-extension")
goto("/appsettings/add-dev-extension")
}
},
{
@ -120,7 +119,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
function: async () => {
// const appStateStore = useAppStateStore()
appState.clearSearchTerm()
goto("/settings/set-dev-ext-path")
goto("/appsettings/set-dev-ext-path")
}
},
{
@ -132,7 +131,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
// goto("/window-troubleshooter")
// goto("/appwindow-troubleshooter")
const winLabel = `main:extension-window-troubleshooter-${uuidv4()}`
console.log(winLabel)
new WebviewWindow(winLabel, {
@ -151,7 +150,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/extension/permission-inspector")
goto("/appextension/permission-inspector")
},
keywords: ["extension"]
},
@ -164,7 +163,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/troubleshooters/extension-loading")
goto("/apptroubleshooters/extension-loading")
},
keywords: ["extension", "troubleshooter"]
},
@ -177,7 +176,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Create a Quicklink",
function: async () => {
appState.clearSearchTerm()
goto("/extension/create-quick-link")
goto("/appextension/create-quick-link")
}
},
{
@ -188,7 +187,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "Open Settings",
function: async () => {
goto("/settings")
goto("/appsettings")
appState.clearSearchTerm()
}
},
@ -248,7 +247,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "Dance",
function: async () => {
goto("/dance")
goto("/appdance")
}
},
{
@ -289,7 +288,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Clipboard History",
function: async () => {
appState.clearSearchTerm()
goto("/extension/clipboard")
goto("/appextension/clipboard")
}
},
{
@ -326,7 +325,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "MDNS Debugger",
function: async () => {
goto("/troubleshooters/mdns-debugger")
goto("/apptroubleshooters/mdns-debugger")
},
flags: {
developer: true

View File

@ -87,7 +87,7 @@
async function pickExtFiles() {
if (!$appConfig.devExtensionPath) {
toast.warning("Please set the dev extension path in the settings")
return goto("/settings/set-dev-ext-path")
return goto("/appsettings/set-dev-ext-path")
}
const selected = await openFileSelector({
directory: false,

View File

@ -17,7 +17,7 @@
toast.warning(
"Please set the dev extension path in the settings to install tarball extension"
)
return goto("/settings/set-dev-ext-path")
return goto("/appsettings/set-dev-ext-path")
}
await extensions
.installFromNpmPackageName(data.name, $appConfig.devExtensionPath)

View File

@ -19,7 +19,7 @@
toast.warning(
"Please set the dev extension path in the settings to install tarball extension"
)
return goto("/settings/set-dev-ext-path")
return goto("/appsettings/set-dev-ext-path")
}
await extensions
.installFromTarballUrl(data.url, $appConfig.devExtensionPath)

View File

@ -59,7 +59,7 @@ export async function handleKunkunProtocol(parsedUrl: URL) {
if (parsed.identifier) {
goto(`/extension/store/${parsed.identifier}`)
} else {
goto("/extension/store")
goto("/appextension/store")
}
} else if (href.startsWith(DEEP_LINK_PATH_REFRESH_DEV_EXTENSION)) {
emitRefreshDevExt()

View File

@ -76,7 +76,7 @@ export async function globalKeyDownHandler(e: KeyboardEvent) {
if ((_platform === "macos" && e.metaKey) || (_platform === "windows" && e.ctrlKey)) {
if (e.key === ",") {
e.preventDefault()
goto("/settings")
goto("/appsettings")
}
}
// Toggle Devtools with control + shift + I

View File

@ -7,7 +7,7 @@ export function goBack() {
}
export function goHome() {
goto("/")
goto("/app")
}
export function goHomeOrCloseDependingOnWindow() {

View File

@ -1,117 +1,11 @@
<script lang="ts">
import AppContext from "@/components/context/AppContext.svelte"
import "../app.css"
import { appConfig, appState, extensions, quickLinks, winExtMap } from "@/stores"
import { initDeeplink } from "@/utils/deeplink"
import { updateAppHotkey } from "@/utils/hotkey"
import { globalKeyDownHandler, goBackOrCloseOnEscape } from "@/utils/key"
import { listenToWindowBlur } from "@/utils/tauri-events"
import { isInMainWindow } from "@/utils/window"
import { listenToKillProcessEvent, listenToRecordExtensionProcessEvent } from "@kksh/api/events"
import {
Button,
ModeWatcher,
themeConfigStore,
ThemeWrapper,
updateTheme,
type ThemeConfig
} from "@kksh/svelte5"
import { Constants, ViewTransition } from "@kksh/ui"
import type { UnlistenFn } from "@tauri-apps/api/event"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
import { attachConsole, error, info } from "@tauri-apps/plugin-log"
import { afterNavigate, beforeNavigate } from "$app/navigation"
import { gsap } from "gsap"
import { Flip } from "gsap/Flip"
import { onDestroy, onMount } from "svelte"
import { toast, Toaster } from "svelte-sonner"
import * as shellx from "tauri-plugin-shellx-api"
/* -------------------------------------------------------------------------- */
/* Gsap Flip Animation */
/* -------------------------------------------------------------------------- */
gsap.registerPlugin(Flip)
let flipState: Flip.FlipState
beforeNavigate(() => {
flipState = Flip.getState(
`.${Constants.CLASSNAMES.EXT_LOGO}, .${Constants.CLASSNAMES.BACK_BUTTON}`
)
})
afterNavigate(() => {
if (!flipState) {
return
}
Flip.from(flipState, {
targets: `.${Constants.CLASSNAMES.EXT_LOGO}, .${Constants.CLASSNAMES.BACK_BUTTON}`,
duration: 0.5,
absolute: true,
scale: true,
ease: "ease-out"
})
})
import { ModeWatcher, ThemeWrapper } from "@kksh/svelte5"
let { children } = $props()
const unlisteners: UnlistenFn[] = []
onDestroy(() => {
unlisteners.forEach((unlistener) => unlistener())
})
onMount(async () => {
attachConsole().then((unlistener) => unlisteners.push(unlistener))
initDeeplink().then((unlistener) => unlisteners.push(unlistener))
shellx
.fixPathEnv()
.then(() => {
info("fixed path env")
})
.catch(error)
quickLinks.init()
appConfig.init()
if (isInMainWindow()) {
if ($appConfig.triggerHotkey) {
updateAppHotkey($appConfig.triggerHotkey)
}
unlisteners.push(
await listenToWindowBlur(() => {
const win = getCurrentWebviewWindow()
win.isFocused().then((isFocused) => {
// this extra is focused check may be needed because blur event got triggered somehow when window show()
// for edge case: when settings page is opened and focused, switch to main window, the blur event is triggered for main window
if (!isFocused) {
if ($appConfig.hideOnBlur) {
win.hide()
}
}
})
})
)
extensions.init()
unlisteners.push(
await listenToRecordExtensionProcessEvent(async (event) => {
console.log("record extension process event", event)
winExtMap.registerProcess(event.payload.windowLabel, event.payload.pid)
})
)
unlisteners.push(
await listenToKillProcessEvent((event) => {
console.log("kill process event", event)
winExtMap.unregisterProcess(event.payload.pid)
})
)
} else {
}
getCurrentWebviewWindow().show()
})
</script>
<svelte:window on:keydown={globalKeyDownHandler} />
<ViewTransition />
<ModeWatcher />
<Toaster richColors />
<AppContext {appConfig} {appState}>
<ThemeWrapper>
{@render children()}
</ThemeWrapper>
</AppContext>
<ThemeWrapper>
{@render children()}
</ThemeWrapper>

View File

@ -1,13 +1,5 @@
import { getExtensionsFolder, IS_IN_TAURI } from "@/constants"
import { error } from "@tauri-apps/plugin-log"
import type { LayoutLoad } from "./$types"
// Tauri doesn't have a Node.js server to do proper SSR
// so we will use adapter-static to prerender the app (SSG)
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
export const prerender = true
export const ssr = false
export const load: LayoutLoad = async () => {
return { extsInstallDir: IS_IN_TAURI ? await getExtensionsFolder() : "" }
}

View File

@ -1,176 +1 @@
<!-- This file renders the main command palette, a list of commands -->
<script lang="ts">
import { commandLaunchers } from "@/cmds"
import { builtinCmds } from "@/cmds/builtin"
import { systemCommands } from "@/cmds/system"
import { appConfig, appState, devStoreExts, installedStoreExts, quickLinks } from "@/stores"
import { cmdQueries } from "@/stores/cmdQuery"
import { isKeyboardEventFromInputElement } from "@/utils/dom"
import Icon from "@iconify/svelte"
import { toggleDevTools } from "@kksh/api/commands"
import { Button, Command, DropdownMenu } from "@kksh/svelte5"
import {
BuiltinCmds,
CustomCommandInput,
ExtCmdsGroup,
GlobalCommandPaletteFooter,
QuickLinks,
SystemCmds
} from "@kksh/ui/main"
import type { CmdValue } from "@kksh/ui/types"
import { cn, commandScore } from "@kksh/ui/utils"
import { convertFileSrc } from "@tauri-apps/api/core"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
import { exit } from "@tauri-apps/plugin-process"
import { ArrowBigUpIcon, CircleXIcon, EllipsisVerticalIcon, RefreshCcwIcon } from "lucide-svelte"
import { onMount } from "svelte"
import { hasCommand, whereIsCommand } from "tauri-plugin-shellx-api"
let inputEle: HTMLInputElement | null = null
function onKeyDown(event: KeyboardEvent) {
if (event.key === "Escape") {
;(event.target as HTMLInputElement).value = ""
$appState.searchTerm = ""
}
}
// let imgSrc = convertFileSrc("/?id=15", "cbimg")
</script>
<svelte:window
on:keydown={(e) => {
if (e.key === "/") {
if (isKeyboardEventFromInputElement(e)) {
e.preventDefault()
} else {
e.preventDefault()
inputEle?.focus()
}
}
}}
/>
<!-- <pre>{imgSrc}</pre>
<img class="border-2 border-red-500 w-64" src={imgSrc} alt="test" /> -->
<Command.Root
class={cn("h-screen rounded-lg border shadow-md")}
bind:value={$appState.highlightedCmd}
filter={(value, search, keywords) => {
return commandScore(
value.startsWith("{") ? (JSON.parse(value) as CmdValue).cmdName : value,
search,
keywords
)
}}
loop
>
<CustomCommandInput
autofocus
bind:ref={inputEle}
id="main-command-input"
placeholder={$cmdQueries.length === 0 ? "Type a command or search..." : undefined}
bind:value={$appState.searchTerm}
onkeydown={onKeyDown}
>
{#snippet rightSlot()}
<span
class={cn("absolute flex space-x-2")}
style={`left: ${$appState.searchTerm.length + 3}ch`}
>
{#each $cmdQueries as cmdQuery}
{@const queryWidth = Math.max(cmdQuery.name.length, cmdQuery.value.length) + 2}
<input
class="bg-muted rounded-md border border-gray-300 pl-2 font-mono focus:outline-none dark:border-gray-600"
type="text"
placeholder={cmdQuery.name}
style={`width: ${queryWidth}ch`}
onkeydown={(evt) => {
if (evt.key === "Enter") {
evt.preventDefault()
evt.stopPropagation()
commandLaunchers.onQuickLinkSelect(
JSON.parse($appState.highlightedCmd),
$cmdQueries
)
}
}}
bind:value={cmdQuery.value}
/>
{/each}
</span>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button variant="outline" size="icon"><EllipsisVerticalIcon /></Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content class="w-80">
<DropdownMenu.Group>
<DropdownMenu.Item onclick={() => exit()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Quit
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => getCurrentWebviewWindow().hide()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Close Window
</DropdownMenu.Item>
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Group>
<DropdownMenu.GroupHeading data-tauri-drag-region>Developer</DropdownMenu.GroupHeading>
<DropdownMenu.Item onclick={toggleDevTools}>
<Icon icon="mingcute:code-fill" class="mr-2 h-5 w-5 text-green-500" />
Toggle Devtools
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+I</span
></DropdownMenu.Shortcut
>
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => location.reload()}>
<RefreshCcwIcon class="mr-2 h-4 w-4 text-green-500" />
Reload Window
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+R</span
></DropdownMenu.Shortcut
>
</DropdownMenu.Item>
<DropdownMenu.Item
onclick={() => {
appConfig.update((config) => ({ ...config, hmr: !config.hmr }))
}}
>
<Icon
icon={$appConfig.hmr ? "fontisto:toggle-on" : "fontisto:toggle-off"}
class={cn("mr-1 h-5 w-5", { "text-green-500": $appConfig.hmr })}
/>
Toggle Dev Extension HMR
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu.Root>
{/snippet}
</CustomCommandInput>
<Command.List class="max-h-screen grow">
<Command.Empty data-tauri-drag-region>No results found.</Command.Empty>
{#if $appConfig.extensionsInstallDir && $devStoreExts.length > 0}
<ExtCmdsGroup
extensions={$devStoreExts}
heading="Dev Extensions"
isDev={true}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}
hmr={$appConfig.hmr}
/>
{/if}
{#if $appConfig.extensionsInstallDir && $installedStoreExts.length > 0}
<ExtCmdsGroup
extensions={$installedStoreExts}
heading="Extensions"
isDev={false}
hmr={false}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}
/>
{/if}
<QuickLinks quickLinks={$quickLinks} />
<BuiltinCmds builtinCmds={$builtinCmds} />
<SystemCmds {systemCommands} />
</Command.List>
<GlobalCommandPaletteFooter />
</Command.Root>
<h1 class="text-red-500">Root</h1>

View File

@ -0,0 +1,107 @@
<script lang="ts">
import AppContext from "@/components/context/AppContext.svelte"
import { appConfig, appState, extensions, quickLinks, winExtMap } from "@/stores"
import { initDeeplink } from "@/utils/deeplink"
import { updateAppHotkey } from "@/utils/hotkey"
import { globalKeyDownHandler, goBackOrCloseOnEscape } from "@/utils/key"
import { listenToWindowBlur } from "@/utils/tauri-events"
import { isInMainWindow } from "@/utils/window"
import { listenToKillProcessEvent, listenToRecordExtensionProcessEvent } from "@kksh/api/events"
import { Constants, ViewTransition } from "@kksh/ui"
import type { UnlistenFn } from "@tauri-apps/api/event"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
import { attachConsole, error, info } from "@tauri-apps/plugin-log"
import { afterNavigate, beforeNavigate } from "$app/navigation"
import { gsap } from "gsap"
import { Flip } from "gsap/Flip"
import { onDestroy, onMount } from "svelte"
import { toast, Toaster } from "svelte-sonner"
import * as shellx from "tauri-plugin-shellx-api"
/* -------------------------------------------------------------------------- */
/* Gsap Flip Animation */
/* -------------------------------------------------------------------------- */
gsap.registerPlugin(Flip)
let flipState: Flip.FlipState
beforeNavigate(() => {
flipState = Flip.getState(
`.${Constants.CLASSNAMES.EXT_LOGO}, .${Constants.CLASSNAMES.BACK_BUTTON}`
)
})
afterNavigate(() => {
if (!flipState) {
return
}
Flip.from(flipState, {
targets: `.${Constants.CLASSNAMES.EXT_LOGO}, .${Constants.CLASSNAMES.BACK_BUTTON}`,
duration: 0.5,
absolute: true,
scale: true,
ease: "ease-out"
})
})
let { children } = $props()
const unlisteners: UnlistenFn[] = []
onDestroy(() => {
unlisteners.forEach((unlistener) => unlistener())
})
onMount(async () => {
console.log("root layout onMount")
attachConsole().then((unlistener) => unlisteners.push(unlistener))
initDeeplink().then((unlistener) => unlisteners.push(unlistener))
shellx
.fixPathEnv()
.then(() => {
info("fixed path env")
})
.catch(error)
quickLinks.init()
appConfig.init()
if (isInMainWindow()) {
if ($appConfig.triggerHotkey) {
updateAppHotkey($appConfig.triggerHotkey)
}
unlisteners.push(
await listenToWindowBlur(() => {
const win = getCurrentWebviewWindow()
win.isFocused().then((isFocused) => {
// this extra is focused check may be needed because blur event got triggered somehow when window show()
// for edge case: when settings page is opened and focused, switch to main window, the blur event is triggered for main window
if (!isFocused) {
if ($appConfig.hideOnBlur) {
win.hide()
}
}
})
})
)
extensions.init()
unlisteners.push(
await listenToRecordExtensionProcessEvent(async (event) => {
console.log("record extension process event", event)
winExtMap.registerProcess(event.payload.windowLabel, event.payload.pid)
})
)
unlisteners.push(
await listenToKillProcessEvent((event) => {
console.log("kill process event", event)
winExtMap.unregisterProcess(event.payload.pid)
})
)
} else {
}
getCurrentWebviewWindow().show()
})
</script>
<svelte:window on:keydown={globalKeyDownHandler} />
<ViewTransition />
<Toaster richColors />
<AppContext {appConfig} {appState}>
{@render children()}
</AppContext>

View File

@ -0,0 +1,7 @@
import { getExtensionsFolder, IS_IN_TAURI } from "@/constants"
import { error } from "@tauri-apps/plugin-log"
import type { LayoutLoad } from "./$types"
export const load: LayoutLoad = async () => {
return { extsInstallDir: IS_IN_TAURI ? await getExtensionsFolder() : "" }
}

View File

@ -0,0 +1,183 @@
<!-- This file renders the main command palette, a list of commands -->
<script lang="ts">
import { commandLaunchers } from "@/cmds"
import { builtinCmds } from "@/cmds/builtin"
import { systemCommands } from "@/cmds/system"
import { appConfig, appState, devStoreExts, installedStoreExts, quickLinks } from "@/stores"
import { cmdQueries } from "@/stores/cmdQuery"
import { isKeyboardEventFromInputElement } from "@/utils/dom"
import Icon from "@iconify/svelte"
import { toggleDevTools } from "@kksh/api/commands"
import { Button, Command, DropdownMenu } from "@kksh/svelte5"
import {
BuiltinCmds,
CustomCommandInput,
ExtCmdsGroup,
GlobalCommandPaletteFooter,
QuickLinks,
SystemCmds
} from "@kksh/ui/main"
import type { CmdValue } from "@kksh/ui/types"
import { cn, commandScore } from "@kksh/ui/utils"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
import { getCurrentWindow, Window } from "@tauri-apps/api/window"
import { exit } from "@tauri-apps/plugin-process"
import { ArrowBigUpIcon, CircleXIcon, EllipsisVerticalIcon, RefreshCcwIcon } from "lucide-svelte"
import { onMount } from "svelte"
import { hasCommand, whereIsCommand } from "tauri-plugin-shellx-api"
let inputEle: HTMLInputElement | null = $state(null)
function onKeyDown(event: KeyboardEvent) {
if (event.key === "Escape") {
;(event.target as HTMLInputElement).value = ""
$appState.searchTerm = ""
}
}
onMount(() => {
Promise.all([Window.getByLabel("splashscreen"), getCurrentWindow()]).then(
([splashscreenWin, mainWin]) => {
mainWin.show()
if (splashscreenWin) {
splashscreenWin.close()
}
}
)
})
</script>
<svelte:window
on:keydown={(e) => {
if (e.key === "/") {
if (isKeyboardEventFromInputElement(e)) {
e.preventDefault()
} else {
e.preventDefault()
inputEle?.focus()
}
}
}}
/>
<Command.Root
class={cn("h-screen rounded-lg border shadow-md")}
bind:value={$appState.highlightedCmd}
filter={(value, search, keywords) => {
return commandScore(
value.startsWith("{") ? (JSON.parse(value) as CmdValue).cmdName : value,
search,
keywords
)
}}
loop
>
<CustomCommandInput
autofocus
bind:ref={inputEle}
id="main-command-input"
placeholder={$cmdQueries.length === 0 ? "Type a command or search..." : undefined}
bind:value={$appState.searchTerm}
onkeydown={onKeyDown}
>
{#snippet rightSlot()}
<span
class={cn("absolute flex space-x-2")}
style={`left: ${$appState.searchTerm.length + 3}ch`}
>
{#each $cmdQueries as cmdQuery}
{@const queryWidth = Math.max(cmdQuery.name.length, cmdQuery.value.length) + 2}
<input
class="bg-muted rounded-md border border-gray-300 pl-2 font-mono focus:outline-none dark:border-gray-600"
type="text"
placeholder={cmdQuery.name}
style={`width: ${queryWidth}ch`}
onkeydown={(evt) => {
if (evt.key === "Enter") {
evt.preventDefault()
evt.stopPropagation()
commandLaunchers.onQuickLinkSelect(
JSON.parse($appState.highlightedCmd),
$cmdQueries
)
}
}}
bind:value={cmdQuery.value}
/>
{/each}
</span>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button variant="outline" size="icon"><EllipsisVerticalIcon /></Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content class="w-80">
<DropdownMenu.Group>
<DropdownMenu.Item onclick={() => exit()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Quit
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => getCurrentWebviewWindow().hide()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Close Window
</DropdownMenu.Item>
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Group>
<DropdownMenu.GroupHeading data-tauri-drag-region>Developer</DropdownMenu.GroupHeading>
<DropdownMenu.Item onclick={toggleDevTools}>
<Icon icon="mingcute:code-fill" class="mr-2 h-5 w-5 text-green-500" />
Toggle Devtools
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+I</span
></DropdownMenu.Shortcut
>
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => location.reload()}>
<RefreshCcwIcon class="mr-2 h-4 w-4 text-green-500" />
Reload Window
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+R</span
></DropdownMenu.Shortcut
>
</DropdownMenu.Item>
<DropdownMenu.Item
onclick={() => {
appConfig.update((config) => ({ ...config, hmr: !config.hmr }))
}}
>
<Icon
icon={$appConfig.hmr ? "fontisto:toggle-on" : "fontisto:toggle-off"}
class={cn("mr-1 h-5 w-5", { "text-green-500": $appConfig.hmr })}
/>
Toggle Dev Extension HMR
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu.Root>
{/snippet}
</CustomCommandInput>
<Command.List class="max-h-screen grow">
<Command.Empty data-tauri-drag-region>No results found.</Command.Empty>
{#if $appConfig.extensionsInstallDir && $devStoreExts.length > 0}
<ExtCmdsGroup
extensions={$devStoreExts}
heading="Dev Extensions"
isDev={true}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}
hmr={$appConfig.hmr}
/>
{/if}
{#if $appConfig.extensionsInstallDir && $installedStoreExts.length > 0}
<ExtCmdsGroup
extensions={$installedStoreExts}
heading="Extensions"
isDev={false}
hmr={false}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}
/>
{/if}
<QuickLinks quickLinks={$quickLinks} />
<BuiltinCmds builtinCmds={$builtinCmds} />
<SystemCmds {systemCommands} />
</Command.List>
<GlobalCommandPaletteFooter />
</Command.Root>

View File

@ -44,7 +44,7 @@
function onSignOut() {
auth
.signOut()
.then(() => goto("/auth"))
.then(() => goto("/appauth"))
.catch((err) => toast.error("Failed to sign out", { description: err.message }))
}
</script>
@ -56,7 +56,7 @@
size="icon"
onclick={() => {
console.log("go Home")
goto("/")
goto("/app")
}}
>
<ArrowLeft class="size-4" />

View File

@ -5,7 +5,7 @@
function handleKeyDown(event: KeyboardEvent) {
if (event.key === "Enter") {
goto("/")
goto("/app")
}
}
</script>
@ -17,7 +17,7 @@
title="Fail to Load Extension"
class="w-fit max-w-screen-sm border-2 border-red-500"
message={$page.error?.message ?? "Unknown Error"}
onGoBack={() => goto("/")}
onGoBack={() => goto("/app")}
rawJsonError={JSON.stringify($page, null, 2)}
/>
</Layouts.Center>

View File

@ -136,7 +136,7 @@
function handleKeydown(e: KeyboardEvent) {
if (e.key === "Escape") {
if (!delayedImageDialogOpen) {
goto("/extension/store")
goto("/appextension/store")
}
}
}
@ -148,7 +148,7 @@
size="icon"
class={cn("fixed left-3 top-3", Constants.CLASSNAMES.BACK_BUTTON)}
data-flip-id={Constants.CLASSNAMES.BACK_BUTTON}
onclick={() => goto("/extension/store")}
onclick={() => goto("/appextension/store")}
>
<ArrowLeftIcon />
</Button>

View File

@ -51,7 +51,7 @@
const iframeUiAPI: IUiIframeServer2 = {
goBack: async () => {
if (isInMainWindow()) {
goto("/")
goto("/app")
} else {
appWin.close()
}

View File

@ -24,7 +24,7 @@ export const load: PageLoad = async ({
if (!_extPath || !_extUrl) {
toast.error("Invalid extension path or url")
error("Invalid extension path or url")
goto("/")
goto("/app")
}
const extPath = z.string().parse(_extPath)
const extUrl = z.string().parse(_extUrl)
@ -36,7 +36,7 @@ export const load: PageLoad = async ({
toast.error("Error loading extension manifest", {
description: `${err}`
})
goto("/")
goto("/app")
}
const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -44,7 +44,7 @@ export const load: PageLoad = async ({
toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
})
goto("/")
goto("/app")
}
return { extPath, url: extUrl, loadedExt, extInfoInDB: extInfoInDB! }
}

View File

@ -63,7 +63,7 @@
async function goBack() {
if (isInMainWindow()) {
goto("/")
goto("/app")
} else {
appWin.close()
}

View File

@ -27,7 +27,7 @@ export const load: PageLoad = async ({ url }) => {
if (!extPath || !cmdName) {
toast.error("Invalid extension path or url")
error("Invalid extension path or url")
goto("/")
goto("/app")
}
let _loadedExt: ExtPackageJsonExtra | undefined
@ -38,7 +38,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Error loading extension manifest", {
description: `${err}`
})
goto("/")
goto("/app")
}
const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -46,7 +46,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
})
goto("/")
goto("/app")
}
const pkgJsonPath = await join(extPath!, "package.json")
if (!(await exists(extPath!))) {

View File

@ -0,0 +1,20 @@
<script lang="ts">
import { Skeleton } from "@kksh/svelte5"
import { getCurrentWindow } from "@tauri-apps/api/window"
import { onMount } from "svelte"
onMount(async () => {
const mainWin = await getCurrentWindow()
mainWin.show()
})
</script>
<main data-tauri-drag-region class="h-screen">
<div class="flex items-center space-x-4">
<Skeleton class="size-12 rounded-full" />
<div class="space-y-2">
<Skeleton class="h-4 w-[250px]" />
<Skeleton class="h-4 w-[200px]" />
</div>
</div>
</main>