From 54b7cc58c480983ca8039f56bca9e35d5d6d5402 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Mon, 4 Nov 2024 17:15:17 -0500 Subject: [PATCH] feat: add system commands --- apps/desktop/src/lib/cmds/system.ts | 4 +++ .../lib/components/main/CommandPalette.svelte | 5 +++- packages/api/src/commands/system.ts | 2 +- .../ui/src/components/main/SystemCmds.svelte | 26 +++++++++++++++++++ packages/ui/src/components/main/index.ts | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 apps/desktop/src/lib/cmds/system.ts create mode 100644 packages/ui/src/components/main/SystemCmds.svelte diff --git a/apps/desktop/src/lib/cmds/system.ts b/apps/desktop/src/lib/cmds/system.ts new file mode 100644 index 0000000..cd7221f --- /dev/null +++ b/apps/desktop/src/lib/cmds/system.ts @@ -0,0 +1,4 @@ +import { getSystemCommands } from "@kksh/api/commands" +import type { SysCommand } from "@kksh/api/models" + +export const systemCommands: SysCommand[] = getSystemCommands() diff --git a/apps/desktop/src/lib/components/main/CommandPalette.svelte b/apps/desktop/src/lib/components/main/CommandPalette.svelte index 8e117e4..c9256f9 100644 --- a/apps/desktop/src/lib/components/main/CommandPalette.svelte +++ b/apps/desktop/src/lib/components/main/CommandPalette.svelte @@ -3,6 +3,7 @@ passing everything through props will be very complicated and hard to maintain. --> + + + {#each systemCommands as cmd} + { + cmd.function() + }} + > + + {#if cmd.icon} + + {/if} + {cmd.name} + + + {/each} + diff --git a/packages/ui/src/components/main/index.ts b/packages/ui/src/components/main/index.ts index 7ff257d..cb38b5e 100644 --- a/packages/ui/src/components/main/index.ts +++ b/packages/ui/src/components/main/index.ts @@ -2,4 +2,5 @@ export { default as BuiltinCmds } from "./BuiltinCmds.svelte" export { default as CustomCommandInput } from "./CustomCommandInput.svelte" export { default as GlobalCommandPaletteFooter } from "./GlobalCommandPaletteFooter.svelte" export { default as ExtCmdsGroup } from "./ExtCmdsGroup.svelte" +export { default as SystemCmds } from "./SystemCmds.svelte" export * from "./types"