it-tools/src/tools/uuid-generator/uuid-generator.vue
2023-05-28 23:29:14 +02:00

45 lines
1.2 KiB
Vue

<script setup lang="ts">
import { v4 as generateUUID } from 'uuid';
import { useCopy } from '@/composable/copy';
import { computedRefreshable } from '@/composable/computedRefreshable';
const count = useStorage('uuid-generator:quantity', 1);
const [uuids, refreshUUIDs] = computedRefreshable(() =>
Array.from({ length: count.value }, () => generateUUID()).join('\n'),
);
const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard' });
</script>
<template>
<div>
<div flex items-center justify-center gap-3>
Quantity :
<n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" />
</div>
<n-input
style="text-align: center; font-family: monospace"
:value="uuids"
type="textarea"
placeholder="Your uuids"
:autosize="{ minRows: 1 }"
readonly
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
my-3
/>
<div flex justify-center gap-3>
<c-button autofocus @click="copy">
Copy
</c-button>
<c-button @click="refreshUUIDs">
Refresh
</c-button>
</div>
</div>
</template>