aboutsummaryrefslogtreecommitdiff
path: root/src/tools/token-generator/token-generator.tool.vue
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-01-28 21:06:16 +0100
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-01-28 21:06:16 +0100
commitdb817a2459e23bd096274a7f91815d613d5f7ff4 (patch)
tree5b5dc1be0f6301f02db81df2b180cf41d82ad64c /src/tools/token-generator/token-generator.tool.vue
parent119041c1853d44e000f57b294ff202abffbefab4 (diff)
downloadit-tools-db817a2459e23bd096274a7f91815d613d5f7ff4.tar.gz
it-tools-db817a2459e23bd096274a7f91815d613d5f7ff4.tar.zst
it-tools-db817a2459e23bd096274a7f91815d613d5f7ff4.zip
refactor(tools): config in query params
Diffstat (limited to 'src/tools/token-generator/token-generator.tool.vue')
-rw-r--r--src/tools/token-generator/token-generator.tool.vue15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/tools/token-generator/token-generator.tool.vue b/src/tools/token-generator/token-generator.tool.vue
index 25bfea2..c2dcb0f 100644
--- a/src/tools/token-generator/token-generator.tool.vue
+++ b/src/tools/token-generator/token-generator.tool.vue
@@ -54,18 +54,19 @@
<script setup lang="ts">
import { useCopy } from '@/composable/copy';
import { ref, watch } from 'vue';
+import { useQueryParam } from '@/composable/queryParams';
import { createToken } from './token-generator.service';
const token = ref('');
-const length = ref(64);
+const length = useQueryParam({ name: 'length', defaultValue: 64 });
const { copy } = useCopy({ source: token, text: 'Token copied to the clipboard' });
-const withUppercase = ref(true);
-const withLowercase = ref(true);
-const withNumbers = ref(true);
-const withSymbols = ref(false);
+const withUppercase = useQueryParam({ name: 'uppercase', defaultValue: true });
+const withLowercase = useQueryParam({ name: 'lowercase', defaultValue: true });
+const withNumbers = useQueryParam({ name: 'numbers', defaultValue: true });
+const withSymbols = useQueryParam({ name: 'symbols', defaultValue: false });
-watch([withUppercase, withLowercase, withNumbers, withSymbols, length], refreshToken);
+watch([withUppercase, withLowercase, withNumbers, withSymbols, length], refreshToken, { immediate: true });
function refreshToken() {
token.value = createToken({
@@ -76,6 +77,4 @@ function refreshToken() {
withSymbols: withSymbols.value,
});
}
-
-refreshToken();
</script>