Parcourir la source

اضافه کردن landing

hgh il y a 1 an
Parent
commit
3e39ae1052
2 fichiers modifiés avec 90 ajouts et 0 suppressions
  1. 66 0
      src/pages/Public/landing.vue
  2. 24 0
      src/router/routes/Public.js

+ 66 - 0
src/pages/Public/landing.vue

@@ -0,0 +1,66 @@
+<template>
+  <q-page-builder v-model:sections="currenSections"
+                  v-model:options="pageConfig"
+                  :editable="pageBuilderEditable"
+                  :loading="pageBuilderLoading" />
+</template>
+
+<script>
+import { APIGateway } from 'src/api/APIGateway.js'
+import { PageSetting } from 'src/models/PageSetting.js'
+import { mixinSEO, mixinPageOptions, mixinPrefetchServerData, mixinAuth } from 'src/mixin/Mixins.js'
+
+export default {
+  name: 'Landing',
+  mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO, mixinAuth],
+  computed: {
+    hasDynamicSetting () {
+      return !!this.$route.meta?.hasDynamicSetting
+    },
+    hasDynamicSettingWithParams () {
+      return !!this.$route.meta?.hasDynamicSettingWithParams
+    }
+  },
+  methods: {
+    onFailedFetchData () {
+      setTimeout(() => {
+        this.checkNewLanding()
+      }, 1000)
+    },
+    goToNotFoundLanding () {
+      // this.$router.push({ name: 'NotFound' })
+      this.$router.push({ name: 'Public.Home' })
+    },
+    checkNewLanding () {
+      if (!this.isUserLogin || !this.user.isSuperUser()) {
+        this.goToNotFoundLanding()
+        return
+      }
+
+      this.$q.dialog({
+        title: 'ساخت صفحه جدید',
+        message: 'از نام لندینگ ' + this.$route.params.slug + ' اطمینان دارید؟ ',
+        cancel: true,
+        persistent: true
+      }).onOk(() => {
+        this.createNewLanding()
+      }).onCancel(() => {
+        // this.$router.push({ name: 'Public.Home' })
+        this.goToNotFoundLanding()
+      })
+    },
+    createNewLanding () {
+      const params = JSON.stringify(this.$route.params)
+      const routeName = this.$route.name
+      const key = 'route_name:' + routeName + '-params:' + params
+      const value = new PageSetting({
+        value: { sections: [], seo: {}, layoutConfig: {} }
+      }).getStringifyValue()
+      APIGateway.pageSetting.create({ key, value })
+        .then(() => {
+          this.currenSections = []
+        })
+    }
+  }
+}
+</script>

+ 24 - 0
src/router/routes/Public.js

@@ -203,6 +203,30 @@ export default {
         }
       ]
     },
+    {
+      name: 'Public.Landing',
+      path: 'landing',
+      meta: {
+        hasDynamicSetting: true
+      },
+      component: () => import('layouts/bareLayout.vue'),
+      children: [
+        {
+          path: '',
+          name: 'Public.Landing.List',
+          component: () => import('src/pages/BasicDynamicPage.vue')
+        },
+        {
+          path: ':slug',
+          name: 'Public.Landing.Show',
+          meta: {
+            hasDynamicSetting: true,
+            hasDynamicSettingWithParams: true
+          },
+          component: () => import('src/pages/Public/landing.vue')
+        }
+      ]
+    },
     {
       name: 'Public.Rules',
       path: 'rules',