feat: open quick ai with modifier key + enter (#939)

* feat: open quick ai with modifier key + enter

* docs: update changelog
This commit is contained in:
ayangweb
2025-10-21 15:56:01 +08:00
committed by GitHub
parent d1ad1af71a
commit cbd8dc52cd
4 changed files with 14 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ feat: support pageup/pagedown to navigate search results #920
feat: standardize multi-level menu label structure #925 feat: standardize multi-level menu label structure #925
feat(View Extension): page field now accepts HTTP(s) links #925 feat(View Extension): page field now accepts HTTP(s) links #925
feat: return sub-exts when extension type exts themselves are matched #928 feat: return sub-exts when extension type exts themselves are matched #928
feat: open quick ai with modifier key + enter #939
### 🐛 Bug fix ### 🐛 Bug fix

View File

@@ -7,8 +7,9 @@ import platformAdapter from "@/utils/platformAdapter";
import { Get } from "@/api/axiosRequest"; import { Get } from "@/api/axiosRequest";
import type { Assistant } from "@/types/chat"; import type { Assistant } from "@/types/chat";
import { useAppStore } from "@/stores/appStore"; import { useAppStore } from "@/stores/appStore";
import { navigateBack } from "@/utils"; import { canNavigateBack, navigateBack } from "@/utils";
import { useKeyPress } from "ahooks"; import { useKeyPress } from "ahooks";
import { useShortcutsStore } from "@/stores/shortcutsStore";
interface AssistantManagerProps { interface AssistantManagerProps {
isChatMode: boolean; isChatMode: boolean;
@@ -49,6 +50,7 @@ export function useAssistantManager({
}, [quickAiAccessAssistant, selectedAssistant]); }, [quickAiAccessAssistant, selectedAssistant]);
const [assistantDetail, setAssistantDetail] = useState<any>({}); const [assistantDetail, setAssistantDetail] = useState<any>({});
const { modifierKey } = useShortcutsStore();
useEffect(() => { useEffect(() => {
if (goAskAi) return; if (goAskAi) return;
@@ -78,7 +80,7 @@ export function useAssistantManager({
}, [askAI?.id, askAI?.querySource?.id, disabledExtensions]); }, [askAI?.id, askAI?.querySource?.id, disabledExtensions]);
const handleAskAi = useCallback(() => { const handleAskAi = useCallback(() => {
if (!isTauri) return; if (!isTauri || canNavigateBack()) return;
if (disabledExtensions.includes("QuickAIAccess")) return; if (disabledExtensions.includes("QuickAIAccess")) return;
@@ -206,6 +208,11 @@ export function useAssistantManager({
setSourceData(selectedSearchContent); setSourceData(selectedSearchContent);
}); });
useKeyPress(`${modifierKey}.enter`, () => {
assistant_get();
return handleAskAi();
});
return { return {
askAI, askAI,
askAIRef, askAIRef,

View File

@@ -28,6 +28,7 @@ import {
import { useTauriFocus } from "@/hooks/useTauriFocus"; import { useTauriFocus } from "@/hooks/useTauriFocus";
import { SendMessageParams } from "../Assistant/Chat"; import { SendMessageParams } from "../Assistant/Chat";
import { isEmpty } from "lodash-es"; import { isEmpty } from "lodash-es";
import { formatKey } from "@/utils/keyboardUtils";
interface ChatInputProps { interface ChatInputProps {
onSend: (params: SendMessageParams) => void; onSend: (params: SendMessageParams) => void;
@@ -253,8 +254,8 @@ export default function ChatInput({
replace: [akiAiTooltipPrefix, askAI.name], replace: [akiAiTooltipPrefix, askAI.name],
})} })}
</span> </span>
<div className="flex items-center justify-center w-8 h-[20px] text-xs rounded-md border border-black/10 dark:border-[#545454]"> <div className="flex items-center justify-center px-1 h-[20px] text-xs rounded-md border border-black/10 dark:border-[#545454]">
Tab {formatKey(modifierKey)} + {formatKey("Enter")}
</div> </div>
</div> </div>
)} )}

View File

@@ -37,7 +37,7 @@ export const KEY_SYMBOLS: Record<string, string> = {
// Special keys // Special keys
Space: "Space", Space: "Space",
space: "Space", space: "Space",
Enter: "", Enter: "↩︎",
Backspace: "⌫", Backspace: "⌫",
Delete: "Del", Delete: "Del",
Escape: "Esc", Escape: "Esc",