UUIDv7 generator

This commit is contained in:
nghduc97 2024-06-06 22:15:54 +07:00
parent b430baef40
commit bdc1c84635
No known key found for this signature in database
3 changed files with 6577 additions and 5154 deletions

View file

@ -87,6 +87,7 @@
"unicode-emoji-json": "^0.4.0",
"unplugin-auto-import": "^0.16.4",
"uuid": "^9.0.0",
"uuidv7": "^1.0.0",
"vue": "^3.3.4",
"vue-i18n": "^9.9.1",
"vue-router": "^4.1.6",

11726
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,11 @@
<script setup lang="ts">
import { v1 as generateUuidV1, v3 as generateUuidV3, v4 as generateUuidV4, v5 as generateUuidV5, NIL as nilUuid } from 'uuid';
import { uuidv7 as generateUuidV7 } from 'uuidv7'; // 'uuid' package support for v7 is still in beta
import { useCopy } from '@/composable/copy';
import { computedRefreshable } from '@/composable/computedRefreshable';
import { withDefaultOnError } from '@/utils/defaults';
const versions = ['NIL', 'v1', 'v3', 'v4', 'v5'] as const;
const versions = ['NIL', 'v1', 'v3', 'v4', 'v5', 'v7'] as const;
const version = useStorage<typeof versions[number]>('uuid-generator:version', 'v4');
const count = useStorage('uuid-generator:quantity', 1);
@ -34,6 +35,7 @@ const generators = {
v3: () => generateUuidV3(v35Args.value.name, v35Args.value.namespace),
v4: () => generateUuidV4(),
v5: () => generateUuidV5(v35Args.value.name, v35Args.value.namespace),
v7: () => generateUuidV7(),
};
const [uuids, refreshUUIDs] = computedRefreshable(() => withDefaultOnError(() =>