it-tools/src/tools/uuid-generator/uuid-generator.vue

42 lines
1.1 KiB
Vue
Raw Normal View History

2022-04-04 21:46:35 +02:00
<template>
2023-05-27 17:36:15 +02:00
<div>
<div flex items-center justify-center gap-3>
Quantity :
<n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" />
2023-05-27 17:36:15 +02:00
</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"
2023-05-27 17:36:15 +02:00
my-3
/>
2023-05-27 17:36:15 +02:00
<div flex justify-center gap-3>
<c-button autofocus @click="copy"> Copy </c-button>
<c-button @click="refreshUUIDs"> Refresh </c-button>
2023-05-27 17:36:15 +02:00
</div>
</div>
2022-04-04 21:46:35 +02:00
</template>
<script setup lang="ts">
import { useCopy } from '@/composable/copy';
import { v4 as generateUUID } from 'uuid';
import { computedRefreshable } from '@/composable/computedRefreshable';
2022-04-04 21:46:35 +02:00
const count = useStorage('uuid-generator:quantity', 1);
2022-04-04 21:46:35 +02:00
const [uuids, refreshUUIDs] = computedRefreshable(() =>
Array.from({ length: count.value }, () => generateUUID()).join('\n'),
);
2022-04-04 21:46:35 +02:00
2022-04-22 23:31:40 +02:00
const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard' });
2022-04-04 21:46:35 +02:00
</script>