mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-24 16:56:14 -04:00
feat: UuidGenerator
Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
parent
407669def2
commit
77a6f20b2b
2 changed files with 55 additions and 0 deletions
47
src/routes/tools/UuidGenerator.vue
Normal file
47
src/routes/tools/UuidGenerator.vue
Normal file
|
@ -0,0 +1,47 @@
|
|||
<template>
|
||||
<v-card class="single-card">
|
||||
<v-card-title>Uuid v4 generator</v-card-title>
|
||||
|
||||
<v-card-text>
|
||||
<v-text-field outlined v-model="token" class="centered-input"/>
|
||||
|
||||
<div class="text-center">
|
||||
<v-btn @click="refreshBool = !refreshBool" depressed class="mr-4">Refresh</v-btn>
|
||||
<v-btn @click="copyToken()" depressed>Copy token</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {copyToClipboard} from "../../utils/helpers";
|
||||
|
||||
const noop = () => {
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "UuidGenerator",
|
||||
data: () => ({
|
||||
refreshBool: true
|
||||
}),
|
||||
methods: {
|
||||
copyToken() {
|
||||
copyToClipboard(this.token);
|
||||
this.$toast.success('Copied to clipboard.')
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
token() {
|
||||
if (this.refreshBool) noop(); // To force recomputation
|
||||
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
::v-deep .centered-input input {
|
||||
text-align: center
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue