index.vue 771 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div class="preview">
  3. <div class="loader" v-if="!isLoaded">
  4. <v-progress-circular indeterminate></v-progress-circular>
  5. </div>
  6. <NewsArticle v-else :news="newsItem" />
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. isLoaded: false,
  14. newsItem: null,
  15. };
  16. },
  17. async mounted() {
  18. const uuid = this.$route.query.uuid;
  19. if(uuid) {
  20. let response = await this.$axios.get(`admin/news/preview/${uuid}`);
  21. this.newsItem = response.data.data
  22. }
  23. else {
  24. this.newsItem = JSON.parse(window.localStorage.getItem("preview"))
  25. }
  26. if (this.newsItem) this.isLoaded = true;
  27. },
  28. };
  29. </script>
  30. <style lang="less" scoped>
  31. .loader {
  32. text-align: center;
  33. padding: 50px 0;
  34. }
  35. </style>>