mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 15:15:02 -04:00
feat(command-palette): random tool action
This commit is contained in:
parent
63045951e1
commit
ec4c533718
3 changed files with 33 additions and 2 deletions
|
@ -8,10 +8,12 @@ import { useStyleStore } from '@/stores/style.store';
|
|||
import SunIcon from '~icons/mdi/white-balance-sunny';
|
||||
import GithubIcon from '~icons/mdi/github';
|
||||
import BugIcon from '~icons/mdi/bug-outline';
|
||||
import DiceIcon from '~icons/mdi/dice-5';
|
||||
|
||||
export const useCommandPaletteStore = defineStore('command-palette', () => {
|
||||
const toolStore = useToolStore();
|
||||
const styleStore = useStyleStore();
|
||||
const router = useRouter();
|
||||
const searchPrompt = ref('');
|
||||
|
||||
const toolsOptions = toolStore.tools.map(tool => ({
|
||||
|
@ -23,6 +25,18 @@ export const useCommandPaletteStore = defineStore('command-palette', () => {
|
|||
|
||||
const searchOptions: PaletteOption[] = [
|
||||
...toolsOptions,
|
||||
{
|
||||
name: 'Random tool',
|
||||
description: 'Get a random tool from the list.',
|
||||
action: () => {
|
||||
const { path } = _.sample(toolStore.tools)!;
|
||||
router.push(path);
|
||||
},
|
||||
icon: DiceIcon,
|
||||
category: 'Tools',
|
||||
keywords: ['random', 'tool', 'pick', 'choose', 'select'],
|
||||
closeOnSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'Toggle dark mode',
|
||||
description: 'Toggle dark mode on or off.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue