1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2025-01-24 02:34:00 +09:00

Merge pull request #554

* feat: custome search engine

* fix import

* Rollback elements
This commit is contained in:
Esurio/1673beta 2025-01-01 22:10:56 +09:00 committed by GitHub
parent 23f47b93b3
commit 24b3750b91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 212 additions and 2 deletions

View File

@ -3170,3 +3170,17 @@ _scheduledNoteDelete:
_getQRCode:
title: "Scan QR Code"
description: "Can scan or share the QR code below."
_searchSite:
title: "Search Engine"
description: "Change search engine that used in search MFM."
google: "Google"
bing: "Bing"
yahoo: "Yahoo"
baidu: "Baidu"
naver: "NAVER"
duckduckgo: "DuckDuckGo"
other: "Other"
otherDescription: "Use Other search engine"
query: "Query"
queryDescription: "Input query scheme for search engine. For example, If https://www.ecosia.org/search?q=test, input 'q'."

113
locales/index.d.ts vendored
View File

@ -12115,6 +12115,65 @@ export interface Locale extends ILocale {
*/
"sent": string;
};
"_remoteLookupErrors": {
"_federationNotAllowed": {
/**
*
*/
"title": string;
/**
*
*
*/
"description": string;
};
"_uriInvalid": {
/**
* URIが不正です
*/
"title": string;
/**
* URIに問題がありますURIに使用できない文字を入力していないか確認してください
*/
"description": string;
};
"_requestFailed": {
/**
*
*/
"title": string;
/**
* URIや存在しないURIを入力していないか確認してください
*/
"description": string;
};
"_responseInvalid": {
/**
*
*/
"title": string;
/**
*
*/
"description": string;
};
"_responseInvalidIdHostNotMatch": {
/**
* URIのドメインと最終的に得られたURIのドメインとが異なりますURIを使用して照会し直してください
*/
"description": string;
};
"_noSuchObject": {
/**
*
*/
"title": string;
/**
* URIをもう一度お確かめください
*/
"description": string;
};
};
"_abuse": {
"_resolver": {
/**
@ -12303,6 +12362,60 @@ export interface Locale extends ILocale {
*/
"description": string;
};
"_searchSite": {
/**
*
*/
"title": string;
/**
* MFMの検索構文で検索できるサイトを変更します
*/
"description": string;
/**
* Google
*/
"google": string;
/**
* Bing
*/
"bing": string;
/**
* Yahoo
*/
"yahoo": string;
/**
* Baidu
*/
"baidu": string;
/**
* NAVER
*/
"naver": string;
/**
* DuckDuckGo
*/
"duckduckgo": string;
/**
*
*/
"other": string;
/**
*
*/
"otherSearchEngine": string;
/**
* 使
*/
"otherDescription": string;
/**
*
*/
"query": string;
/**
* 使(: https://www.ecosia.org/search?q=test の場合qを入れる)
*/
"queryDescription": string;
};
}
declare const locales: {
[lang: string]: Locale;

View File

@ -3297,3 +3297,18 @@ _scheduledNoteDelete:
_getQRCode:
title: "QRコードをスキャンする"
description: "以下のQRコードをスキャンまたは共有できます。"
_searchSite:
title: "検索エンジン"
description: "MFMの検索構文で検索できるサイトを変更します。"
google: "Google"
bing: "Bing"
yahoo: "Yahoo"
baidu: "Baidu"
naver: "NAVER"
duckduckgo: "DuckDuckGo"
other: "その他"
otherSearchEngine: "その他の検索エンジン"
otherDescription: "その他の検索エンジンを使用します。"
query: "検索クエリ"
queryDescription: "検索エンジンが使用するクエリを入力します。(例: https://www.ecosia.org/search?q=test の場合qを入れる)"

View File

@ -13,6 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
const props = defineProps<{
q: string;
@ -22,8 +23,40 @@ const query = ref(props.q);
const search = () => {
const sp = new URLSearchParams();
sp.append('q', query.value);
window.open(`https://www.google.com/search?${sp.toString()}`, '_blank', 'noopener');
let url = '';
switch (defaultStore.state.searchEngine) {
case 'google':
sp.append('q', query.value);
url = `https://www.google.com/search?${sp.toString()}`;
break;
case 'bing':
sp.append('q', query.value);
url = `https://www.bing.com/search?${sp.toString()}`;
break;
case 'yahoo':
sp.append('p', query.value);
url = `https://search.yahoo.com/search?${sp.toString()}`;
break;
case 'baidu':
// see detail: https://www.jademond.com/magazine/baidu-search-url-parameters/
sp.append('wd', query.value);
url = `https://www.baidu.com/s?${sp.toString()}`;
break;
case 'naver':
sp.append('query', query.value);
url = `https://search.naver.com/search.naver?${sp.toString()}`;
break;
case 'duckduckgo':
sp.append('q', query.value);
url = `https://duckduckgo.com/?${sp.toString()}`;
break;
case 'other':
sp.append(defaultStore.state.searchEngineUrlQuery, query.value);
url = `${defaultStore.state.searchEngineUrl}${sp.toString()}`;
break;
}
window.open(url, '_blank', 'noopener');
};
</script>

View File

@ -152,6 +152,25 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="S">{{ i18n.ts._hemisphere.S }}</option>
<template #caption>{{ i18n.ts._hemisphere.caption }}</template>
</MkRadios>
<MkSelect v-model="searchEngine">
<template #label>{{ i18n.ts._searchSite.title }}</template>
<template #caption>{{ i18n.ts._searchSite.description }}</template>
<option value="google">{{ i18n.ts._searchSite.google }}</option>
<option value="bing">{{ i18n.ts._searchSite.bing }}</option>
<option value="yahoo">{{ i18n.ts._searchSite.yahoo }}</option>
<option value="baidu">{{ i18n.ts._searchSite.baidu }}</option>
<option value="naver">{{ i18n.ts._searchSite.naver }}</option>
<option value="duckduckgo">{{ i18n.ts._searchSite.duckduckgo }}</option>
<option value="other">{{ i18n.ts._searchSite.other }}</option>
</MkSelect>
<MkInput v-if="defaultStore.state.searchEngine == 'other'" v-model="searchEngineUrl">
<template #label>{{ i18n.ts._searchSite.otherSearchEngine }}</template>
<template #caption>{{ i18n.ts._searchSite.otherDescription }}</template>
</MkInput>
<MkInput v-if="defaultStore.state.searchEngine == 'other'" v-model="searchEngineUrlQuery">
<template #label>{{ i18n.ts._searchSite.query }}</template>
<template #caption>{{ i18n.ts._searchSite.queryDescription }}</template>
</MkInput>
<MkFolder>
<template #label>{{ i18n.ts.additionalEmojiDictionary }}</template>
<div class="_buttons">
@ -191,6 +210,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { miLocalStorage } from '@/local-storage.js';
import { globalEvents } from '@/events.js';
import { $i } from '@/account.js';
import MkInput from '@/components/MkInput.vue';
const lang = ref(miLocalStorage.getItem('lang'));
const dataSaver = ref(defaultStore.state.dataSaver);
@ -223,6 +243,9 @@ const useAutoTranslate = computed(defaultStore.makeGetterSetter('useAutoTranslat
const welcomeBackToast = computed(defaultStore.makeGetterSetter('welcomeBackToast'));
const disableNyaize = computed(defaultStore.makeGetterSetter('disableNyaize'));
const externalNavigationWarning = computed(defaultStore.makeGetterSetter('externalNavigationWarning'));
const searchEngine = computed(defaultStore.makeGetterSetter('searchEngine'));
const searchEngineUrl = computed(defaultStore.makeGetterSetter('searchEngineUrl'));
const searchEngineUrlQuery = computed(defaultStore.makeGetterSetter('searchEngineUrlQuery'));
watch(lang, () => {
miLocalStorage.setItem('lang', lang.value as string);

View File

@ -582,6 +582,18 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
searchEngine: {
where: 'device',
default: 'google' as 'google' | 'bing' | 'yahoo' | 'baidu'| 'naver' | 'duckduckgo' | 'other',
},
searchEngineUrl: {
where: 'device',
default: 'https://www.ecosia.org/search?',
},
searchEngineUrlQuery: {
where: 'device',
default: 'q',
},
// - Settings/Appearance
collapseReplies: {