Static.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <MainContentLayout id="not-found" class="">
  3. <template v-slot:header>
  4. <span v-if="!page" class="loading">Loading ...</span>
  5. <h1 v-else>{{ page.title }}</h1>
  6. </template>
  7. <div v-if="page" v-html="page.tei" />
  8. </MainContentLayout>
  9. </template>
  10. <script>
  11. import { mapState, mapActions } from 'vuex'
  12. import MainContentLayout from '../components/Layouts/MainContentLayout'
  13. export default {
  14. name: 'Static',
  15. components: {
  16. MainContentLayout
  17. },
  18. data: () => ({
  19. uuid: null,
  20. page: null
  21. }),
  22. computed: {
  23. ...mapState({
  24. colophon: state => state.Colophon.colophon
  25. })
  26. // page () {
  27. // }
  28. },
  29. beforeCreate () {
  30. },
  31. created () {
  32. if (!this.colophon.length) {
  33. this.getColophon()
  34. }
  35. console.log('Static created', this.$route)
  36. this.uuid = this.$route.name
  37. if (this.colophon && this.colophon.length > 0) {
  38. this.setPage()
  39. }
  40. },
  41. watch: {
  42. $route (n, o) {
  43. console.log('static route changed', n, o)
  44. this.uuid = n.name
  45. if (this.colophon && this.colophon.length > 0) {
  46. this.setPage()
  47. }
  48. },
  49. colophon (n, o) {
  50. this.setPage()
  51. }
  52. },
  53. methods: {
  54. ...mapActions({
  55. getColophon: 'Colophon/getColophon'
  56. }),
  57. setPage () {
  58. for (let i = 0; i < this.colophon.length; i++) {
  59. if (this.colophon[i].uuid === this.uuid) {
  60. this.page = this.colophon[i]
  61. }
  62. }
  63. }
  64. },
  65. metaInfo () {
  66. return {
  67. title: `Static`
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. </style>