File tree Expand file tree Collapse file tree
adminforth/spa/src/stores Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { ref , computed } from 'vue'
1+ import { ref , computed , onMounted , onUnmounted } from 'vue'
22import { defineStore } from 'pinia'
33import { callAdminForthApi } from '@/utils' ;
44import websocket from '@/websocket' ;
@@ -21,6 +21,19 @@ export const useCoreStore = defineStore('core', () => {
2121 const userData : Ref < UserData | null > = ref ( null ) ;
2222 const isResourceFetching = ref ( false ) ;
2323 const isInternetError = ref ( false ) ;
24+ const screenWidth = ref ( window . innerWidth ) ;
25+
26+ onMounted ( ( ) => {
27+ window . addEventListener ( 'resize' , updateWidth ) ;
28+ } ) ;
29+ onUnmounted ( ( ) => {
30+ window . removeEventListener ( 'resize' , updateWidth ) ;
31+ } ) ;
32+
33+ const isMobile = computed ( ( ) => screenWidth . value <= 768 ) ;
34+ const updateWidth = ( ) => {
35+ screenWidth . value = window . innerWidth
36+ }
2437
2538 const resourceColumnsWithFilters = computed ( ( ) => {
2639 if ( ! resource . value ) {
@@ -261,5 +274,6 @@ export const useCoreStore = defineStore('core', () => {
261274 isResourceFetching,
262275 isIos,
263276 isInternetError,
277+ isMobile,
264278 }
265279} )
You can’t perform that action at this time.
0 commit comments