Load news from json

This commit is contained in:
Cagatay Civici 2023-01-31 01:50:55 +03:00
parent cf1a9838d6
commit b8a283e95a
5 changed files with 36 additions and 36 deletions

38
app.vue
View file

@ -6,15 +6,13 @@
<script>
import EventBus from '@/layouts/AppEventBus';
import NewsService from '@/service/NewsService';
import News from '@/assets/data/news.json';
export default {
themeChangeListener: null,
newsActivate: null,
newsService: null,
data() {
return {
storageKey: 'primevue',
layout: 'custom'
};
},
@ -30,27 +28,23 @@ export default {
}
}
},
created() {
this.newsService = new NewsService();
},
mounted() {
/*this.newsActivate = () => {
this.newsService.fetchNews().then((data) => {
this.$appState.announcement = data;
this.newsActivate = () => {
this.$appState.announcement = News;
const itemString = localStorage.getItem(this.$appState.storageKey);
const itemString = localStorage.getItem(this.storageKey);
if (itemString) {
const item = JSON.parse(itemString);
if (itemString) {
const item = JSON.parse(itemString);
if (item.hiddenNews && item.hiddenNews !== data.id) {
this.$appState.newsActive = true;
} else this.$appState.newsActive = false;
} else {
if (!item.hiddenNews || item.hiddenNews !== News.id)
this.$appState.newsActive = true;
}
});
};*/
else this.$appState.newsActive = false;
}
else {
this.$appState.newsActive = true;
}
};
this.themeChangeListener = (event) => {
const elementId = 'theme-link';
@ -71,11 +65,11 @@ export default {
};
EventBus.on('theme-change', this.themeChangeListener);
//EventBus.on('news-activate', this.newsActivate);
EventBus.on('news-activate', this.newsActivate);
},
beforeUnmount() {
EventBus.off('theme-change', this.themeChangeListener);
//EventBus.off('news-activate', this.newsActivate);
EventBus.off('news-activate', this.newsActivate);
}
};
</script>