mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
Merge branch 'up/feat/nanoid-generator' into chore/all-my-stuffs
This commit is contained in:
commit
95708f1ca7
7 files changed
+251
-4
No files matched your search
@@ -357,6 +357,22 @@ tools:
|
||||
title: UUIDs generator
|
||||
description: A Universally Unique Identifier (UUID) is a 128-bit number used to identify information in computer systems. The number of possible UUIDs is 16^32, which is 2^128 or about 3.4x10^38 (which is a lot!).
|
||||
|
||||
nanoid-generator:
|
||||
title: NanoIDs generator
|
||||
description: Generate random, unique, and URL-friendly IDs for your applications.
|
||||
uppercase: Uppercase
|
||||
lowercase: Lowercase
|
||||
numbers: Numbers
|
||||
symbols: Symbols
|
||||
excludeLookalikes: Exclude lookalikes
|
||||
length: Length
|
||||
quantity: Quantity
|
||||
copied: NanoID copied to the clipboard
|
||||
button:
|
||||
copy: Copy
|
||||
refresh: Refresh
|
||||
|
||||
|
||||
ipv4-address-converter:
|
||||
title: IPv4 address converter
|
||||
description: Convert an IP address into decimal, binary, hexadecimal, or even an IPv6 representation of it.
|
||||
|
||||
@@ -177,6 +177,8 @@
|
||||
"monaco-editor": "^0.43.0",
|
||||
"morsee": "^1.0.9",
|
||||
"naive-ui": "^2.35.0",
|
||||
"nanoid": "^5.0.7",
|
||||
"nanoid-dictionary": "^4.3.0",
|
||||
"netmask": "^2.0.2",
|
||||
"netstack.js": "^2.0.0",
|
||||
"nginx-config-formatter": "^1.4.5",
|
||||
|
||||
Generated
+23
-4
@@ -428,6 +428,12 @@ dependencies:
|
||||
naive-ui:
|
||||
specifier: ^2.35.0
|
||||
version: 2.35.0(vue@3.3.4)
|
||||
nanoid:
|
||||
specifier: ^5.0.7
|
||||
version: 5.0.8
|
||||
nanoid-dictionary:
|
||||
specifier: ^4.3.0
|
||||
version: 4.3.0
|
||||
netmask:
|
||||
specifier: ^2.0.2
|
||||
version: 2.0.2
|
||||
@@ -1339,6 +1345,7 @@ packages:
|
||||
/@babel/helper-validator-identifier@7.22.20:
|
||||
resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
dev: true
|
||||
|
||||
/@babel/helper-validator-identifier@7.22.5:
|
||||
resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==}
|
||||
@@ -1439,6 +1446,7 @@ packages:
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@babel/types': 7.23.0
|
||||
dev: true
|
||||
|
||||
/@babel/parser@7.26.2:
|
||||
resolution: {integrity: sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==}
|
||||
@@ -2430,6 +2438,7 @@ packages:
|
||||
'@babel/helper-string-parser': 7.22.5
|
||||
'@babel/helper-validator-identifier': 7.22.20
|
||||
to-fast-properties: 2.0.0
|
||||
dev: true
|
||||
|
||||
/@babel/types@7.26.0:
|
||||
resolution: {integrity: sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==}
|
||||
@@ -5467,7 +5476,7 @@ packages:
|
||||
/@types/lodash-es@4.17.10:
|
||||
resolution: {integrity: sha512-YJP+w/2khSBwbUSFdGsSqmDvmnN3cCKoPOL7Zjle6s30ZtemkkqhjVfFqGwPN7ASil5VyjE2GtyU/yqYY6mC0A==}
|
||||
dependencies:
|
||||
'@types/lodash': 4.14.200
|
||||
'@types/lodash': 4.14.192
|
||||
dev: false
|
||||
|
||||
/@types/lodash.defaultsdeep@4.6.9:
|
||||
@@ -5490,7 +5499,6 @@ packages:
|
||||
|
||||
/@types/lodash@4.14.192:
|
||||
resolution: {integrity: sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==}
|
||||
dev: true
|
||||
|
||||
/@types/lodash@4.14.200:
|
||||
resolution: {integrity: sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==}
|
||||
@@ -6461,11 +6469,11 @@ packages:
|
||||
/@vue/reactivity-transform@3.3.4:
|
||||
resolution: {integrity: sha512-MXgwjako4nu5WFLAjpBnCj/ieqcjE2aJBINUNQzkZQfzIZA4xn+0fV1tIYBJvvva3N3OvKGofRLvQIwEQPpaXw==}
|
||||
dependencies:
|
||||
'@babel/parser': 7.23.0
|
||||
'@babel/parser': 7.22.10
|
||||
'@vue/compiler-core': 3.3.4
|
||||
'@vue/shared': 3.3.4
|
||||
estree-walker: 2.0.2
|
||||
magic-string: 0.30.5
|
||||
magic-string: 0.30.2
|
||||
|
||||
/@vue/reactivity@3.3.4:
|
||||
resolution: {integrity: sha512-kLTDLwd0B1jG08NBF3R5rqULtv/f8x3rOFByTDz4J53ttIQEDmALqKqXY0J+XQeN0aV2FBxY8nJDf88yvOPAqQ==}
|
||||
@@ -12074,9 +12082,20 @@ packages:
|
||||
vueuc: 0.4.51(vue@3.3.4)
|
||||
dev: false
|
||||
|
||||
/nanoid-dictionary@4.3.0:
|
||||
resolution: {integrity: sha512-Xw1+/QnRGWO1KJ0rLfU1xR85qXmAHyLbE3TUkklu9gOIDburP6CsUnLmTaNECGpBh5SHb2uPFmx0VT8UPyoeyw==}
|
||||
dev: false
|
||||
|
||||
/nanoid@3.3.6:
|
||||
resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
/nanoid@5.0.8:
|
||||
resolution: {integrity: sha512-TcJPw+9RV9dibz1hHUzlLVy8N4X9TnwirAjrU08Juo6BNKggzVfP2ZJ/3ZUSq15Xl5i85i+Z89XBO90pB2PghQ==}
|
||||
engines: {node: ^18 || >=20}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/napi-build-utils@1.0.2:
|
||||
resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==}
|
||||
|
||||
@@ -107,6 +107,7 @@ import { tool as torrentToMagnet } from './torrent-to-magnet';
|
||||
import { tool as ttlCalculator } from './ttl-calculator';
|
||||
import { tool as unicodeFormatter } from './unicode-formatter';
|
||||
import { tool as raidCalculator } from './raid-calculator';
|
||||
import { tool as nanoidGenerator } from './nanoid-generator';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -245,6 +246,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
bcrypt,
|
||||
uuidGenerator,
|
||||
ulidGenerator,
|
||||
nanoidGenerator,
|
||||
cypher,
|
||||
bip39,
|
||||
hmacGenerator,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Fingerprint } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.nanoid-generator.title'),
|
||||
path: '/nanoid-generator',
|
||||
description: translate('tools.nanoid-generator.description'),
|
||||
keywords: ['nanoid', 'generator'],
|
||||
component: () => import('./nanoid-generator.vue'),
|
||||
icon: Fingerprint,
|
||||
createdAt: new Date('2024-05-31'),
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { customAlphabet, nanoid } from 'nanoid';
|
||||
import { lowercase, nolookalikes, numbers, uppercase } from 'nanoid-dictionary';
|
||||
|
||||
const symbols = '-_';
|
||||
|
||||
export function createNanoid({
|
||||
length = 21,
|
||||
withLowercase = true,
|
||||
withUppercase = true,
|
||||
withNumbers = true,
|
||||
withSymbols = true,
|
||||
excludeLookalikes = false,
|
||||
}: {
|
||||
length?: number
|
||||
withLowercase?: boolean
|
||||
withUppercase?: boolean
|
||||
withNumbers?: boolean
|
||||
withSymbols?: boolean
|
||||
excludeLookalikes?: boolean
|
||||
}) {
|
||||
let alphabet = '';
|
||||
|
||||
if (!withLowercase && !withUppercase && !withNumbers && !excludeLookalikes && !withSymbols) {
|
||||
return nanoid(length);
|
||||
}
|
||||
|
||||
if (excludeLookalikes) {
|
||||
alphabet = [nolookalikes, withSymbols ? symbols : ''].join('');
|
||||
}
|
||||
|
||||
alphabet = [
|
||||
withLowercase ? lowercase : '',
|
||||
withUppercase ? uppercase : '',
|
||||
withNumbers ? numbers : '',
|
||||
withSymbols ? symbols : '',
|
||||
].join('');
|
||||
|
||||
return customAlphabet(alphabet, length);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<script setup lang="ts">
|
||||
import { InfoCircle } from '@vicons/tabler';
|
||||
import { createNanoid } from './nanoid-generator.service';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
|
||||
const count = useQueryParam({ name: 'count', defaultValue: 1 });
|
||||
const length = useQueryParam({ name: 'length', defaultValue: 21 });
|
||||
const withUppercase = useQueryParam({ name: 'uppercase', defaultValue: true });
|
||||
const withLowercase = useQueryParam({ name: 'lowercase', defaultValue: true });
|
||||
const withNumbers = useQueryParam({ name: 'numbers', defaultValue: true });
|
||||
const withSymbols = useQueryParam({ name: 'symbols', defaultValue: true });
|
||||
const excludeLookalikes = useQueryParam({ name: 'no-lookalikes', defaultValue: false });
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const [nanoIds, refreshNanoIds] = computedRefreshable(() =>
|
||||
withDefaultOnError(
|
||||
() =>
|
||||
Array.from({ length: count.value }, (_ignored) => {
|
||||
const nanoId = createNanoid({
|
||||
length: length.value,
|
||||
withUppercase: withUppercase.value,
|
||||
withLowercase: withLowercase.value,
|
||||
withNumbers: withNumbers.value,
|
||||
withSymbols: withSymbols.value,
|
||||
excludeLookalikes: excludeLookalikes.value,
|
||||
});
|
||||
|
||||
return nanoId();
|
||||
}).join('\n'),
|
||||
'',
|
||||
),
|
||||
);
|
||||
|
||||
const { copy } = useCopy({ source: nanoIds, text: 'NanoIds copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<n-form label-placement="left" label-width="140">
|
||||
<div mb-8 flex justify-center gap-8>
|
||||
<div class="column">
|
||||
<div>
|
||||
<n-text>{{ t('tools.nanoid-generator.uppercase') }}</n-text>
|
||||
<c-tooltip
|
||||
tooltip="ABCDEFGHIJKLMNOPQRSTUVWXYZ" position="bottom"
|
||||
>
|
||||
<n-icon size="20" :component="InfoCircle" />
|
||||
</c-tooltip>
|
||||
<n-switch v-model:value="withUppercase" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<n-text>{{ t('tools.nanoid-generator.lowercase') }}</n-text>
|
||||
<c-tooltip
|
||||
tooltip="abcdefghijklmnopqrstuvwxyz" position="bottom"
|
||||
>
|
||||
<n-icon size="20" :component="InfoCircle" />
|
||||
</c-tooltip>
|
||||
<n-switch v-model:value="withLowercase" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div>
|
||||
<n-text>
|
||||
{{ t('tools.nanoid-generator.numbers') }}
|
||||
</n-text>
|
||||
<c-tooltip
|
||||
tooltip="0123456789" position="bottom"
|
||||
>
|
||||
<n-icon size="20" :component="InfoCircle" />
|
||||
</c-tooltip>
|
||||
<n-switch v-model:value="withNumbers" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<n-text>
|
||||
{{ t('tools.nanoid-generator.symbols') }}
|
||||
</n-text>
|
||||
<c-tooltip
|
||||
tooltip="-_" position="bottom"
|
||||
>
|
||||
<n-icon size="20" :component="InfoCircle" />
|
||||
</c-tooltip>
|
||||
<n-switch v-model:value="withSymbols" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div>
|
||||
<n-text>
|
||||
{{ t('tools.nanoid-generator.excludeLookalikes') }}
|
||||
</n-text>
|
||||
<c-tooltip
|
||||
tooltip="1lI0Oouv5Ss2Z" position="bottom"
|
||||
>
|
||||
<n-icon size="20" :component="InfoCircle" />
|
||||
</c-tooltip>
|
||||
<n-switch v-model:value="excludeLookalikes" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</n-form>
|
||||
|
||||
<div mb-2 flex items-center>
|
||||
<span w-100px>{{ t('tools.nanoid-generator.length') }}</span>
|
||||
<n-input-number v-model:value="length" flex-1 :min="1" :max="100" placeholder="NanoId Length" />
|
||||
</div>
|
||||
<div mb-2 flex items-center>
|
||||
<span w-100px>{{ t('tools.nanoid-generator.quantity') }}</span>
|
||||
<n-input-number v-model:value="count" flex-1 :min="1" :max="50" placeholder="NanoIds quantity" />
|
||||
</div>
|
||||
|
||||
<c-input-text
|
||||
style="text-align: center; font-family: monospace"
|
||||
:value="nanoIds"
|
||||
placeholder="Your uuids"
|
||||
rows="1"
|
||||
autosize
|
||||
readonly
|
||||
raw-text
|
||||
multiline
|
||||
monospace
|
||||
my-3
|
||||
class="uuid-display"
|
||||
/>
|
||||
|
||||
<div flex justify-center gap-3>
|
||||
<c-button autofocus @click="copy()">
|
||||
{{ t('tools.nanoid-generator.button.copy') }}
|
||||
</c-button>
|
||||
<c-button @click="refreshNanoIds">
|
||||
{{ t('tools.nanoid-generator.button.refresh') }}
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.n-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.n-text {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user