Skip to content

Commit 7688046

Browse files
authored
feat: add a shortcut to open a network search range (#355)
1 parent 42fb956 commit 7688046

6 files changed

Lines changed: 59 additions & 17 deletions

File tree

src/components/Search/SearchPopover.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export default function SearchPopover({
6262
const popoverRef = useRef<HTMLDivElement>(null);
6363
const buttonRef = useRef<HTMLButtonElement>(null);
6464
const internetSearch = useShortcutsStore((state) => state.internetSearch);
65+
const internetSearchScope = useShortcutsStore((state) => {
66+
return state.internetSearchScope;
67+
});
6568

6669
useEffect(() => {
6770
if (!showDataSource) return;
@@ -157,13 +160,20 @@ export default function SearchPopover({
157160
setShowDataSource((prev) => !prev);
158161
}}
159162
>
160-
<ChevronDownIcon
161-
className={clsx("size-5", [
162-
isSearchActive
163-
? "text-[#0072FF] dark:text-[#0072FF]"
164-
: "text-[#333] dark:text-white",
165-
])}
166-
/>
163+
<VisibleKey
164+
shortcut={internetSearchScope}
165+
onKeypress={() => {
166+
buttonRef.current?.click();
167+
}}
168+
>
169+
<ChevronDownIcon
170+
className={clsx("size-5", [
171+
isSearchActive
172+
? "text-[#0072FF] dark:text-[#0072FF]"
173+
: "text-[#333] dark:text-white",
174+
])}
175+
/>
176+
</VisibleKey>
167177
</PopoverButton>
168178

169179
{showDataSource ? (

src/components/Settings/Advanced/components/Shortcuts/index.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,21 @@ const Shortcuts = () => {
2727
const deepThinking = useShortcutsStore((state) => state.deepThinking);
2828
const setDeepThinking = useShortcutsStore((state) => state.setDeepThinking);
2929
const internetSearch = useShortcutsStore((state) => state.internetSearch);
30-
const setInternetSearch = useShortcutsStore(
31-
(state) => state.setInternetSearch
32-
);
33-
const historicalRecords = useShortcutsStore(
34-
(state) => state.historicalRecords
35-
);
36-
const setHistoricalRecords = useShortcutsStore(
37-
(state) => state.setHistoricalRecords
38-
);
30+
const setInternetSearch = useShortcutsStore((state) => {
31+
return state.setInternetSearch;
32+
});
33+
const internetSearchScope = useShortcutsStore((state) => {
34+
return state.internetSearchScope;
35+
});
36+
const setInternetSearchScope = useShortcutsStore((state) => {
37+
return state.setInternetSearchScope;
38+
});
39+
const historicalRecords = useShortcutsStore((state) => {
40+
return state.historicalRecords;
41+
});
42+
const setHistoricalRecords = useShortcutsStore((state) => {
43+
return state.setHistoricalRecords;
44+
});
3945
const newSession = useShortcutsStore((state) => state.newSession);
4046
const setNewSession = useShortcutsStore((state) => state.setNewSession);
4147
const fixedWindow = useShortcutsStore((state) => state.fixedWindow);
@@ -90,6 +96,13 @@ const Shortcuts = () => {
9096
value: internetSearch,
9197
setValue: setInternetSearch,
9298
},
99+
{
100+
title: "settings.advanced.shortcuts.internetSearchScope.title",
101+
description:
102+
"settings.advanced.shortcuts.internetSearchScope.description",
103+
value: internetSearchScope,
104+
setValue: setInternetSearchScope,
105+
},
93106
{
94107
title: "settings.advanced.shortcuts.historicalRecords.title",
95108
description: "settings.advanced.shortcuts.historicalRecords.description",

src/locales/en/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
"title": "Internet Search",
112112
"description": "Shortcut button to enable networking search in chat mode."
113113
},
114+
"internetSearchScope": {
115+
"title": "Internet Search Scope",
116+
"description": "Shortcut to open the networking search scope menu in chat mode."
117+
},
114118
"historicalRecords": {
115119
"title": "Conversation History",
116120
"description": "Shortcut to view past conversation history in chat mode."

src/locales/zh/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
"title": "联网搜索",
112112
"description": "在聊天模式下启用联网搜索的快捷按键。"
113113
},
114+
"internetSearchScope": {
115+
"title": "联网搜索范围",
116+
"description": "在聊天模式下打开联网搜索范围菜单的快捷键。"
117+
},
114118
"historicalRecords": {
115119
"title": "历史记录",
116120
"description": "在聊天模式下查看历史对话记录的快捷键。"

src/pages/main/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function MainApp() {
2222
queryStrings: { query: input },
2323
}
2424
);
25-
console.log(11111, response)
25+
console.log(11111, response);
2626
return response;
2727
} catch (error) {
2828
console.error("query_coco_fusion error:", error);
@@ -90,6 +90,9 @@ function MainApp() {
9090
const setInternetSearch = useShortcutsStore((state) => {
9191
return state.setInternetSearch;
9292
});
93+
const setInternetSearchScope = useShortcutsStore((state) => {
94+
return state.setInternetSearchScope;
95+
});
9396
const setHistoricalRecords = useShortcutsStore((state) => {
9497
return state.setHistoricalRecords;
9598
});
@@ -117,6 +120,7 @@ function MainApp() {
117120
addFile,
118121
deepThinking,
119122
internetSearch,
123+
internetSearchScope,
120124
historicalRecords,
121125
newSession,
122126
fixedWindow,
@@ -130,6 +134,7 @@ function MainApp() {
130134
setAddFile(addFile);
131135
setDeepThinking(deepThinking);
132136
setInternetSearch(internetSearch);
137+
setInternetSearchScope(internetSearchScope);
133138
setHistoricalRecords(historicalRecords);
134139
setNewSession(newSession);
135140
setFixedWindow(fixedWindow);

src/stores/shortcutsStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export type IShortcutsStore = {
2121
setDeepThinking: (deepThinking: string) => void;
2222
internetSearch: string;
2323
setInternetSearch: (internetSearch: string) => void;
24+
internetSearchScope: string;
25+
setInternetSearchScope: (internetSearchScope: string) => void;
2426
historicalRecords: string;
2527
setHistoricalRecords: (historicalRecords: string) => void;
2628
newSession: string;
@@ -53,6 +55,10 @@ export const useShortcutsStore = create<IShortcutsStore>()(
5355
setDeepThinking: (deepThinking: string) => set({ deepThinking }),
5456
internetSearch: "G",
5557
setInternetSearch: (internetSearch: string) => set({ internetSearch }),
58+
internetSearchScope: "J",
59+
setInternetSearchScope: (internetSearchScope: string) => {
60+
return set({ internetSearchScope });
61+
},
5662
historicalRecords: "Y",
5763
setHistoricalRecords: (historicalRecords: string) => {
5864
return set({ historicalRecords });

0 commit comments

Comments
 (0)