primevue-mirror/apps/showcase/components/layout/AppNews.vue

49 lines
1.7 KiB
Vue
Raw Normal View History

2022-04-07 12:57:53 +00:00
<template>
2023-10-17 11:37:05 +00:00
<div v-if="$appState.newsActive" class="layout-news" :style="$appState.announcement.backgroundStyle">
2023-09-25 10:05:27 +00:00
<div class="layout-news-container">
<i></i>
<div class="layout-news-content">
<span class="layout-news-text" :style="$appState.announcement.textStyle">{{ $appState.announcement.content }}</span>
2024-11-07 13:24:45 +00:00
<a class="layout-news-link" :href="$appState.announcement.linkHref" :target="$appState.announcement.target" rel="noopener noreferrer">{{ $appState.announcement.linkText }}</a>
2023-09-25 10:05:27 +00:00
</div>
<a class="layout-news-close" :style="$appState.announcement.textStyle" @click="onClose">
<span class="pi pi-times"></span>
</a>
2022-04-07 12:57:53 +00:00
</div>
2022-12-08 12:26:57 +00:00
</div>
2022-04-07 12:57:53 +00:00
</template>
<script>
2023-10-17 11:34:50 +00:00
import News from '@/assets/data/news.json';
2022-04-07 12:57:53 +00:00
export default {
mounted() {
2023-10-17 11:34:50 +00:00
const itemString = localStorage.getItem(this.$appState.storageKey);
if (itemString) {
const item = JSON.parse(itemString);
if (!item.hiddenNews || item.hiddenNews !== News.id) {
this.$appState.newsActive = true;
this.$appState.announcement = News;
} else {
this.$appState.newsActive = false;
}
} else {
this.$appState.announcement = News;
this.$appState.newsActive = true;
}
2022-04-07 12:57:53 +00:00
},
methods: {
onClose() {
this.$appState.newsActive = false;
const item = {
hiddenNews: this.$appState.announcement.id
};
2022-12-08 12:26:57 +00:00
2023-01-30 22:50:55 +00:00
localStorage.setItem(this.$appState.storageKey, JSON.stringify(item));
2022-04-07 12:57:53 +00:00
}
}
2022-09-14 14:26:41 +00:00
};
</script>