From f855d08ff06dbc2c583973529afdea672d6263ad Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Thu, 17 Jul 2025 15:51:28 +0800 Subject: [PATCH] Add global isMobile computed util --- open-isle-cli/src/utils/screen.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 open-isle-cli/src/utils/screen.js diff --git a/open-isle-cli/src/utils/screen.js b/open-isle-cli/src/utils/screen.js new file mode 100644 index 000000000..2796da6b3 --- /dev/null +++ b/open-isle-cli/src/utils/screen.js @@ -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)