mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +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();
|
||||
}
|
||||
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)
|
||||
.omit(key)
|
||||
.omit(mapUnit(key))
|
||||
.forEach(({ unit }) => {
|
||||
try {
|
||||
units[unit].ref = converter.to(unit).value;
|
||||
units[unit].ref = converter.to(mapUnit(unit)).value;
|
||||
}
|
||||
catch (e: any) {
|
||||
units[unit].ref = 0;
|
||||
|
||||
@@ -4,10 +4,10 @@ import UnitsConverter from '@/components/UnitsConverter.vue';
|
||||
const supportedUnits = {
|
||||
'm/s': 'meter per second',
|
||||
'km/h': 'kilometer per hour',
|
||||
'm/h': 'meter per hour',
|
||||
'mi/h': 'miles per hour',
|
||||
'knot': 'knot',
|
||||
'ft/s': 'feet per second',
|
||||
}; ;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in new issue
Block a user