-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c325db9
commit 6f78c2a
Showing
8 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { onUnmounted, ref } from 'vue' | ||
|
||
export function useMediaQuery(query: string) { | ||
const mediaQueryList = window.matchMedia(query) | ||
const matches = ref(mediaQueryList.matches) | ||
|
||
const changeHandler = (event: MediaQueryListEvent) => { | ||
matches.value = event.matches | ||
} | ||
|
||
mediaQueryList.addEventListener('change', changeHandler) | ||
|
||
onUnmounted(() => mediaQueryList.removeEventListener('change', changeHandler)) | ||
|
||
return matches | ||
} | ||
|
||
// sm | ||
export function useIsSmScreen() { | ||
return useMediaQuery('(min-width: 640px)') | ||
} | ||
|
||
// md | ||
export function useIsMdScreen() { | ||
return useMediaQuery('(min-width: 768px)') | ||
} | ||
|
||
// lg | ||
export function useIsLgScreen() { | ||
return useMediaQuery('(min-width: 1024px)') | ||
} | ||
|
||
// xl | ||
export function useIsXlScreen() { | ||
return useMediaQuery('(min-width: 1280px)') | ||
} | ||
|
||
// 2xl | ||
export function useIs2XlScreen() { | ||
return useMediaQuery('(min-width: 1536px)') | ||
} | ||
|
||
// [0,sm) | ||
export function useIsLessThanSmScreen() { | ||
return useMediaQuery('(max-width: 639px)') | ||
} | ||
|
||
// [sm,md) | ||
export function useIsBetweenSmAndMdScreen() { | ||
return useMediaQuery('(min-width: 640px) and (max-width: 767px)') | ||
} | ||
|
||
// [md,lg) | ||
export function useIsBetweenMdAndLgScreen() { | ||
return useMediaQuery('(min-width: 768px) and (max-width: 1023px)') | ||
} | ||
|
||
// [lg,xl) | ||
export function useIsBetweenLgAndXlScreen() { | ||
return useMediaQuery('(min-width: 1024px) and (max-width: 1279px)') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,3 @@ | |
</router-view> | ||
</div> | ||
</template> | ||
|
||
<style lang="css" scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters