aboutsummaryrefslogtreecommitdiff
path: root/src/tools/uuid-generator/uuid-generator.vue
blob: 61dc6bf59860acb52f0adc30bdd782ad292a9f0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
    <div>
        <n-card>
            <n-space align="center" justify="center">
                Quantity :
                <n-input-number v-model:value="count" :min="1" :max="50" />
            </n-space>
            <br />
            <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"
            />
            <br />
            <br />
            <n-space justify="center">
                <n-button @click="copy" secondary autofocus>Copy</n-button>
                <n-button @click="refreshUUIDs" secondary>Refresh</n-button>
            </n-space>
        </n-card>
    </div>
</template>

<script setup lang="ts">
import { useCopy } from '@/composable/copy';
import { ref, watch } from 'vue'
import { v4 as generateUUID } from 'uuid';

const count = ref(1)

const uuids = ref('')

function refreshUUIDs() {
    uuids.value = Array.from({ length: count.value }, () => generateUUID()).join('\n')
}

watch([count], refreshUUIDs)

const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard' })

refreshUUIDs()
</script>

<style lang="less" scoped>
</style>