feat(new tool): Wiktionary Search

Fix #1042
This commit is contained in:
ShareVB committed 2026-01-03 23:54:34 +01:00
1 parent 3c7e690fbd
commit ea37ca60cf
2 files changed
+82

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import { Books } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Online Dictionary',
path: '/online-wiktionary',
description: 'Search words in Wiktionary',
keywords: ['online', 'dictionary', 'wiktionary'],
component: () => import('./online-wiktionary.vue'),
icon: Books,
createdAt: new Date('2026-01-03'),
category: 'Data',
});
@@ -0,0 +1,69 @@
<script setup>
import { ref } from 'vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const query = ref('');
const language = useQueryParamOrStorage({ name: 'lang', storageName: 'wiktionary:l', defaultValue: 'en' });
// Extend this list as needed
const languageOptions = [
{ label: 'English', value: 'en' },
{ label: 'French', value: 'fr' },
{ label: 'German', value: 'de' },
{ label: 'Spanish', value: 'es' },
{ label: 'Italian', value: 'it' },
{ label: 'Russian', value: 'ru' },
{ label: 'Chinese', value: 'zh' },
{ label: 'Japanese', value: 'ja' },
{ label: 'Arabic', value: 'ar' },
];
const iframeUrl = ref('');
function openSearch() {
const encoded = encodeURIComponent(query.value.trim());
iframeUrl.value = `https://${language.value}.wiktionary.org/wiki/Special:Search?search=${encoded}`;
}
</script>
<template>
<div>
<n-form-item label="" label-placement="left">
<n-input
v-model:value="query"
placeholder="Enter a word…"
clearable
mr-1
/>
<n-select
v-model:value="language"
:options="languageOptions"
placeholder="Select a language"
filterable
/>
</n-form-item>
<n-space justify="center">
<n-button
type="primary"
:disabled="!query || !language"
@click="openSearch"
>
Search on Wiktionary
</n-button>
</n-space>
<n-divider />
<div style="height: 70vh; border: 1px solid #ddd; border-radius: 6px; overflow: hidden;">
<iframe
v-if="iframeUrl"
:src="iframeUrl"
style="width: 100%; height: 100%; border: none;"
/>
<div v-else style="padding: 1rem; text-align: center; color: #888;">
Enter a word and select a language to load Wiktionary
</div>
</div>
</div>
</template>