mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 05:24:06 +03:00
feat(new tool): ISO-639 Language Searcher
This commit is contained in:
1 parent
81fa4c598b
commit
4a2e83ee31
5 files changed
+172
No files matched your search
@@ -231,6 +231,7 @@
|
||||
"jszip": "^3.10.1",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"korean-unpacker": "^1.0.3",
|
||||
"langs": "^2.0.0",
|
||||
"libmime": "^5.3.7",
|
||||
"libphonenumber-js": "^1.12.33",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
Generated
+8
@@ -582,6 +582,9 @@ importers:
|
||||
korean-unpacker:
|
||||
specifier: ^1.0.3
|
||||
version: 1.0.3
|
||||
langs:
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
libmime:
|
||||
specifier: ^5.3.7
|
||||
version: 5.3.7
|
||||
@@ -8178,6 +8181,9 @@ packages:
|
||||
resolution: {integrity: sha512-QJv/h939gDpvT+9SiLVlY7tZC3xB2qK57v0J04Sh9wpMb6MP1q8gB21L3WIo8T5P1MSMg3Ep14L7KkDCFG3y4w==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
|
||||
langs@2.0.0:
|
||||
resolution: {integrity: sha512-v4pxOBEQVN1WBTfB1crhTtxzNLZU9HPWgadlwzWKISJtt6Ku/CnpBrwVy+jFv8StjxsPfwPFzO0CMwdZLJ0/BA==}
|
||||
|
||||
last-run@2.0.0:
|
||||
resolution: {integrity: sha512-j+y6WhTLN4Itnf9j5ZQos1BGPCS8DAwmgMroR3OzfxAsBxam0hMw7J8M3KqZl0pLQJ1jNnwIexg5DYpC/ctwEQ==}
|
||||
engines: {node: '>= 10.13.0'}
|
||||
@@ -19911,6 +19917,8 @@ snapshots:
|
||||
vscode-languageserver-textdocument: 1.0.12
|
||||
vscode-uri: 3.0.8
|
||||
|
||||
langs@2.0.0: {}
|
||||
|
||||
last-run@2.0.0: {}
|
||||
|
||||
layout-base@1.0.2: {}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Language } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'ISO 639 Searcher',
|
||||
path: '/iso-639-searcher',
|
||||
description: 'Search in ISO 639-1/2T/2B/3 language codes',
|
||||
keywords: ['iso639', 'language', 'langcode', 'searcher'],
|
||||
component: () => import('./iso-639-searcher.vue'),
|
||||
icon: Language,
|
||||
createdAt: new Date('2026-02-21'),
|
||||
category: 'Data',
|
||||
});
|
||||
@@ -0,0 +1,139 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onUnmounted, ref } from 'vue';
|
||||
import { all as allCodes } from 'langs';
|
||||
import useDebouncedRef from '@/composable/debouncedref';
|
||||
import { useFlexSearch } from '@/composable/flexSearch';
|
||||
|
||||
const searchQuery = useDebouncedRef('', 250);
|
||||
const langsSearchData = allCodes();
|
||||
const limit = ref(20);
|
||||
const { searchResult } = useFlexSearch({
|
||||
search: searchQuery,
|
||||
data: langsSearchData,
|
||||
options: {
|
||||
keys: [{ name: 'name', weight: 2 }, { name: '1', weight: 3 }, { name: '2T', weight: 2 }, { name: '2B', weight: 2 }, { name: '3', weight: 2 }, 'local'],
|
||||
},
|
||||
limit,
|
||||
});
|
||||
|
||||
// Batch loading logic for search results
|
||||
const RESULTS_PER_BATCH = 2; // Show 2 results per batch
|
||||
const visibleResultsCount = ref(RESULTS_PER_BATCH); // Start with first batch
|
||||
let loadingInterval: NodeJS.Timeout | null = null;
|
||||
|
||||
// Computed property for visible search results
|
||||
const visibleSearchResults = computed(() => {
|
||||
return searchResult.value.slice(0, visibleResultsCount.value);
|
||||
});
|
||||
|
||||
// Function to stop automated loading
|
||||
function stopAutomatedLoading() {
|
||||
if (loadingInterval) {
|
||||
clearInterval(loadingInterval);
|
||||
loadingInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to start automated loading
|
||||
function startAutomatedLoading() {
|
||||
// Clear any existing interval
|
||||
if (loadingInterval) {
|
||||
clearInterval(loadingInterval);
|
||||
}
|
||||
|
||||
// Reset visible count when starting new search
|
||||
visibleResultsCount.value = RESULTS_PER_BATCH;
|
||||
|
||||
// Start loading batches every 150ms
|
||||
loadingInterval = setInterval(() => {
|
||||
if (visibleResultsCount.value < searchResult.value.length) {
|
||||
visibleResultsCount.value = Math.min(
|
||||
visibleResultsCount.value + RESULTS_PER_BATCH,
|
||||
searchResult.value.length,
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Stop loading when all results are visible
|
||||
stopAutomatedLoading();
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
|
||||
// Watch for changes in search results to restart batching
|
||||
watch(searchResult, (newResults) => {
|
||||
if (newResults.length > 0) {
|
||||
nextTick(() => {
|
||||
startAutomatedLoading();
|
||||
});
|
||||
}
|
||||
else {
|
||||
stopAutomatedLoading();
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
// Clean up on component unmount
|
||||
onUnmounted(() => {
|
||||
stopAutomatedLoading();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div mx-auto max-w-2400px important:flex-1>
|
||||
<div mx-auto max-w-600px flex justify-center gap-3>
|
||||
<c-input-text v-model:value="searchQuery" placeholder="Search iso-639 language code by iso-1, iso-2T/2B, iso-3, name...">
|
||||
<template #prefix>
|
||||
<icon-mdi-search mr-6px color-black op-70 dark:color-white />
|
||||
</template>
|
||||
</c-input-text>
|
||||
<n-form-item label="Max results:" label-placement="left">
|
||||
<n-input-number-i18n v-model:value="limit" :min="1" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<div v-if="searchQuery.trim().length > 0">
|
||||
<div v-if="searchResult.length === 0" mt-4 text-20px font-bold>
|
||||
No results
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div mt-4 text-20px font-bold>
|
||||
Search Results
|
||||
</div>
|
||||
|
||||
<n-table>
|
||||
<thead>
|
||||
<th>iso-639-1</th>
|
||||
<th>iso-639-2T/2B</th>
|
||||
<th>iso-639-3</th>
|
||||
<th>English and local name</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(result, ix) in visibleSearchResults" :key="ix">
|
||||
<td>
|
||||
<input-copyable :value="result[1]" :readonly="true" />
|
||||
</td>
|
||||
<td>
|
||||
<input-copyable label-position="left" label="2B:" :value="result['2B']" :readonly="true" mb-1 />
|
||||
<input-copyable label-position="left" label="2T:" :value="result['2T']" :readonly="true" />
|
||||
</td>
|
||||
<td>
|
||||
<input-copyable :value="result['3']" :readonly="true" />
|
||||
</td>
|
||||
<td>
|
||||
<input-copyable label-position="left" label="ENG:" :value="result.name" :readonly="true" mb-1 />
|
||||
<input-copyable :value="result.local" :readonly="true" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
|
||||
<!-- Loading indicator when more results are coming -->
|
||||
<div v-if="visibleResultsCount < searchResult.length" mt-6 text-center>
|
||||
<div text-14px op-70>
|
||||
Loading more results... ({{ visibleSearchResults.length }}/{{ searchResult.length }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
declare module 'langs' {
|
||||
export function all(): Array<{
|
||||
"name":string
|
||||
"local": string
|
||||
"1": string
|
||||
"2": string
|
||||
"2T":string
|
||||
"2B":string
|
||||
"3":string
|
||||
}>
|
||||
}
|
||||
Reference in new issue
Block a user