|
@@ -8,16 +8,16 @@ import { Loading } from 'element-ui';
|
|
|
/**
|
|
|
* 保存页面数据
|
|
|
*/
|
|
|
-export const saveTheme = ({commit}, theme) => {
|
|
|
+export const saveTheme = ({ commit }, theme) => {
|
|
|
if (theme && theme._id) {
|
|
|
return Promise.resolve(api.updateTheme(theme).then((res) => {
|
|
|
commit(types.UPDATE_THEME_SUCCESS, res)
|
|
|
- window.hasSaveFlag=true;
|
|
|
+ window.hasSaveFlag = true;
|
|
|
}))
|
|
|
} else {
|
|
|
return Promise.resolve(api.saveTheme(theme).then((res) => {
|
|
|
commit(types.ADD_THEME_SUCCESS, res)
|
|
|
- window.hasSaveFlag=true;
|
|
|
+ window.hasSaveFlag = true;
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
@@ -26,7 +26,7 @@ export const saveTheme = ({commit}, theme) => {
|
|
|
* 获取用户所有场景主题
|
|
|
* @param commit
|
|
|
*/
|
|
|
-export const getUserThemeList = ({commit}, type) => {
|
|
|
+export const getUserThemeList = ({ commit }, type) => {
|
|
|
api.getUserThemeList(type).then((res) => {
|
|
|
commit(types.GET_USER_THEME_LIST, res)
|
|
|
})
|
|
@@ -37,8 +37,8 @@ export const getUserThemeList = ({commit}, type) => {
|
|
|
* @param commit
|
|
|
*/
|
|
|
|
|
|
-export const createTheme = ({commit}, type) => {
|
|
|
- var theme = new Theme({type: type})
|
|
|
+export const createTheme = ({ commit }, type) => {
|
|
|
+ var theme = new Theme({ type: type })
|
|
|
commit(types.CREATE_THEME, theme)
|
|
|
commit(types.SET_CUR_EDITOR_THEME, theme)
|
|
|
}
|
|
@@ -46,7 +46,7 @@ export const createTheme = ({commit}, type) => {
|
|
|
/**
|
|
|
* 设置当前编辑的主题
|
|
|
*/
|
|
|
-export const setEditorTheme = ({commit}, theme) => {
|
|
|
+export const setEditorTheme = ({ commit }, theme) => {
|
|
|
var newTheme = new Theme(theme)
|
|
|
commit(types.SET_CUR_EDITOR_THEME, newTheme)
|
|
|
}
|
|
@@ -56,7 +56,7 @@ export const setEditorTheme = ({commit}, theme) => {
|
|
|
* @param commit
|
|
|
* @param page
|
|
|
*/
|
|
|
-export const setEditorPage = ({commit}, page) => {
|
|
|
+export const setEditorPage = ({ commit }, page) => {
|
|
|
commit(types.SET_CUR_EDITOR_PAGE, page)
|
|
|
}
|
|
|
|
|
@@ -64,16 +64,22 @@ export const setEditorPage = ({commit}, page) => {
|
|
|
* 给主题添加页面
|
|
|
* @param commit
|
|
|
*/
|
|
|
-export const addPage = ({commit}) => {
|
|
|
+export const addPage = ({ commit }) => {
|
|
|
var page = new Page()
|
|
|
commit(types.ADD_PAGE, page)
|
|
|
commit(types.SET_CUR_EDITOR_PAGE, page)
|
|
|
}
|
|
|
+export const addPage1 = ({ commit }, position) => {
|
|
|
+ console.log("SSSSSSSSSSSSSSSS", position);
|
|
|
+ var page = new Page()
|
|
|
+ commit(types.ADD_PAGE_POSITION, page, position)
|
|
|
+ commit(types.SET_CUR_EDITOR_PAGE, page)
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 添加页面元素
|
|
|
*/
|
|
|
-export const addElement = ({commit, state}, data) => {
|
|
|
+export const addElement = ({ commit, state }, data) => {
|
|
|
commit(types.ADD_PIC_ELEMENT, new Element(data))
|
|
|
var list = state.editorPage.elements
|
|
|
var lastIndex = list.length - 1
|
|
@@ -84,7 +90,7 @@ export const addElement = ({commit, state}, data) => {
|
|
|
/**
|
|
|
* 添加背景图片
|
|
|
*/
|
|
|
-export const addBGElement = ({commit}, data) => {
|
|
|
+export const addBGElement = ({ commit }, data) => {
|
|
|
var element = new Element(data)
|
|
|
commit(types.SET_BG_ELEMENT, element)
|
|
|
commit(types.SET_CUR_EDITOR_ELEMENT, null)
|
|
@@ -95,25 +101,25 @@ export const addBGElement = ({commit}, data) => {
|
|
|
* @param commit
|
|
|
* @param data
|
|
|
*/
|
|
|
-export const savePic = ({commit}, data) => {
|
|
|
+export const savePic = ({ commit }, data) => {
|
|
|
commit(types.PUSH_PIC_LIST, data)
|
|
|
}
|
|
|
/**
|
|
|
* 清除背景
|
|
|
* @param commit
|
|
|
*/
|
|
|
-export const cleanBG = ({commit}) => {
|
|
|
+export const cleanBG = ({ commit }) => {
|
|
|
commit(types.CLEAN_BG)
|
|
|
}
|
|
|
|
|
|
-export const cleanEle = ({commit}, ele) => {
|
|
|
+export const cleanEle = ({ commit }, ele) => {
|
|
|
commit(types.CLEAN_ELE, ele)
|
|
|
}
|
|
|
/**
|
|
|
* 复制页面
|
|
|
* @param commit
|
|
|
*/
|
|
|
-export const copyPage = ({commit}, data) => {
|
|
|
+export const copyPage = ({ commit }, data) => {
|
|
|
var page = tools.vue2json(data)
|
|
|
commit(types.ADD_PAGE, page)
|
|
|
}
|
|
@@ -122,24 +128,24 @@ export const copyPage = ({commit}, data) => {
|
|
|
* 删除页面
|
|
|
* @param commit
|
|
|
*/
|
|
|
-export const delPage = ({commit}, page) => {
|
|
|
+export const delPage = ({ commit }, page) => {
|
|
|
commit(types.DELETE_PAGE, page)
|
|
|
}
|
|
|
|
|
|
-export const getPageByThemeId = ({dispatch, commit}, id) => {
|
|
|
- let loading=Loading.service({
|
|
|
+export const getPageByThemeId = ({ dispatch, commit }, id) => {
|
|
|
+ let loading = Loading.service({
|
|
|
lock: true,
|
|
|
text: '模板加载中...',
|
|
|
spinner: 'el-icon-loading',
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
});
|
|
|
api.getPageByThemeId(id).then((res) => {
|
|
|
- res.pages=res.pages||[];
|
|
|
- res.backgroundAudio = res.backgroundAudio|| '';
|
|
|
- res.pages.forEach((page)=>{
|
|
|
- page.elements.forEach((element)=>{
|
|
|
- element.animatedFont = element.animatedFont||''
|
|
|
- element.eleCanvas = element.eleCanvas||''
|
|
|
+ res.pages = res.pages || [];
|
|
|
+ res.backgroundAudio = res.backgroundAudio || '';
|
|
|
+ res.pages.forEach((page) => {
|
|
|
+ page.elements.forEach((element) => {
|
|
|
+ element.animatedFont = element.animatedFont || ''
|
|
|
+ element.eleCanvas = element.eleCanvas || ''
|
|
|
})
|
|
|
})
|
|
|
commit(types.SET_CUR_EDITOR_THEME, res)
|
|
@@ -147,35 +153,35 @@ export const getPageByThemeId = ({dispatch, commit}, id) => {
|
|
|
loading.close()
|
|
|
setTimeout(function () {
|
|
|
|
|
|
- window.revocationFlag=true
|
|
|
- },800)
|
|
|
+ window.revocationFlag = true
|
|
|
+ }, 800)
|
|
|
}).then(() => {
|
|
|
dispatch('sortElementsByZindex')
|
|
|
loading.close()
|
|
|
setTimeout(function () {
|
|
|
|
|
|
- window.revocationFlag=true
|
|
|
- },800)
|
|
|
+ window.revocationFlag = true
|
|
|
+ }, 800)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export const setEditorElement = ({commit}, element) => {
|
|
|
- if(element&&element.locked){
|
|
|
+export const setEditorElement = ({ commit }, element) => {
|
|
|
+ if (element && element.locked) {
|
|
|
return false
|
|
|
}
|
|
|
commit(types.SET_CUR_EDITOR_ELEMENT, element)
|
|
|
}
|
|
|
|
|
|
// 删除元素
|
|
|
-export const deleteElement = ({commit}, element) => {
|
|
|
+export const deleteElement = ({ commit }, element) => {
|
|
|
commit(types.DELETE_ELEMENT, element)
|
|
|
}
|
|
|
|
|
|
-export const deleteSelectedElement = ({commit, state}) => {
|
|
|
+export const deleteSelectedElement = ({ commit, state }) => {
|
|
|
commit(types.DELETE_ELEMENT, state.editorElement)
|
|
|
}
|
|
|
|
|
|
-export const playAnimate = ({state, commit, getters}) => {
|
|
|
+export const playAnimate = ({ state, commit, getters }) => {
|
|
|
commit(types.PLAY_ANIMATE)
|
|
|
let target = getters['editingElement'] || getters['editingPageElements'] || null
|
|
|
let time = 0
|
|
@@ -191,27 +197,27 @@ export const playAnimate = ({state, commit, getters}) => {
|
|
|
}, time * 1000)
|
|
|
}
|
|
|
|
|
|
-export const getPicListByThemeId = ({commit}, _id) => {
|
|
|
+export const getPicListByThemeId = ({ commit }, _id) => {
|
|
|
api.getPicListByThemeId(_id).then((res) => {
|
|
|
commit(types.FETCH_PIC_LIST, res)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export const cleanPicList = ({commit}) => {
|
|
|
+export const cleanPicList = ({ commit }) => {
|
|
|
commit(types.CLEAN_PIC_LIST)
|
|
|
}
|
|
|
|
|
|
-export const sortElementsByZindex = ({commit}, location) => {
|
|
|
+export const sortElementsByZindex = ({ commit }, location) => {
|
|
|
commit(types.SORTELEMENTS_BY_ZINDEX, location)
|
|
|
}
|
|
|
|
|
|
-export const deleteTheme = ({commit}, theme) => {
|
|
|
+export const deleteTheme = ({ commit }, theme) => {
|
|
|
return Promise.resolve(api.delTheme(theme).then((res) => {
|
|
|
commit(types.DELETE_THEME, theme)
|
|
|
}))
|
|
|
}
|
|
|
|
|
|
-export const uploadPsd = ({commit}, _file) => {
|
|
|
+export const uploadPsd = ({ commit }, _file) => {
|
|
|
api.uploadPsd(_file).then((res) => {
|
|
|
})
|
|
|
}
|