mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-10 05:50:45 +08:00
Merge pull request #233 from nagisa77/codex/add-global-ismobile-compute
Add global isMobile computed util
This commit is contained in:
12
open-isle-cli/src/utils/screen.js
Normal file
12
open-isle-cli/src/utils/screen.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
|
// reactive width value to watch window resize events
|
||||||
|
const width = ref(window.innerWidth)
|
||||||
|
|
||||||
|
// update width on resize
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
width.value = window.innerWidth
|
||||||
|
})
|
||||||
|
|
||||||
|
// global computed property
|
||||||
|
export const isMobile = computed(() => width.value <= 768)
|
||||||
Reference in New Issue
Block a user