Some ssr issue solved

pull/3420/head
Bahadir Sofuoglu 2022-09-13 14:29:45 +03:00
parent 699a2d7398
commit 148a17057f
9 changed files with 44 additions and 16 deletions

19
app.vue
View File

@ -1,8 +1,7 @@
<template> <template>
<NuxtLayout v-if="$route.name !== 'index'"> <NuxtLayout :name="layout">
<NuxtPage /> <NuxtPage />
</NuxtLayout> </NuxtLayout>
<NuxtPage v-else />
</template> </template>
<script> <script>
@ -15,7 +14,21 @@ export default {
newsService: null, newsService: null,
data() { data() {
return { return {
storageKey: 'primevue' storageKey: 'primevue',
layout: 'custom',
}
},
watch: {
$route: {
immediate: true,
handler(to) {
if (to.name === 'index') {
this.layout = 'custom';
}
else {
this.layout = 'default';
}
}
} }
}, },
created() { created() {

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="layout-news" :style="$appState.announcement.backgroundStyle"> <div class="layout-news" :style="$appState?.announcement?.backgroundStyle">
<i></i> <i></i>
<div class="layout-news-content"> <div class="layout-news-content">
<span class="layout-news-text" :style="$appState.announcement.textStyle">{{$appState.announcement.content}}</span> <span class="layout-news-text" :style="$appState?.announcement?.textStyle">{{$appState?.announcement?.content}}</span>
<a class="layout-news-link" :href="$appState.announcement.linkHref">{{$appState.announcement.linkText}}</a> <a class="layout-news-link" :href="$appState?.announcement?.linkHref">{{$appState?.announcement?.linkText}}</a>
</div> </div>
<a class="layout-news-close" :style="$appState.announcement.textStyle" @click="onClose"> <a class="layout-news-close" :style="$appState?.announcement?.textStyle" @click="onClose">
<span class="pi pi-times"></span> <span class="pi pi-times"></span>
</a> </a>
</div> </div>

5
layouts/custom.vue Normal file
View File

@ -0,0 +1,5 @@
<template>
<div>
<slot></slot>
</div>
</template>

View File

@ -1,7 +1,7 @@
import { defineNuxtConfig } from 'nuxt' import { defineNuxtConfig } from 'nuxt'
const path = require('path'); const path = require('path');
import vueJsx from '@vitejs/plugin-vue-jsx' import vueJsx from '@vitejs/plugin-vue-jsx'
import rollupOptions from './rollup.config'
// https://v3.nuxtjs.org/api/configuration/nuxt.config // https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({ export default defineNuxtConfig({
ssr: true, ssr: true,
@ -13,12 +13,12 @@ export default defineNuxtConfig({
{ {
id: 'theme-link', id: 'theme-link',
rel: 'stylesheet', rel: 'stylesheet',
href: `./themes/lara-light-blue/theme.css` href: `/themes/lara-light-blue/theme.css`
}, },
{ {
id: 'home-table-link', id: 'home-table-link',
rel: 'stylesheet', rel: 'stylesheet',
href: './styles/landing/themes/lara-light-blue/theme.css' href: '/styles/landing/themes/lara-light-blue/theme.css'
} }
], ],
}, },

2
package-lock.json generated
View File

@ -24,7 +24,7 @@
"gulp-uglify": "^3.0.2", "gulp-uglify": "^3.0.2",
"gulp-uglifycss": "^1.0.6", "gulp-uglifycss": "^1.0.6",
"jsdom": "^19.0.0", "jsdom": "^19.0.0",
"nuxt": "3.0.0-rc.9", "nuxt": "^3.0.0-rc.9",
"primeflex": "^3.2.1", "primeflex": "^3.2.1",
"primeicons": "^5.0.0", "primeicons": "^5.0.0",
"prismjs": "^1.29.0", "prismjs": "^1.29.0",

View File

@ -29,7 +29,7 @@
"gulp-uglify": "^3.0.2", "gulp-uglify": "^3.0.2",
"gulp-uglifycss": "^1.0.6", "gulp-uglifycss": "^1.0.6",
"jsdom": "^19.0.0", "jsdom": "^19.0.0",
"nuxt": "3.0.0-rc.9", "nuxt": "^3.0.0-rc.9",
"primeflex": "^3.2.1", "primeflex": "^3.2.1",
"primeicons": "^5.0.0", "primeicons": "^5.0.0",
"prismjs": "^1.29.0", "prismjs": "^1.29.0",

View File

@ -1,7 +1,8 @@
<template> <template>
<div :class="landingClass"> <div :class="landingClass">
<ClientOnly>
<div class="landing-intro"> <div class="landing-intro">
<AppNews v-if="$appState.newsActive" /> <AppNews v-if="true" />
<HeaderSection @theme-toggle="onThemeToggle" /> <HeaderSection @theme-toggle="onThemeToggle" />
<HeroSection /> <HeroSection />
</div> </div>
@ -13,6 +14,7 @@
<UsersSection /> <UsersSection />
<FeaturesSection /> <FeaturesSection />
<FooterSection /> <FooterSection />
</ClientOnly>
</div> </div>
</template> </template>
@ -89,7 +91,7 @@ export default {
}, },
computed: { computed: {
landingClass() { landingClass() {
return ['landing', {'landing-dark': this.$appState.darkTheme, 'landing-light': !this.$appState.darkTheme, 'landing-news-active': this.$appState.newsActive}]; return ['landing', {'landing-dark': this.$appState?.darkTheme, 'landing-light': !this.$appState?.darkTheme, 'landing-news-active': this.$appState?.newsActive}];
} }
}, },
components: { components: {

View File

@ -1,5 +1,6 @@
<template> <template>
<div class="stepsdemo-content"> <div class="stepsdemo-content">
<ClientOnly>
<Card> <Card>
<template v-slot:title> Confirmation </template> <template v-slot:title> Confirmation </template>
<template v-slot:content> <template v-slot:content>
@ -47,6 +48,7 @@
</div> </div>
</template> </template>
</Card> </Card>
</ClientOnly>
</div> </div>
</template> </template>

View File

@ -1,6 +1,12 @@
export default class NewsService { export default class NewsService {
fetchNews() { async fetchNews() {
return fetch('https://www.primefaces.org/cdn/news/primevue.json', {cache: 'no-store'}).then(res => res.json()); try {
const data = await useFetch('https://www.primefaces.org/cdn/news/primevue.json', {cache: 'no-store'})
console.log(data)
return await data.json();
} catch (error) {
console.log(error)
}
} }
} }