2024-05-30 18:06:50 +07:00
|
|
|
import { defineStore, acceptHMRUpdate } from "pinia";
|
2024-06-03 21:53:23 +07:00
|
|
|
import { useLocalStorage } from "@vueuse/core";
|
2024-05-30 18:06:50 +07:00
|
|
|
export const useDynamicPageStore = defineStore("dynamicPageStore", () => {
|
|
|
|
|
const currentPage = ref<any>({});
|
|
|
|
|
const sectionPublished = ref<any[]>([]);
|
|
|
|
|
const componentPublished = ref<any[]>([]);
|
2024-06-03 21:53:23 +07:00
|
|
|
const step = ref<number>(0)
|
|
|
|
|
|
2024-05-30 18:06:50 +07:00
|
|
|
|
|
|
|
|
async function fetchPageByCode(slug: any) {
|
2024-05-31 00:46:43 +07:00
|
|
|
try {
|
|
|
|
|
const { data } = await useFetch(`/api/dynamic-page/get-by-code/${slug}`)
|
2024-06-12 17:17:49 +07:00
|
|
|
// const data = ref({
|
|
|
|
|
// "sections": [
|
|
|
|
|
// {
|
|
|
|
|
// "id": 42,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section5hang",
|
|
|
|
|
// "slug": "section5hang",
|
|
|
|
|
// "code": "section5hang",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": "[{\"type\":\"component\",\"data\":57},{\"type\":\"component\",\"data\":68},{\"type\":\"component\",\"data\":69},{\"type\":\"component\",\"data\":44},{\"type\":\"component\",\"data\":50}]",
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal-TYPE:Default-MAX:5",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T16:17:57.386059",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:18:56.082485"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 32,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section2hang",
|
|
|
|
|
// "slug": "section2hang",
|
|
|
|
|
// "code": "section2hang_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": "[{\"type\":\"component\",\"data\":58},{\"type\":\"component\",\"data\":101}]",
|
|
|
|
|
// "keywords": null,
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal-TYPE:Default-MAX:2",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T10:33:59.071404",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:18:56.493553"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 31,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section2left3",
|
|
|
|
|
// "slug": "section2left3",
|
|
|
|
|
// "code": "section2left3_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": "[{\"type\":\"section\",\"data\":42},{\"type\":\"section\",\"data\":32}]",
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": "",
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:02:35.828188",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:36:43.623068"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 30,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section2left2",
|
|
|
|
|
// "slug": "section2left2",
|
|
|
|
|
// "code": "section2left2_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": "",
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:02:09.626405",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:37:17.837094"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 29,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section2left1",
|
|
|
|
|
// "slug": "section2left1",
|
|
|
|
|
// "code": "section2left1_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": "",
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:01:11.78265",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:01:40.494573"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 28,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section3cot",
|
|
|
|
|
// "slug": "section3cot",
|
|
|
|
|
// "code": "section3cot_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-TYPE:Default-MAX:3",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": "",
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:00:32.765855",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:37:50.127734"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 27,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section2left",
|
|
|
|
|
// "slug": "section2left",
|
|
|
|
|
// "code": "section2left_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-TYPE:LEFT-MAX:2",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": "",
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:00:05.873579",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:38:06.600079"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 26,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section3hang",
|
|
|
|
|
// "slug": "section3hang",
|
|
|
|
|
// "code": "section3hang_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": null,
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal-TYPE:Default-MAX:3",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T08:59:19.411836",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:38:29.410238"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 25,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section1hang1",
|
|
|
|
|
// "slug": "section1hang1",
|
|
|
|
|
// "code": "section1hang1_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": "",
|
|
|
|
|
// "keywords": null,
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal-TYPE:Default-MAX:1",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T08:53:59.364384",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T08:57:34.1155"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 24,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "section1hang",
|
|
|
|
|
// "slug": "section1hang",
|
|
|
|
|
// "code": "section1hang_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": null,
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal-TYPE:Default-MAX:1",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T08:53:52.871306",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T09:39:00.332127"
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// "components": [
|
|
|
|
|
// {
|
|
|
|
|
// "id": 101,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "ads2_doisong",
|
|
|
|
|
// "code": "ads2_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "ADS_DEFAULT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-06-04T15:44:49.728501",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-06-04T15:45:02.192997"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 69,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "coppy_link_2",
|
|
|
|
|
// "code": "coppy_link_2",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "ARTICLE_BUTTON",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T15:51:28.699877",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:00.334897"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 68,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_detail_1",
|
|
|
|
|
// "code": "article_detail_1",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "ARTICLE_DETAIL_DEFAULT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T15:37:58.099224",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:00.742949"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 62,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "coppy_link_1",
|
|
|
|
|
// "code": "coppy_link_1",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "ARTICLE_DETAIL_DEFAULT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": -1,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T15:24:08.987936",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T15:25:38.566902"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 58,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "ads_1",
|
|
|
|
|
// "code": "ads_1",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "ADS_DEFAULT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T15:09:08.953513",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:01.56169"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 57,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "breadcrumb_1",
|
|
|
|
|
// "code": "breadcrumb_1",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "BREADCRUM_DEFAULT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T15:01:25.190114",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:01.972624"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 50,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "comment",
|
|
|
|
|
// "code": "comment_default1",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "COMMENT",
|
|
|
|
|
// "template": "Other",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T11:37:42.957585",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T11:38:23.481239"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 47,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "collection_paging",
|
|
|
|
|
// "code": "collection_paging_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "DEFAULT",
|
|
|
|
|
// "template": "Section",
|
|
|
|
|
// "dataQuery": "Get[Article] Top[10] With[Categories:81]",
|
|
|
|
|
// "dataResult": "[]",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:49:48.945226",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:02.788055"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 44,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "collection5item2",
|
|
|
|
|
// "code": "collection5item2_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "TYPE:Article-LAYOUT:vertical-DATA:HORIZONTAL-MAX:5",
|
|
|
|
|
// "template": "Collection",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": true,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:18:53.361283",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:03.20532"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 43,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_doc",
|
|
|
|
|
// "code": "article_doc_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:18:26.503605",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:03.613773"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 42,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "collection5item",
|
|
|
|
|
// "code": "collection5item_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "TYPE:Article-LAYOUT:vertical-DATA:HORIZONTAL-MAX:5",
|
|
|
|
|
// "template": "Collection",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:17:57.798722",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:04.026497"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 41,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_doc_intro3",
|
|
|
|
|
// "code": "article_doc_intro3_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-HIDE:paragraph",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:17:21.675354",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:04.431454"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 40,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_doc_intro2",
|
|
|
|
|
// "code": "article_doc_intro2_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-HIDE:paragraph",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:16:56.07848",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:04.842294"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 39,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_doc_intro1",
|
|
|
|
|
// "code": "article_doc_intro1_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:vertical-HIDE:paragraph",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:16:39.074945",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:05.246938"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 38,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "article_ngang",
|
|
|
|
|
// "code": "article_ngang_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "LAYOUT:horizontal",
|
|
|
|
|
// "template": "Article",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:15:38.638781",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:05.664736"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "id": 37,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "pageId": 4,
|
|
|
|
|
// "sectionId": null,
|
|
|
|
|
// "title": "category",
|
|
|
|
|
// "code": "category_doisong",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "keywords": "",
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "DEFAULT",
|
|
|
|
|
// "template": "Category",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": "",
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": null,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T09:14:11.978206",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:19:06.0724"
|
|
|
|
|
// }
|
|
|
|
|
// ],
|
|
|
|
|
// "id": 4,
|
|
|
|
|
// "siteId": 1,
|
|
|
|
|
// "parentId": null,
|
|
|
|
|
// "title": "Trang đời sống",
|
|
|
|
|
// "slug": "trang-doi-song",
|
|
|
|
|
// "code": "page-doi-song",
|
|
|
|
|
// "type": 1,
|
|
|
|
|
// "content": null,
|
|
|
|
|
// "favicon": null,
|
|
|
|
|
// "keywords": null,
|
|
|
|
|
// "thumbnail": null,
|
|
|
|
|
// "settings": {
|
|
|
|
|
// "label": "",
|
|
|
|
|
// "layout": "Center_Page",
|
|
|
|
|
// "template": "Home",
|
|
|
|
|
// "dataQuery": null,
|
|
|
|
|
// "dataResult": null,
|
|
|
|
|
// "pinned": null
|
|
|
|
|
// },
|
|
|
|
|
// "features": "Navigation",
|
|
|
|
|
// "taxonomy": "Navigation",
|
|
|
|
|
// "description": null,
|
|
|
|
|
// "isPublished": false,
|
|
|
|
|
// "publishedBy": null,
|
|
|
|
|
// "publishedOn": null,
|
|
|
|
|
// "expiresOn": null,
|
|
|
|
|
// "order": 0,
|
|
|
|
|
// "status": 6,
|
|
|
|
|
// "createdBy": 1,
|
|
|
|
|
// "createdOn": "2024-05-30T08:42:10.319911",
|
|
|
|
|
// "updatedBy": 1,
|
|
|
|
|
// "updatedOn": "2024-05-30T16:18:55.254121"
|
|
|
|
|
// })
|
2024-05-31 00:46:43 +07:00
|
|
|
currentPage.value = {}
|
|
|
|
|
currentPage.value = data.value
|
|
|
|
|
} catch (error: any) {}
|
2024-05-30 18:06:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchPageById(id: string | number) {
|
2024-05-31 00:46:43 +07:00
|
|
|
try {
|
|
|
|
|
const { data } = await useFetch(`/api/dynamic-page/get-by-id/${id}`)
|
|
|
|
|
currentPage.value = {}
|
|
|
|
|
currentPage.value = data.value
|
|
|
|
|
} catch (error: any) {}
|
2024-05-30 18:06:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const setSectionPublished = () => {
|
2024-06-19 16:13:42 +07:00
|
|
|
const exsitsTemplate = ['None']
|
2024-05-30 18:06:50 +07:00
|
|
|
const contentArr: any = [];
|
|
|
|
|
currentPage.value.sections && currentPage.value.sections.map((section: any) => {
|
|
|
|
|
contentArr.push(section.content && typeof section.content === 'string' && JSON.parse(section.content));
|
|
|
|
|
return section;
|
|
|
|
|
});
|
2024-05-31 15:31:05 +07:00
|
|
|
|
2024-05-30 18:06:50 +07:00
|
|
|
|
|
|
|
|
sectionPublished.value = currentPage.value.sections && currentPage.value.sections.filter(
|
2024-06-19 16:13:42 +07:00
|
|
|
(section: any) => exsitsTemplate.includes(section.settings?.template) && section.isPublished && !contentArr.flat().some((_section: any) => _section && _section.data && _section.type === "section" && section.id === _section.data)
|
2024-06-04 09:59:12 +07:00
|
|
|
).sort((a: any, b: any) => a.order - b.order);
|
2024-05-30 18:06:50 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const setComponentPublished = () => {
|
2024-06-17 11:48:00 +07:00
|
|
|
const exsitsTemplate = ['None']
|
2024-05-30 18:06:50 +07:00
|
|
|
const contentArr: any = [];
|
|
|
|
|
currentPage.value.sections && currentPage.value.sections.map((section: any) => {
|
|
|
|
|
contentArr.push(section.content && JSON.parse(section.content) && JSON.parse(section.content));
|
|
|
|
|
return section;
|
|
|
|
|
});
|
|
|
|
|
componentPublished.value = currentPage.value.components && currentPage.value.components.filter((section: any) => section.isPublished);
|
2024-05-31 12:39:53 +07:00
|
|
|
};
|
2024-05-30 18:06:50 +07:00
|
|
|
|
|
|
|
|
const setDataQuery = (query: any, componentId: number | string) => {
|
|
|
|
|
for (const _component of currentPage.value.components && currentPage.value.components) {
|
|
|
|
|
if (_component.id === componentId) {
|
|
|
|
|
const currentSetting = {
|
|
|
|
|
..._component.settings,
|
|
|
|
|
dataQuery: query,
|
|
|
|
|
};
|
|
|
|
|
_component.settings = {
|
|
|
|
|
...currentSetting,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setComponentPublished();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
currentPage,
|
|
|
|
|
sectionPublished,
|
|
|
|
|
componentPublished,
|
|
|
|
|
|
|
|
|
|
fetchPageByCode,
|
|
|
|
|
fetchPageById,
|
|
|
|
|
setSectionPublished,
|
|
|
|
|
setComponentPublished,
|
|
|
|
|
setDataQuery,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (import.meta.hot) {
|
|
|
|
|
import.meta.hot.accept(acceptHMRUpdate(useDynamicPageStore, import.meta.hot));
|
|
|
|
|
}
|