Skip to content

Commit 17f2bcf

Browse files
authored
fix: fix the problem that web cannot click on the jump (#575)
1 parent c471a83 commit 17f2bcf

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/components/Search/DocumentList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import platformAdapter from "@/utils/platformAdapter";
1111
import { Get } from "@/api/axiosRequest";
1212
import { useAppStore } from "@/stores/appStore";
1313
import { useConnectStore } from "@/stores/connectStore";
14+
import { OpenURLWithBrowser } from "@/utils";
1415

1516
interface DocumentListProps {
1617
onSelectDocument: (id: string) => void;
@@ -236,10 +237,14 @@ export const DocumentList: React.FC<DocumentListProps> = ({
236237
onMouseEnter={() => onMouseEnter(index, hit.document)}
237238
onItemClick={() => {
238239
if (hit.document?.on_opened) {
239-
platformAdapter.invokeBackend("open", {
240+
return platformAdapter.invokeBackend("open", {
240241
onOpened: hit.document.on_opened,
241242
});
242243
}
244+
245+
if (hit.document?.url) {
246+
OpenURLWithBrowser(hit.document.url);
247+
}
243248
}}
244249
showListRight={viewMode === "list"}
245250
/>

src/components/Search/DropdownList.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useKeyboardNavigation } from "@/hooks/useKeyboardNavigation";
1616
import { SearchSource } from "./SearchSource";
1717
import DropdownListItem from "./DropdownListItem";
1818
import platformAdapter from "@/utils/platformAdapter";
19+
import { OpenURLWithBrowser } from "@/utils";
1920

2021
type ISearchData = Record<string, QueryHits[]>;
2122

@@ -82,7 +83,13 @@ function DropdownList({
8283
},
8384
onItemClick: (item: SearchDocument) => {
8485
if (item?.on_opened) {
85-
platformAdapter.invokeBackend("open", { onOpened: item.on_opened });
86+
return platformAdapter.invokeBackend("open", {
87+
onOpened: item.on_opened,
88+
});
89+
}
90+
91+
if (item?.url) {
92+
OpenURLWithBrowser(item.url);
8693
}
8794
},
8895
goToTwoPage: (item: SearchDocument) => {

src/routes/layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect } from "react";
22
import { Outlet, useLocation } from "react-router-dom";
33
import { useTranslation } from "react-i18next";
44
import { useAsyncEffect, useEventListener, useMount } from "ahooks";
5-
import { isString } from "lodash-es";
5+
import { isArray, isString } from "lodash-es";
66
import { error } from "@tauri-apps/plugin-log";
77

88
import { useAppStore } from "@/stores/appStore";
@@ -130,6 +130,8 @@ export default function Layout() {
130130
"list_extensions"
131131
);
132132

133+
if (!isArray(result)) return;
134+
133135
const disabledExtensions = result[1].filter((item) => !item.enabled);
134136

135137
setDisabledExtensions(disabledExtensions.map((item) => item.id));

src/utils/platformAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// manual modification
22
import { createTauriAdapter } from "./tauriAdapter";
3-
//import { createWebAdapter } from './webAdapter';
4-
53
let platformAdapter = createTauriAdapter();
6-
//let platformAdapter = createWebAdapter();
4+
5+
// import { createWebAdapter } from "./webAdapter";
6+
// let platformAdapter = createWebAdapter();
77

88
export default platformAdapter;

0 commit comments

Comments
 (0)