mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 06:55:06 -04:00
feat(new-tool): http status codes
This commit is contained in:
parent
6fb4994603
commit
8355bd2ae4
6 changed files with 525 additions and 0 deletions
60
src/tools/http-status-codes/http-status-codes.vue
Normal file
60
src/tools/http-status-codes/http-status-codes.vue
Normal file
|
@ -0,0 +1,60 @@
|
|||
<template>
|
||||
<div>
|
||||
<n-form-item :show-label="false">
|
||||
<n-input
|
||||
v-model:value="search"
|
||||
placeholder="Search http status..."
|
||||
size="large"
|
||||
autofocus
|
||||
mb-10
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
>
|
||||
<template #prefix>
|
||||
<n-icon :component="SearchRound" />
|
||||
</template>
|
||||
</n-input>
|
||||
</n-form-item>
|
||||
|
||||
<div v-for="{ codes, category } of codesByCategoryFiltered" :key="category" mb-8>
|
||||
<n-h2> {{ category }} </n-h2>
|
||||
|
||||
<n-space vertical :size="20">
|
||||
<n-card v-for="{ code, description, name, type } of codes" :key="code">
|
||||
<n-space align="center">
|
||||
<n-text strong text-lg> {{ code }} {{ name }} </n-text>
|
||||
</n-space>
|
||||
<n-text depth="3">{{ description }} {{ type !== 'HTTP' ? `For ${type}.` : '' }}</n-text>
|
||||
</n-card>
|
||||
</n-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useFuzzySearch } from '@/composable/fuzzySearch';
|
||||
import _ from 'lodash';
|
||||
import { SearchRound } from '@vicons/material';
|
||||
import { codesByCategories } from './http-status-codes.constants';
|
||||
|
||||
const search = ref('');
|
||||
|
||||
const { searchResult } = useFuzzySearch({
|
||||
search,
|
||||
data: codesByCategories.flatMap(({ codes, category }) => codes.map((code) => ({ ...code, category }))),
|
||||
options: {
|
||||
keys: [{ name: 'code', weight: 3 }, { name: 'name', weight: 2 }, 'description', 'category'],
|
||||
},
|
||||
});
|
||||
|
||||
const codesByCategoryFiltered = computed(() => {
|
||||
if (!search.value) {
|
||||
return codesByCategories;
|
||||
}
|
||||
|
||||
return [{ category: 'Search results', codes: searchResult.value }];
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
Loading…
Add table
Add a link
Reference in a new issue