update command

This commit is contained in:
Dede Fuji Abdul
2023-10-27 09:38:20 +07:00
parent 70a6353c98
commit 3b4e2ae1b9
5 changed files with 50 additions and 47 deletions

View File

@ -1,12 +1,14 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { RouteRecordRaw } from 'vue-router'
import { useRouter, type RouteRecordRaw } from 'vue-router'
import { readDataJson, writeDataJson } from '@/utils/storage'
import { extractLeafRoutes } from '@/router'
import { useMenuStore } from '@/stores/menu'
export const useCommandPalattesStore = defineStore('command_palettes', () => {
const open = ref(false)
const route = useRouter()
const menu = useMenuStore()
const controlStatus = ref(false)
const keyFStatus = ref(false)
@ -82,6 +84,16 @@ export const useCommandPalattesStore = defineStore('command_palettes', () => {
return matchingRoutes
}
const openMenu = (routeTarget: RouteRecordRaw) => {
addRecent(routeTarget)
route.push(routeTarget.path)
closeCommand()
}
const closeCommand = () => {
open.value = false
}
return {
open,
showCommandPalettes,
@ -91,6 +103,8 @@ export const useCommandPalattesStore = defineStore('command_palettes', () => {
addRecent,
readRecent,
searchRoutesByName,
searchRoutesPath
searchRoutesPath,
openMenu,
closeCommand
}
})