2022-04-12 14:27:52 +02:00
|
|
|
<template>
|
2022-04-15 23:10:47 +02:00
|
|
|
<div>
|
|
|
|
<n-card>
|
2022-04-24 23:22:52 +02:00
|
|
|
<div v-if="styleStore.isSmallScreen">
|
|
|
|
<n-input-group>
|
|
|
|
<n-input-group-label style="flex: 0 0 120px"> Input number: </n-input-group-label>
|
|
|
|
<n-input-number v-model:value="inputNumber" min="0" style="width: 100%" />
|
|
|
|
</n-input-group>
|
|
|
|
<n-input-group>
|
|
|
|
<n-input-group-label style="flex: 0 0 120px"> Input base: </n-input-group-label>
|
|
|
|
<n-input-number v-model:value="inputBase" max="64" min="2" style="width: 100%" />
|
|
|
|
</n-input-group>
|
|
|
|
</div>
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group v-else>
|
|
|
|
<n-input-group-label style="flex: 0 0 120px"> Input number: </n-input-group-label>
|
|
|
|
<n-input-number v-model:value="inputNumber" min="0" />
|
|
|
|
<n-input-group-label style="flex: 0 0 120px"> Input base: </n-input-group-label>
|
|
|
|
<n-input-number v-model:value="inputBase" max="64" min="2" />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-input-group>
|
|
|
|
<n-divider />
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-input-group>
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 170px"> Binary (2): </n-input-group-label>
|
2022-04-22 23:31:40 +02:00
|
|
|
<input-copyable :value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: 2 })" readonly />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-input-group>
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-input-group>
|
2022-05-09 14:38:54 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 170px"> Octal (8): </n-input-group-label>
|
2022-04-22 23:31:40 +02:00
|
|
|
<input-copyable :value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: 8 })" readonly />
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-input-group>
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-input-group>
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 170px"> Decimal (10): </n-input-group-label>
|
2022-04-16 01:15:23 +02:00
|
|
|
<input-copyable
|
2022-04-15 23:10:47 +02:00
|
|
|
:value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: 10 })"
|
|
|
|
readonly
|
|
|
|
/>
|
|
|
|
</n-input-group>
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-input-group>
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 170px"> Hexadecimal (16): </n-input-group-label>
|
2022-04-16 01:15:23 +02:00
|
|
|
<input-copyable
|
2022-04-15 23:10:47 +02:00
|
|
|
:value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: 16 })"
|
|
|
|
readonly
|
|
|
|
/>
|
|
|
|
</n-input-group>
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-15 23:10:47 +02:00
|
|
|
<n-input-group>
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 170px"> Base64 (64): </n-input-group-label>
|
2022-04-16 01:15:23 +02:00
|
|
|
<input-copyable
|
2022-04-15 23:10:47 +02:00
|
|
|
:value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: 64 })"
|
|
|
|
readonly
|
|
|
|
/>
|
|
|
|
</n-input-group>
|
|
|
|
<n-input-group>
|
2022-04-24 23:22:52 +02:00
|
|
|
<n-input-group-label style="flex: 0 0 85px"> Custom: </n-input-group-label>
|
|
|
|
<n-input-number v-model:value="outputBase" style="flex: 0 0 86px" max="64" min="2" />
|
2022-04-16 01:15:23 +02:00
|
|
|
<input-copyable
|
2022-04-15 23:10:47 +02:00
|
|
|
:value="convertBase({ value: String(inputNumber), fromBase: inputBase, toBase: outputBase })"
|
|
|
|
readonly
|
|
|
|
/>
|
|
|
|
</n-input-group>
|
|
|
|
</n-card>
|
|
|
|
</div>
|
2022-04-12 14:27:52 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-04-22 23:31:40 +02:00
|
|
|
import { ref } from 'vue';
|
2022-08-04 22:46:50 +02:00
|
|
|
import { useStyleStore } from '@/stores/style.store';
|
2022-04-22 23:31:40 +02:00
|
|
|
import { convertBase } from './integer-base-converter.model';
|
|
|
|
import InputCopyable from '../../components/InputCopyable.vue';
|
2022-04-24 23:22:52 +02:00
|
|
|
|
|
|
|
const styleStore = useStyleStore();
|
2022-04-12 14:27:52 +02:00
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const inputNumber = ref(42);
|
|
|
|
const inputBase = ref(10);
|
|
|
|
const outputBase = ref(42);
|
2022-04-12 14:27:52 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.n-input-group:not(:first-child) {
|
2022-04-22 23:31:40 +02:00
|
|
|
margin-top: 5px;
|
2022-04-12 14:27:52 +02:00
|
|
|
}
|
2022-04-22 23:31:40 +02:00
|
|
|
</style>
|