Commit abd9e622515d6c5ef8e6787411261762e53bd31d

Authored by ly525
1 parent 4a21fd39

parse api element to client element model

front-end/h5/src/store/modules/work.js
1 // import Work from '../../components/core/models/work' 1 // import Work from '../../components/core/models/work'
  2 +import Element from '../../components/core/models/element'
2 import strapi from '../../utils/strapi' 3 import strapi from '../../utils/strapi'
3 4
4 export const actions = { 5 export const actions = {
@@ -30,8 +31,11 @@ export const actions = { @@ -30,8 +31,11 @@ export const actions = {
30 31
31 // mutations 32 // mutations
32 export const mutations = { 33 export const mutations = {
33 - setWork (state, payload) {  
34 - state.work = payload 34 + setWork (state, work) {
  35 + work.pages.forEach(page => {
  36 + page.elements = page.elements.map(element => new Element(element))
  37 + })
  38 + state.work = work
35 }, 39 },
36 // createWork (state) { 40 // createWork (state) {
37 // state.work = new Work() 41 // state.work = new Work()