mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 13:34:04 +03:00
1 parent
fb8a1eb5b1
commit
dfb92f2441
2 files changed
+12
-5
No files matched your search
@@ -92,13 +92,20 @@ function update(key: string) {
|
|||||||
.value();
|
.value();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const converter = unitsconverter[converterType.value](value).from(key);
|
const mapUnit = (unit: string) => {
|
||||||
|
// npm units-converter uses wrong symbol for miles per hour, so we need to fix it
|
||||||
|
if (converterType.value === 'speed' && unit === 'mi/h') {
|
||||||
|
return 'm/h';
|
||||||
|
}
|
||||||
|
return unit;
|
||||||
|
};
|
||||||
|
const converter = unitsconverter[converterType.value](value).from(mapUnit(key));
|
||||||
|
|
||||||
_.chain(units)
|
_.chain(units)
|
||||||
.omit(key)
|
.omit(mapUnit(key))
|
||||||
.forEach(({ unit }) => {
|
.forEach(({ unit }) => {
|
||||||
try {
|
try {
|
||||||
units[unit].ref = converter.to(unit).value;
|
units[unit].ref = converter.to(mapUnit(unit)).value;
|
||||||
}
|
}
|
||||||
catch (e: any) {
|
catch (e: any) {
|
||||||
units[unit].ref = 0;
|
units[unit].ref = 0;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import UnitsConverter from '@/components/UnitsConverter.vue';
|
|||||||
const supportedUnits = {
|
const supportedUnits = {
|
||||||
'm/s': 'meter per second',
|
'm/s': 'meter per second',
|
||||||
'km/h': 'kilometer per hour',
|
'km/h': 'kilometer per hour',
|
||||||
'm/h': 'meter per hour',
|
'mi/h': 'miles per hour',
|
||||||
'knot': 'knot',
|
'knot': 'knot',
|
||||||
'ft/s': 'feet per second',
|
'ft/s': 'feet per second',
|
||||||
}; ;
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in new issue
Block a user