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

45 lines
1.3 KiB
Vue
Raw Normal View History

2022-04-04 21:46:35 +02:00
<template>
2022-04-15 23:10:47 +02:00
<div>
<n-card>
2022-04-22 23:31:40 +02:00
<n-space align="center" justify="center">
2022-04-15 23:10:47 +02:00
Quantity :
2022-04-22 23:31:40 +02:00
<n-input-number v-model:value="count" :min="1" :max="50" />
2022-04-15 23:10:47 +02:00
</n-space>
2022-04-22 23:31:40 +02:00
<br />
2022-04-15 23:10:47 +02:00
<n-input
2022-04-22 23:31:40 +02:00
style="text-align: center; font-family: monospace"
2022-04-15 23:10:47 +02:00
:value="uuids"
type="textarea"
placeholder="Your uuids"
:autosize="{ minRows: 1 }"
readonly
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
2022-04-22 23:31:40 +02:00
<br />
<br />
2022-04-15 23:10:47 +02:00
<n-space justify="center">
2022-04-22 23:31:40 +02:00
<n-button secondary autofocus @click="copy"> Copy </n-button>
<n-button secondary @click="refreshUUIDs"> Refresh </n-button>
2022-04-15 23:10:47 +02:00
</n-space>
</n-card>
</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 { useQueryParam } from '@/composable/queryParams';
import { computedRefreshable } from '@/composable/computedRefreshable';
2022-04-04 21:46:35 +02:00
const count = useQueryParam({ defaultValue: 1, name: 'count' });
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>