From b8a283e95aa56d0835e68ed6f3195a2f6fcf271c Mon Sep 17 00:00:00 2001 From: Cagatay Civici Date: Tue, 31 Jan 2023 01:50:55 +0300 Subject: [PATCH] Load news from json --- app.vue | 38 ++++++++++++++++---------------------- assets/data/news.json | 9 +++++++++ layouts/AppNews.vue | 10 ++-------- plugins/appState.js | 10 +++++++++- service/NewsService.js | 5 ----- 5 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 assets/data/news.json delete mode 100644 service/NewsService.js diff --git a/app.vue b/app.vue index d154b960a..5839d76bc 100644 --- a/app.vue +++ b/app.vue @@ -6,15 +6,13 @@ diff --git a/assets/data/news.json b/assets/data/news.json new file mode 100644 index 000000000..c92cb2244 --- /dev/null +++ b/assets/data/news.json @@ -0,0 +1,9 @@ +{ + "id": 30, + "content": "Introducing the all-new Apollo Vite Template", + "linkText": "View Demo", + "linkHref": "https://www.primefaces.org/apollo-vue", + "backgroundStyle": "background-color:#4f8ff7", + "textStyle": "color:#ffffff;font-weight:500", + "linkStyle": "color:#ffffff;font-weight:700;text-decoration: underline;" +} \ No newline at end of file diff --git a/layouts/AppNews.vue b/layouts/AppNews.vue index d7b9c07cc..ecfda9723 100644 --- a/layouts/AppNews.vue +++ b/layouts/AppNews.vue @@ -15,14 +15,8 @@ import EventBus from '@/layouts/AppEventBus'; export default { - data() { - return { - storageKey: 'primevue', - hovered: false - }; - }, mounted() { - //EventBus.emit('news-activate'); + EventBus.emit('news-activate'); }, methods: { onClose() { @@ -32,7 +26,7 @@ export default { hiddenNews: this.$appState.announcement.id }; - localStorage.setItem(this.storageKey, JSON.stringify(item)); + localStorage.setItem(this.$appState.storageKey, JSON.stringify(item)); } } }; diff --git a/plugins/appState.js b/plugins/appState.js index 5a60ea340..6b380a249 100644 --- a/plugins/appState.js +++ b/plugins/appState.js @@ -1,6 +1,14 @@ const $appState = { install: (Vue, options) => { - Vue.config.globalProperties.$appState = reactive({ theme: 'lara-light-blue', darkTheme: false, codeSandbox: false, sourceType: 'options-api', newsActive: false, announcement: {} }); + Vue.config.globalProperties.$appState = reactive({ + theme: 'lara-light-blue', + darkTheme: false, + codeSandbox: false, + sourceType: 'options-api', + newsActive: true, + announcement: {}, + storageKey: 'primevue' + }); } }; diff --git a/service/NewsService.js b/service/NewsService.js deleted file mode 100644 index 8495f6855..000000000 --- a/service/NewsService.js +++ /dev/null @@ -1,5 +0,0 @@ -export default class NewsService { - fetchNews() { - return fetch('https://www.primefaces.org/cdn/news/primevue.json', { cache: 'no-store', mode: 'no-cors' }).then((res) => res.json()); - } -}