chore: make class to get the device form factor

This commit is contained in:
Shishkevich D. 2025-03-21 15:09:05 +00:00
parent 510c35f450
commit 6f4eefe601
5 changed files with 11 additions and 6 deletions

View file

@ -781,3 +781,9 @@ class LanguageManager {
return languageFilter.length > 0; return languageFilter.length > 0;
} }
} }
class DeviceUtils {
static isMobile() {
return window.innerWidth <= 768;
}
}

View file

@ -1,6 +1,6 @@
{{define "qrcodeModal"}} {{define "qrcodeModal"}}
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title" <a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
:dialog-style="isMobileQr ? { top: '18px' } : {}" :dialog-style="DeviceUtils.isMobile() ? { top: '18px' } : {}"
:closable="true" :closable="true"
:class="themeSwitcher.currentTheme" :class="themeSwitcher.currentTheme"
:footer="null" width="fit-content"> :footer="null" width="fit-content">
@ -35,7 +35,6 @@
</a-modal> </a-modal>
<script> <script>
const isMobileQr = window.innerWidth <= 768;
const qrModal = { const qrModal = {
title: '', title: '',
dbInbound: new DBInbound(), dbInbound: new DBInbound(),

View file

@ -709,7 +709,7 @@
showAlert: false, showAlert: false,
ipLimitEnable: false, ipLimitEnable: false,
pageSize: 50, pageSize: 50,
isMobile: window.innerWidth <= 768, isMobile: DeviceUtils.isMobile(),
}, },
methods: { methods: {
loading(spinning = true) { loading(spinning = true) {
@ -1473,7 +1473,7 @@
return false return false
}, },
onResize() { onResize() {
this.isMobile = window.innerWidth <= 768; this.isMobile = DeviceUtils.isMobile();
} }
}, },
watch: { watch: {

View file

@ -601,7 +601,7 @@
loadingTip: '{{ i18n "loading"}}', loadingTip: '{{ i18n "loading"}}',
showAlert: false, showAlert: false,
showIp: false, showIp: false,
isMobile: window.innerWidth <= 768 isMobile: DeviceUtils.isMobile()
}, },
methods: { methods: {
loading(spinning, tip = '{{ i18n "loading"}}') { loading(spinning, tip = '{{ i18n "loading"}}') {

View file

@ -877,7 +877,7 @@
refreshing: false, refreshing: false,
restartResult: '', restartResult: '',
showAlert: false, showAlert: false,
isMobile: window.innerWidth <= 768, isMobile: DeviceUtils.isMobile(),
advSettings: 'xraySetting', advSettings: 'xraySetting',
obsSettings: '', obsSettings: '',
cm: null, cm: null,