mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-01-04 10:27:29 -08:00
a927f5cd15
Apply suggestions from code review Co-authored-by: Nelson Chan <[email protected]>
39 lines
770 B
JavaScript
39 lines
770 B
JavaScript
export default {
|
|
|
|
data() {
|
|
return {
|
|
windowWidth: window.innerWidth,
|
|
};
|
|
},
|
|
|
|
created() {
|
|
window.addEventListener("resize", this.onResize);
|
|
this.updateBody();
|
|
},
|
|
|
|
methods: {
|
|
/** Handle screen resize */
|
|
onResize() {
|
|
this.windowWidth = window.innerWidth;
|
|
this.updateBody();
|
|
},
|
|
|
|
/** Add css-class "mobile" to body if needed */
|
|
updateBody() {
|
|
if (this.isMobile) {
|
|
document.body.classList.add("mobile");
|
|
} else {
|
|
document.body.classList.remove("mobile");
|
|
}
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
isMobile() {
|
|
return this.windowWidth <= 767.98;
|
|
},
|
|
},
|
|
|
|
};
|