Skip to content

Commit 7856df3

Browse files
committed
feat: add label for units
1 parent 66dd351 commit 7856df3

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed

components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ declare module '@vue/runtime-core' {
133133
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
134134
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
135135
NButton: typeof import('naive-ui')['NButton']
136+
NCheckbox: typeof import('naive-ui')['NCheckbox']
136137
NCode: typeof import('naive-ui')['NCode']
137138
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
138139
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
140+
NDivider: typeof import('naive-ui')['NDivider']
139141
NEllipsis: typeof import('naive-ui')['NEllipsis']
140142
NForm: typeof import('naive-ui')['NForm']
141143
NFormItem: typeof import('naive-ui')['NFormItem']
142144
NH1: typeof import('naive-ui')['NH1']
143145
NH3: typeof import('naive-ui')['NH3']
144146
NIcon: typeof import('naive-ui')['NIcon']
147+
NInput: typeof import('naive-ui')['NInput']
145148
NInputNumber: typeof import('naive-ui')['NInputNumber']
146149
NLayout: typeof import('naive-ui')['NLayout']
147150
NLayoutSider: typeof import('naive-ui')['NLayoutSider']

src/tools/data-storage-unit-converter/data-storage-unit-converter.vue

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,34 @@ const input = ref<{ size: string; unit: string }>({ size: '0', unit: 'KB' });
66
const output = ref<{ unit: string; precision: number; appendUnit: boolean }>({ unit: 'MB', precision: 3, appendUnit: false });
77
88
const allUnits = [
9-
'iB', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB',
10-
'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB',
11-
'b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'];
9+
{ value: 'B', label: 'Bytes (B)' },
10+
{ value: 'b', label: 'Bits (bit)' },
11+
{ value: 'iB', label: 'Bibytes (iB)' },
12+
{ value: 'KB', label: 'Kilobytes (KB)' },
13+
{ value: 'Kb', label: 'Kilobits (Kbit)' },
14+
{ value: 'KiB', label: 'Kibibytes (KiB)' },
15+
{ value: 'MB', label: 'Megabytes (MB)' },
16+
{ value: 'Mb', label: 'Megabits (Mbit)' },
17+
{ value: 'MiB', label: 'Mebibytes (MiB)' },
18+
{ value: 'GB', label: 'Gigabytes (GB)' },
19+
{ value: 'Gb', label: 'Gigabits (Gbit)' },
20+
{ value: 'GiB', label: 'Gibibytes (GiB)' },
21+
{ value: 'TB', label: 'Terabytes (TB)' },
22+
{ value: 'Tb', label: 'Terabits (Tbit)' },
23+
{ value: 'TiB', label: 'Tebibytes (TiB)' },
24+
{ value: 'PB', label: 'Petabytes (PB)' },
25+
{ value: 'Pb', label: 'Petabits (Pbit)' },
26+
{ value: 'PiB', label: 'Pebibytes (PiB)' },
27+
{ value: 'EB', label: 'Exabytes (EB)' },
28+
{ value: 'Eb', label: 'Exabits (Ebit)' },
29+
{ value: 'EiB', label: 'Exbibytes (EiB)' },
30+
{ value: 'ZB', label: 'Zettabytes (ZB)' },
31+
{ value: 'Zb', label: 'Zettabits (Zbit)' },
32+
{ value: 'ZiB', label: 'Zebibytes (ZiB)' },
33+
{ value: 'YB', label: 'Yottabytes (YB)' },
34+
{ value: 'Yb', label: 'Yottabits (Ybit)' },
35+
{ value: 'YiB', label: 'Yobibytes (YiB)' },
36+
];
1237
1338
const convertedValue = computed(() => {
1439
try {
@@ -51,7 +76,7 @@ const convertedValue = computed(() => {
5176
/>
5277

5378
<n-form-item label="Precision:" label-placement="left">
54-
<n-input-number v-model:value="output.precision" placeholder="Precision..." :max="10" :min="0" />
79+
<n-input-number v-model:value="output.precision" style="width:100px" placeholder="Precision..." :max="10" :min="0" />
5580
</n-form-item>
5681

5782
<n-checkbox v-model:checked="output.appendUnit">

src/tools/data-transfer-rate-converter/data-transfer-rate-converter.vue

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,36 @@ import { type AllSupportedUnits, type BitsUnits, displayStorageAndRateUnits } fr
44
import { amountTransferable, neededRate, transferTimeSeconds } from './data-transfer-rate-converter.service';
55
66
const allStorateUnits = [
7-
'iB', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB',
8-
'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
9-
const allBitsUnits = ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'];
7+
{ value: 'B', label: 'Bytes (B)' },
8+
{ value: 'iB', label: 'Bibytes (iB)' },
9+
{ value: 'KB', label: 'Kilobytes (KB)' },
10+
{ value: 'KiB', label: 'Kibibytes (KiB)' },
11+
{ value: 'MB', label: 'Megabytes (MB)' },
12+
{ value: 'MiB', label: 'Mebibytes (MiB)' },
13+
{ value: 'GB', label: 'Gigabytes (GB)' },
14+
{ value: 'GiB', label: 'Gibibytes (GiB)' },
15+
{ value: 'TB', label: 'Terabytes (TB)' },
16+
{ value: 'TiB', label: 'Tebibytes (TiB)' },
17+
{ value: 'PB', label: 'Petabytes (PB)' },
18+
{ value: 'PiB', label: 'Pebibytes (PiB)' },
19+
{ value: 'EB', label: 'Exabytes (EB)' },
20+
{ value: 'EiB', label: 'Exbibytes (EiB)' },
21+
{ value: 'ZB', label: 'Zettabytes (ZB)' },
22+
{ value: 'ZiB', label: 'Zebibytes (ZiB)' },
23+
{ value: 'YB', label: 'Yottabytes (YB)' },
24+
{ value: 'YiB', label: 'Yobibytes (YiB)' },
25+
];
26+
const allBitsUnits = [
27+
{ value: 'b', label: 'Bits (bit)' },
28+
{ value: 'Kb', label: 'Kilobits (Kbit)' },
29+
{ value: 'Mb', label: 'Megabits (Mbit)' },
30+
{ value: 'Gb', label: 'Gigabits (Gbit)' },
31+
{ value: 'Tb', label: 'Terabits (Tbit)' },
32+
{ value: 'Pb', label: 'Petabits (Pbit)' },
33+
{ value: 'Eb', label: 'Exabits (Ebit)' },
34+
{ value: 'Zb', label: 'Zettabits (Zbit)' },
35+
{ value: 'Yb', label: 'Yottabits (Ybit)' },
36+
];
1037
1138
function convertToTimeDisplay(seconds: number) {
1239
if (seconds === 0) {

0 commit comments

Comments
 (0)