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 80dd7616..9ec5ff5e 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 757af845..4b174bc2 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 6b744115..be47333d 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 4244bb22..9b370ad6 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 58bd979e..4e899055 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 aebd3102..ff0d54cb 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=", + }, }), );