From f763c1f301b57dc319a9c79eb6c08bb8b9cca84c Mon Sep 17 00:00:00 2001 From: Kostya Date: Sat, 16 Dec 2023 15:15:24 +0300 Subject: [PATCH] added mixin for mobile check --- .../HeaderMobileComponent.vue | 2 +- .../adaptive-components/MenuMobileComponent.vue | 10 +++++----- luckydiamond/src/main.js | 2 ++ luckydiamond/src/mixins/mixin.js | 13 +++++++++++++ luckydiamond/src/pages/HomePage.vue | 17 ++++++++--------- luckydiamond/src/pages/ProfilePage.vue | 15 +++++++++++++-- 6 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 luckydiamond/src/mixins/mixin.js diff --git a/luckydiamond/src/components/adaptive-components/HeaderMobileComponent.vue b/luckydiamond/src/components/adaptive-components/HeaderMobileComponent.vue index 9ba2ed6..f47145e 100644 --- a/luckydiamond/src/components/adaptive-components/HeaderMobileComponent.vue +++ b/luckydiamond/src/components/adaptive-components/HeaderMobileComponent.vue @@ -11,7 +11,7 @@

999

- +
diff --git a/luckydiamond/src/components/adaptive-components/MenuMobileComponent.vue b/luckydiamond/src/components/adaptive-components/MenuMobileComponent.vue index b086aa6..b6f7687 100644 --- a/luckydiamond/src/components/adaptive-components/MenuMobileComponent.vue +++ b/luckydiamond/src/components/adaptive-components/MenuMobileComponent.vue @@ -2,11 +2,11 @@ diff --git a/luckydiamond/src/main.js b/luckydiamond/src/main.js index 21baa4b..657575d 100644 --- a/luckydiamond/src/main.js +++ b/luckydiamond/src/main.js @@ -2,10 +2,12 @@ import { createApp } from 'vue' import App from './App.vue' import router from "@/router/router"; +import { Mixins } from "@/mixins/mixin"; import '@/assets/css/global.css' const app = createApp(App) app.use(router) +app.mixin(Mixins) app.mount('#app') diff --git a/luckydiamond/src/mixins/mixin.js b/luckydiamond/src/mixins/mixin.js new file mode 100644 index 0000000..b58eccd --- /dev/null +++ b/luckydiamond/src/mixins/mixin.js @@ -0,0 +1,13 @@ +export const Mixins = { + methods: { + checkWindowSize() { + this.mobile = window.innerWidth <= 600 + }, + AddWindowListener() { + window.addEventListener('resize', this.checkWindowSize) + }, + RemoveWindowListener() { + window.removeEventListener('resize', this.checkWindowSize) + } + } +} \ No newline at end of file diff --git a/luckydiamond/src/pages/HomePage.vue b/luckydiamond/src/pages/HomePage.vue index b68d671..d074778 100644 --- a/luckydiamond/src/pages/HomePage.vue +++ b/luckydiamond/src/pages/HomePage.vue @@ -1,6 +1,6 @@