From 3d2ecadbc62ea4f5de520feae1c6891b5f10cb7f Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 16 Feb 2024 00:35:19 +0900 Subject: [PATCH] feat (client): ability to specify search engine in search bar MFM --- docs/changelog.md | 4 ++++ locales/en-US.yml | 2 ++ locales/ja-JP.yml | 2 ++ packages/client/src/components/MkGoogle.vue | 5 ++++- .../client/src/pages/settings/general.vue | 20 +++++++++++++++++++ packages/client/src/store.ts | 4 ++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index f06e0ac41d..8a3d1c7fd6 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,7 @@ +# Unreleased + +- add ability to specify the search engine used in the search bar MFM + # v20240216 - style changes in the web client (a770ef4314e21f17fdce1f19feb3758953b04486 ab39ff5954a392cc6688a02f1723e1702df5e35c 4eefd534d8150e2cd5cf31dddd327edceb5b84dc) diff --git a/locales/en-US.yml b/locales/en-US.yml index ac1480aa24..570cd5e1ba 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1167,6 +1167,8 @@ hideFollowButtons: "Hide follow buttons in a misclickable position" forMobile: "Mobile" replaceChatButtonWithAccountButton: "Replace chat button with account switch button" replaceWidgetsButtonWithReloadButton: "Replace widgets button with reload button" +searchEngine: "Search engine used in search bar MFM" +postSearch: "Post search on this server" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index d0919ee3ce..fc3ae46199 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2016,3 +2016,5 @@ hideFollowButtons: "誤タップしやすい位置にあるフォローボタン forMobile: "携帯端末向け" replaceChatButtonWithAccountButton: "チャットのボタンをアカウント切り替えボタンに変更する" replaceWidgetsButtonWithReloadButton: "ウィジェットのボタンを再読み込みボタンに変更する" +searchEngine: "検索のMFMで使用する検索エンジン" +postSearch: "このサーバーの投稿検索" diff --git a/packages/client/src/components/MkGoogle.vue b/packages/client/src/components/MkGoogle.vue index 174f03f3c3..a397c5c33a 100644 --- a/packages/client/src/components/MkGoogle.vue +++ b/packages/client/src/components/MkGoogle.vue @@ -13,6 +13,7 @@ import { ref } from "vue"; import { i18n } from "@/i18n"; import { useRouter } from "@/router"; import icon from "@/scripts/icon"; +import { defaultStore } from "@/store"; const router = useRouter(); @@ -23,7 +24,9 @@ const props = defineProps<{ const query = ref(props.q); const search = () => { - router.push(`/search?q=${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 e11852e831..6874cf17a5 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -138,6 +138,25 @@ {{ i18n.ts._serverDisconnectedBehavior.nothing }} + + + + + + + + + @@ -470,6 +489,7 @@ const openServerInfo = computed( ); const iconSet = computed(defaultStore.makeGetterSetter("iconSet")); const useEmojiCdn = computed(defaultStore.makeGetterSetter("useEmojiCdn")); +const searchURL = computed(defaultStore.makeGetterSetter("searchURL")); // This feature (along with injectPromo) is currently disabled // function onChangeInjectFeaturedNote(v) { diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index a0f87fa976..260cbfe17d 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -397,6 +397,10 @@ export const defaultStore = markRaw( where: "device", default: false, }, + searchURL: { + where: "device", + default: "https://duckduckgo.com/?q=", + }, }), );