351c861777
- Migrate source to packages/client and packages/server directories - Namespace all Hermes-specific code under hermes/ subdirectories (api/hermes/, components/hermes/, views/hermes/, stores/hermes/) - Add hermes.* route names and /hermes/* path prefixes - Upgrade @koa/router to v15, adapt path-to-regexp v8 syntax - Fix proxy path rewriting: /api/hermes/v1/* → /v1/*, /api/hermes/* → /api/* - Fix frontend API paths to match backend /api/hermes/* routes - Fix WebSocket terminal path to /api/hermes/terminal - Add proxyMiddleware for reliable unmatched route proxying - Add profiles route module and hermes-cli profile commands - Update CLAUDE.md development guide with new architecture - Add Chinese README (README_zh.md) - Add Web Terminal feature to README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
981 B
TypeScript
40 lines
981 B
TypeScript
import { onMounted, onUnmounted } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { useChatStore } from '@/stores/hermes/chat'
|
|
|
|
export function useKeyboard() {
|
|
const router = useRouter()
|
|
const chatStore = useChatStore()
|
|
|
|
function handleKeydown(e: KeyboardEvent) {
|
|
const mod = e.ctrlKey || e.metaKey
|
|
|
|
if (mod && e.key === 'n') {
|
|
e.preventDefault()
|
|
chatStore.newChat()
|
|
}
|
|
|
|
if (mod && e.key === 'j') {
|
|
e.preventDefault()
|
|
router.push({ name: 'hermes.jobs' })
|
|
}
|
|
|
|
if (e.key === 'Escape') {
|
|
// Close any open modals — naive-ui handles this internally
|
|
const modal = document.querySelector('.n-modal-mask')
|
|
if (modal) {
|
|
const closeBtn = modal.querySelector('.n-base-close') as HTMLElement
|
|
closeBtn?.click()
|
|
}
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
window.addEventListener('keydown', handleKeydown)
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
window.removeEventListener('keydown', handleKeydown)
|
|
})
|
|
}
|