update
This commit is contained in:
@@ -38,13 +38,14 @@ export default function MainLayout() {
|
||||
useState<InstantMeiliSearchInstance>();
|
||||
|
||||
useEffect(() => {
|
||||
const { meilisearchUrl, meilisearchToken } = selector;
|
||||
const { meilisearchUrl, meilisearchToken, enableHybridSearch } = selector;
|
||||
const { searchClient } = instantMeiliSearch(
|
||||
meilisearchUrl,
|
||||
meilisearchToken,
|
||||
{
|
||||
finitePagination: true,
|
||||
meiliSearchParams: {
|
||||
hybrid: enableHybridSearch ? ({} as any) : undefined,
|
||||
attributesToRetrieve: [
|
||||
"cover",
|
||||
"title",
|
||||
|
||||
@@ -19,7 +19,7 @@ import { ThemeSetting } from "@/component/Settings/Theme";
|
||||
import { disableSentry } from "@/sentry";
|
||||
import store from "@/store";
|
||||
import { useOptionsState } from "@/store/module/options";
|
||||
import { setMeilisearchToken, setMeilisearchUrl, setS3Url } from "@/store/reducer/options";
|
||||
import { setEnableHybridSearch, setMeilisearchToken, setMeilisearchUrl, setS3Url } from "@/store/reducer/options";
|
||||
import { useLocalStorage } from "@mantine/hooks";
|
||||
import { IconBrandGithub, IconMail } from "@tabler/icons-react";
|
||||
import { Meilisearch } from "meilisearch";
|
||||
@@ -110,6 +110,22 @@ export default function SettingsPage() {
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: "Enable Hybrid Search",
|
||||
description: "Enable hybrid search for Meilisearch",
|
||||
value: (
|
||||
<div>
|
||||
<Switch
|
||||
size="md"
|
||||
checked={options.enableHybridSearch}
|
||||
onChange={(value) => {
|
||||
const v = value.currentTarget.checked;
|
||||
store.dispatch(setEnableHybridSearch(v));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ export interface OptionsState {
|
||||
meilisearchUrl: string;
|
||||
meilisearchToken: string;
|
||||
s3Url: string;
|
||||
enableHybridSearch?: boolean;
|
||||
}
|
||||
|
||||
const initialState: OptionsState = {
|
||||
@@ -11,6 +12,7 @@ const initialState: OptionsState = {
|
||||
meilisearchToken:
|
||||
"a568afad53a4dd124c508b9acd26ec35ff65665c07020913533cd7b176a28a04",
|
||||
s3Url: "https://minio-hdd.yoshino-s.xyz/",
|
||||
enableHybridSearch: true,
|
||||
};
|
||||
|
||||
const optionsSlice = createSlice({
|
||||
@@ -26,10 +28,16 @@ const optionsSlice = createSlice({
|
||||
setS3Url: (state, action: PayloadAction<string | undefined>) => {
|
||||
state.s3Url = action.payload ?? initialState.s3Url;
|
||||
},
|
||||
setEnableHybridSearch: (
|
||||
state,
|
||||
action: PayloadAction<boolean | undefined>
|
||||
) => {
|
||||
state.enableHybridSearch = action.payload ?? initialState.enableHybridSearch;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const { setS3Url, setMeilisearchUrl, setMeilisearchToken } =
|
||||
export const { setS3Url, setMeilisearchUrl, setMeilisearchToken, setEnableHybridSearch } =
|
||||
optionsSlice.actions;
|
||||
|
||||
export default optionsSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user