From 6661550a87d76bbc39b1f04a92e772c14e396577 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 21 Sep 2023 16:47:06 +0900 Subject: [PATCH] feat: ability to specify search engine for search MFM --- README.md | 7 ++++++ locales/en-US.yml | 2 ++ locales/ja-JP.yml | 2 ++ packages/client/src/components/MkGoogle.vue | 5 +++- .../client/src/pages/settings/general.vue | 23 +++++++++++++++++++ packages/client/src/store.ts | 4 ++++ 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 80dd7616b..9ec5ff5ec 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,13 @@ ## 細かい変更点 +- 検索の MFM で使用する検索エンジンを設定から変更可能に + - 以下の選択肢から選べます + - DuckDuckGo (duckduckgo.com) + - SearXNG (searx.be) + - Google Search (google.com) + - Moon Search (search.naskya.net) + - サーバーの投稿検索 - サーバー設定の初期値を変更 - 新規登録を無効化 - サーバーメトリクスの表示を有効化 diff --git a/locales/en-US.yml b/locales/en-US.yml index 757af8455..4b174bc2b 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2155,3 +2155,5 @@ privacyForNerds: "Privacy protection in public places" disableToast: "Don't show the \"Welcome back\" banner" hideMyIcon: "Hide my icon" hideMyName: "Hide my name and ID" +searchEngine: "Search engine used in search bar MFM" +postSearch: "Post search on this server" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6b744115e..be47333d0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2009,3 +2009,5 @@ disableToast: "「おかえりなさい、◯◯さん」を表示しない" hideMyIcon: "自分のアイコンを表示しない" hideMyName: "自分の名前とIDを表示しない" openServerInfo: "投稿内のサーバー名をクリックでサーバー情報を開く" +searchEngine: "検索の MFM で使用する検索エンジン" +postSearch: "このサーバーの投稿検索" diff --git a/packages/client/src/components/MkGoogle.vue b/packages/client/src/components/MkGoogle.vue index 4244bb22d..9b370ad6f 100644 --- a/packages/client/src/components/MkGoogle.vue +++ b/packages/client/src/components/MkGoogle.vue @@ -12,6 +12,7 @@ import { ref } from "vue"; import { i18n } from "@/i18n"; import { useRouter } from "@/router"; +import { defaultStore } from "@/store"; const router = useRouter(); @@ -22,7 +23,9 @@ const props = defineProps<{ const query = ref(props.q); const search = () => { - router.push(`/search/${query.value}`); + if (defaultStore.state.searchURL === "") + router.push(`/search?q=${query.value}`); + else window.open(`${defaultStore.state.searchURL}${query.value}`, "_blank"); }; diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 58bd979eb..4e8990550 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -108,6 +108,28 @@ {{ i18n.ts._serverDisconnectedBehavior.nothing }} + + + + + + + + + @@ -481,6 +503,7 @@ const hideMyName = computed(defaultStore.makeGetterSetter("hideMyName")); const openServerInfo = computed( defaultStore.makeGetterSetter("openServerInfo"), ); +const searchURL = computed(defaultStore.makeGetterSetter("searchURL")); watch(swipeOnDesktop, () => { defaultStore.set("swipeOnMobile", true); diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index aebd3102d..ff0d54cb6 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -393,6 +393,10 @@ export const defaultStore = markRaw( where: "device", default: true, }, + searchURL: { + where: "device", + default: "https://duckduckgo.com/?q=", + }, }), );