mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
Improve http status codes performance (#86)
* Improved performance on the Unicode Search page: - Created new flexSearch component (Faster than fuzzySearch). For more information, see https://github.com/nextapps-de/flexsearch - Replaced fuzzySearch with the flexSearch component on the unicode search page - Fixed a bug where the search limit counter didn't have any effect - Reduced the default search limit from 100 to 40 to reduce lag from loading all the ui elements * Added clarification to comment * components.d.ts update * - Replaced FuzzySearch with FlexSearch on the ISO 3166 Searcher page - Reduced the debounce from 500ms to 250ms - Reduced the default search limit from 100 to 20, and fixed a bug where the search limit wasn't applied when the value changed - Added the `readonly` prop to the `input-copyable` field - Added the `readonly` flag to all input copyable fields on the unicode search and iso 3166 searcher pages * Merged new changes to flexSearch * chore: vercel optimisation tentative * - Replaced fuzzysearch with flexsearch - Added a redirect icon to redirect to the MDN documentation for each status code - Added an icon before the category icon to more clearly visualize what the category is about * simplified category icon logic and added search icon --------- Co-authored-by: ShareVB <sharevb@gmail.com>
This commit is contained in:
1 parent
3ed3f90ee7
commit
b77c57e08d
2 files changed
+47
-7
No files matched your search
Vendored
-3
@@ -298,7 +298,6 @@ declare module '@vue/runtime-core' {
|
||||
MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default']
|
||||
MultiLinkDownloader: typeof import('./src/tools/multi-link-downloader/multi-link-downloader.vue')['default']
|
||||
MyIp: typeof import('./src/tools/my-ip/my-ip.vue')['default']
|
||||
NA: typeof import('naive-ui')['NA']
|
||||
NanoidGenerator: typeof import('./src/tools/nanoid-generator/nanoid-generator.vue')['default']
|
||||
NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default']
|
||||
'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default']
|
||||
@@ -307,14 +306,12 @@ declare module '@vue/runtime-core' {
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
|
||||
NginxMemo: typeof import('./src/tools/nginx-memo/nginx-memo.vue')['default']
|
||||
'NginxMemo.content': typeof import('./src/tools/nginx-memo/nginx-memo.content.md')['default']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconCircleArrowUpRight,
|
||||
IconCircleCheck,
|
||||
IconDatabaseExclamation,
|
||||
IconDeviceDesktopExclamation,
|
||||
IconExternalLink,
|
||||
IconInfoCircle,
|
||||
IconSearch,
|
||||
} from '@tabler/icons-vue';
|
||||
import { codesByCategories } from './http-status-codes.constants';
|
||||
import { useFuzzySearch } from '@/composable/fuzzySearch';
|
||||
import { useFlexSearch } from '@/composable/flexSearch';
|
||||
|
||||
const search = ref('');
|
||||
|
||||
const { searchResult } = useFuzzySearch({
|
||||
const { searchResult } = useFlexSearch({
|
||||
search,
|
||||
data: codesByCategories.flatMap(({ codes, category }) => codes.map(code => ({ ...code, category }))),
|
||||
options: {
|
||||
@@ -19,6 +28,32 @@ const codesByCategoryFiltered = computed(() => {
|
||||
|
||||
return [{ category: 'Search results', codes: searchResult.value }];
|
||||
});
|
||||
|
||||
function getCategoryIcon(category: string) {
|
||||
const categoryLower = category.toLowerCase();
|
||||
|
||||
if (categoryLower.includes('1xx')) {
|
||||
return IconInfoCircle;
|
||||
}
|
||||
if (categoryLower.includes('2xx')) {
|
||||
return IconCircleCheck;
|
||||
}
|
||||
if (categoryLower.includes('3xx')) {
|
||||
return IconCircleArrowUpRight;
|
||||
}
|
||||
if (categoryLower.includes('4xx')) {
|
||||
return IconDeviceDesktopExclamation;
|
||||
}
|
||||
if (categoryLower.includes('5xx')) {
|
||||
return IconDatabaseExclamation;
|
||||
}
|
||||
// Default icon for search results or unknown categories
|
||||
return IconSearch;
|
||||
}
|
||||
|
||||
function openMdnDocs(code: number) {
|
||||
window.open(`https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/${code}`, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -30,13 +65,21 @@ const codesByCategoryFiltered = computed(() => {
|
||||
/>
|
||||
|
||||
<div v-for="{ codes, category } of codesByCategoryFiltered" :key="category" mb-8>
|
||||
<div mb-2 text-xl>
|
||||
<div mb-2 flex items-center gap-2 text-xl font-bold>
|
||||
<n-icon :component="getCategoryIcon(category)" size="26" />
|
||||
{{ category }}
|
||||
</div>
|
||||
|
||||
<c-card v-for="{ code, description, name, type } of codes" :key="code" mb-2>
|
||||
<div text-lg font-bold>
|
||||
<div flex items-center gap-2 text-lg font-bold>
|
||||
{{ code }} {{ name }}
|
||||
<div
|
||||
class="flex cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:text-blue-600"
|
||||
title="View MDN documentation"
|
||||
@click="openMdnDocs(code)"
|
||||
>
|
||||
<n-icon :component="IconExternalLink" size="18" />
|
||||
</div>
|
||||
</div>
|
||||
<div op-70>
|
||||
{{ description }} {{ type !== 'HTTP' ? `For ${type}.` : '' }}
|
||||
|
||||
Reference in new issue
Block a user