mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-21 15:26:15 -04:00
refactor(uuid-generator): now using computedRefreshable
This commit is contained in:
parent
cf16cb195d
commit
9b4f7727f2
1 changed files with 4 additions and 10 deletions
|
@ -30,21 +30,15 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useCopy } from '@/composable/copy';
|
import { useCopy } from '@/composable/copy';
|
||||||
import { ref, watch } from 'vue';
|
|
||||||
import { v4 as generateUUID } from 'uuid';
|
import { v4 as generateUUID } from 'uuid';
|
||||||
import { useQueryParam } from '@/composable/queryParams';
|
import { useQueryParam } from '@/composable/queryParams';
|
||||||
|
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||||
|
|
||||||
const count = useQueryParam({ defaultValue: 1, name: 'count' });
|
const count = useQueryParam({ defaultValue: 1, name: 'count' });
|
||||||
|
|
||||||
const uuids = ref('');
|
const [uuids, refreshUUIDs] = computedRefreshable(() =>
|
||||||
|
Array.from({ length: count.value }, () => generateUUID()).join('\n'),
|
||||||
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' });
|
const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard' });
|
||||||
|
|
||||||
refreshUUIDs();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue