LouisLam
4 years ago
9 changed files with 345 additions and 45 deletions
@ -0,0 +1,69 @@ |
|||
<template> |
|||
<span v-if="isNum" ref="output">{{ output }}</span> <span v-if="isNum">{{ unit }}</span> |
|||
<span v-else>{{ value }}</span> |
|||
</template> |
|||
|
|||
<script> |
|||
|
|||
import {sleep} from "../../server/util"; |
|||
|
|||
export default { |
|||
|
|||
props: { |
|||
value: [String, Number], |
|||
time: { |
|||
Number, |
|||
default: 0.3, |
|||
}, |
|||
unit: { |
|||
String, |
|||
default: "ms", |
|||
} |
|||
}, |
|||
|
|||
mounted() { |
|||
this.output = this.value; |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
output: "", |
|||
frameDuration: 30, |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
|
|||
}, |
|||
|
|||
computed: { |
|||
isNum() { |
|||
return typeof this.value === 'number' |
|||
} |
|||
}, |
|||
|
|||
watch: { |
|||
async value(from, to) { |
|||
let diff = to - from; |
|||
let frames = 12; |
|||
let step = Math.floor(diff / frames); |
|||
|
|||
if ((diff > 0 && step < 1) || (diff < 0 && step > 1) || diff === 0) { |
|||
// Lazy to NOT this condition, hahaha. |
|||
} else { |
|||
for (let i = 1; i < frames; i++) { |
|||
this.output += step; |
|||
await sleep(15) |
|||
} |
|||
} |
|||
|
|||
this.output = this.value; |
|||
}, |
|||
}, |
|||
|
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,25 @@ |
|||
<template> |
|||
<span>{{ displayText }}</span> |
|||
</template> |
|||
|
|||
<script> |
|||
import dayjs from "dayjs"; |
|||
import relativeTime from "dayjs/plugin/relativeTime" |
|||
dayjs.extend(relativeTime) |
|||
|
|||
export default { |
|||
props: { |
|||
value: String, |
|||
}, |
|||
|
|||
computed: { |
|||
displayText() { |
|||
return this.value |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
@ -0,0 +1,39 @@ |
|||
<template> |
|||
<span class="badge rounded-pill" :class=" 'bg-' + color ">{{ text }}</span> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
status: Number |
|||
}, |
|||
|
|||
computed: { |
|||
color() { |
|||
if (this.status === 0) { |
|||
return "danger" |
|||
} else if (this.status === 1) { |
|||
return "primary" |
|||
} else { |
|||
return "secondary" |
|||
} |
|||
}, |
|||
|
|||
text() { |
|||
if (this.status === 0) { |
|||
return "Down" |
|||
} else if (this.status === 1) { |
|||
return "Up" |
|||
} else { |
|||
return "Unknown" |
|||
} |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
span { |
|||
width: 45px; |
|||
} |
|||
</style> |
Loading…
Reference in new issue