Index page scroll problem fixed

pull/3449/head
Bahadır Sofuoğlu 2022-12-27 11:12:25 +03:00
parent fcfc7cc320
commit 384e9e93ac
4 changed files with 42 additions and 30 deletions

View File

@ -0,0 +1,9 @@
export default defineNuxtRouteMiddleware((to, from) => {
useNuxtApp().hook('page:finish', () => {
if (history.state.scroll) {
setTimeout(() => window.scrollTo(history.state.scroll), 0);
} else {
setTimeout(() => window.scrollTo(0, 0), 0);
}
});
});

29
pages/Intro.vue Normal file
View File

@ -0,0 +1,29 @@
<template>
<div class="landing-intro">
<AppNews v-if="$appState.newsActive" />
<HeaderSection @theme-toggle="onThemeToggle" />
<HeroSection />
</div>
</template>
<script>
import AppNews from '@/layouts/AppNews';
import HeaderSection from './landing/HeaderSection';
import HeroSection from './landing/HeroSection';
export default {
methods: {
onThemeToggle() {
const newTheme = this.$appState.darkTheme ? 'lara-light-blue' : 'lara-dark-blue';
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark');
EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme });
this.replaceTableTheme(newTableTheme);
}
},
components: {
HeaderSection,
HeroSection,
AppNews
}
};
</script>

View File

@ -1,10 +1,6 @@
<template> <template>
<div :class="landingClass"> <div :class="landingClass">
<div class="landing-intro"> <Intro></Intro>
<AppNews v-if="$appState.newsActive" />
<HeaderSection @theme-toggle="onThemeToggle" />
<HeroSection />
</div>
<ComponentSection /> <ComponentSection />
<ThemeSection :theme="tableTheme" @table-theme-change="onTableThemeChange" /> <ThemeSection :theme="tableTheme" @table-theme-change="onTableThemeChange" />
<BlockSection /> <BlockSection />
@ -17,19 +13,15 @@
</template> </template>
<script> <script>
import EventBus from '@/layouts/AppEventBus'; import { defineAsyncComponent } from 'vue';
import AppNews from '@/layouts/AppNews';
import BlockSection from './landing/BlockSection'; import BlockSection from './landing/BlockSection';
import ComponentSection from './landing/ComponentSection'; import ComponentSection from './landing/ComponentSection';
import DesignerSection from './landing/DesignerSection'; import DesignerSection from './landing/DesignerSection';
import FeaturesSection from './landing/FeaturesSection'; import FeaturesSection from './landing/FeaturesSection';
import FooterSection from './landing/FooterSection'; import FooterSection from './landing/FooterSection';
import HeaderSection from './landing/HeaderSection';
import HeroSection from './landing/HeroSection';
import TemplateSection from './landing/TemplateSection'; import TemplateSection from './landing/TemplateSection';
import ThemeSection from './landing/ThemeSection'; import ThemeSection from './landing/ThemeSection';
import UsersSection from './landing/UsersSection'; import UsersSection from './landing/UsersSection';
export default { export default {
props: { props: {
theme: { theme: {
@ -57,13 +49,6 @@ export default {
this.replaceTableTheme(this.$appState.darkTheme ? 'lara-dark-blue' : 'lara-light-blue'); this.replaceTableTheme(this.$appState.darkTheme ? 'lara-dark-blue' : 'lara-light-blue');
}, },
methods: { methods: {
onThemeToggle() {
const newTheme = this.$appState.darkTheme ? 'lara-light-blue' : 'lara-dark-blue';
const newTableTheme = this.$appState.darkTheme ? this.tableTheme.replace('dark', 'light') : this.tableTheme.replace('light', 'dark');
EventBus.emit('theme-change', { theme: newTheme, dark: !this.$appState.darkTheme });
this.replaceTableTheme(newTableTheme);
},
onTableThemeChange(value) { onTableThemeChange(value) {
this.replaceTableTheme(value); this.replaceTableTheme(value);
}, },
@ -96,8 +81,7 @@ export default {
} }
}, },
components: { components: {
HeaderSection, Intro: defineAsyncComponent(() => import('./Intro.vue')),
HeroSection,
ComponentSection, ComponentSection,
ThemeSection, ThemeSection,
BlockSection, BlockSection,
@ -105,8 +89,7 @@ export default {
TemplateSection, TemplateSection,
UsersSection, UsersSection,
FeaturesSection, FeaturesSection,
FooterSection, FooterSection
AppNews
} }
}; };
</script> </script>

View File

@ -1,9 +0,0 @@
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.$router.options.scrollBehavior = () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve({ left: 0, top: 0, behaviour: 'smooth' });
}, 100);
});
};
});