2022-03-31 00:33:29 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-04-04 00:25:29 +02:00
|
|
|
<n-card>
|
|
|
|
<n-form label-placement="left" label-width="140">
|
|
|
|
<n-space justify="center" item-style="padding: 0" :size="0">
|
|
|
|
<div>
|
|
|
|
<n-form-item label="Uppercase (ABC...)">
|
|
|
|
<n-switch v-model:value="withUppercase" />
|
|
|
|
</n-form-item>
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
<n-form-item label="Lowercase (abc...)">
|
|
|
|
<n-switch v-model:value="withLowercase" />
|
|
|
|
</n-form-item>
|
|
|
|
</div>
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
<div>
|
|
|
|
<n-form-item label="Numbers (012...)">
|
|
|
|
<n-switch v-model:value="withNumbers" />
|
|
|
|
</n-form-item>
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
<n-form-item label="Symbols (;-!...)">
|
|
|
|
<n-switch v-model:value="withSymbols" />
|
|
|
|
</n-form-item>
|
|
|
|
</div>
|
|
|
|
</n-space>
|
|
|
|
</n-form>
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
<n-form-item :label="`Length (${length})`" label-placement="left">
|
|
|
|
<n-slider v-model:value="length" :step="1" :min="1" :max="512" />
|
|
|
|
</n-form-item>
|
2022-03-31 00:33:29 +02:00
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
<n-input
|
|
|
|
style="text-align: center;"
|
|
|
|
v-model:value="token"
|
|
|
|
type="textarea"
|
|
|
|
placeholder="The token..."
|
|
|
|
: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="refreshToken" secondary>Refresh</n-button>
|
|
|
|
</n-space>
|
|
|
|
</n-card>
|
2022-03-31 00:33:29 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-04-04 00:25:29 +02:00
|
|
|
import { useCopy } from '@/composable/copy';
|
2022-03-31 00:33:29 +02:00
|
|
|
import { ref, watch } from 'vue';
|
2022-04-04 00:25:29 +02:00
|
|
|
import { createToken } from './token-generator.service';
|
|
|
|
|
2022-03-31 00:33:29 +02:00
|
|
|
|
|
|
|
const token = ref('')
|
|
|
|
const length = ref(64)
|
2022-04-04 00:25:29 +02:00
|
|
|
const { copy } = useCopy({ source: token, text: 'Token copied to the clipboard' })
|
2022-03-31 00:33:29 +02:00
|
|
|
|
|
|
|
const withUppercase = ref(true)
|
|
|
|
const withLowercase = ref(true)
|
|
|
|
const withNumbers = ref(true)
|
|
|
|
const withSymbols = ref(false)
|
|
|
|
|
2022-04-04 00:25:29 +02:00
|
|
|
watch([withUppercase, withLowercase, withNumbers, withSymbols, length], refreshToken)
|
2022-03-31 00:33:29 +02:00
|
|
|
|
|
|
|
function refreshToken() {
|
2022-04-04 00:25:29 +02:00
|
|
|
token.value = createToken({
|
|
|
|
length: length.value,
|
|
|
|
withUppercase: withUppercase.value,
|
|
|
|
withLowercase: withLowercase.value,
|
|
|
|
withNumbers: withNumbers.value,
|
|
|
|
withSymbols: withSymbols.value,
|
|
|
|
})
|
2022-03-31 00:33:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
refreshToken()
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|