Skip to content

Commit

Permalink
feat: device detection in screen size middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
raulwwq0 committed Jul 6, 2023
1 parent 3ead4af commit b45cec8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/web/middleware/valid-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ enum ScreenSize {

export default defineNuxtRouteMiddleware(() => {
const { width } = useWindowSize();
const { isDesktop } = useDevice();

const isValidResolutions = width.value >= ScreenSize.WIDTH;

if (!isValidResolutions) {
if (!isDesktop || !isValidResolutions) {
return navigateTo('/non-supported-screen');
}
});
4 changes: 4 additions & 0 deletions apps/web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineNuxtConfig({
'@nuxtjs/supabase',
'@nuxtjs/robots',
'@nuxtjs/fontaine',
'@nuxtjs/device',
'@vueuse/nuxt',
[
'@pinia/nuxt',
Expand Down Expand Up @@ -47,6 +48,9 @@ export default defineNuxtConfig({
},
},
css: ['@/assets/style/reset.scss'],
device: {
refreshOnResize: true,
},
vite: {
ssr: {
noExternal: ['vuetify'],
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"devDependencies": {
"@mdi/js": "^7.2.96",
"@nuxtjs/device": "^3.1.0",
"@nuxtjs/eslint-config-typescript": "^12.0.0",
"@nuxtjs/fontaine": "^0.2.5",
"@nuxtjs/supabase": "^0.3.1",
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b45cec8

Please sign in to comment.