Skip to content

Commit

Permalink
fix: 修护预览页面没提前保存,以及保存过程截图性能慢的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jy03078959 committed Mar 19, 2020
1 parent 63ad4b2 commit 230d39d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
18 changes: 11 additions & 7 deletions src/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
},
autoSave: function () {
setInterval(() => {
this.ema.fire('pageInfo.save', true)
this.ema.fire('pageInfo.save')
}, 1000 * 60 * 2)
},
canDrag: function () {
Expand Down Expand Up @@ -174,11 +174,11 @@
}
})
// 保存页面
this.ema.bind('pageInfo.save', (fast) => {
this.ema.bind('pageInfo.save', (fast, callback) => {
console.log('save---------', this.nodeInfo)
this.doSave(this.nodeInfo, true)
// if (this.demoMode) return this.$alert('您处在 demo 模式下,不能保存数据哦')
this.savePage()
this.savePage(fast, callback)
})
// 绑定组件点击添加组件到根元素
this.ema.bind('commponent.addOne', menu => {
Expand Down Expand Up @@ -355,7 +355,7 @@
if (process.env.NODE_ENV == 'production') this.$alert('编辑页面缺少key')
else {
this.nodeInfo = cloneDeep(emptyPage)
this.$store.dispatch('SettingChange', {demoMode: true})
this.$store.dispatch('SettingChange', {demoMode: false})
}
return
}
Expand Down Expand Up @@ -411,7 +411,7 @@
saveToServer: function () {
this.ema.fire('pageInfo.save')
},
savePage () {
savePage (fast, callback) {
if (this.demoMode) return this.$alert('您处在demo模式下,不能保存数据哦')
var info = Object.assign({}, this.pageInfo)
info.content = window.localStorage.getItem(this.STORAGE_KEY)
Expand All @@ -426,10 +426,14 @@
let msg = data.msg
if (code == 500) return this.$alert(msg)
this.$message({type: 'success', message: '保存成功'})
callback && callback()
if (!fast) {
this.savePagePreviewImage()
}
}).catch((respond) => {
debugger
this.$message({type: 'success', message: '保存失败'})
})
this.savePagePreviewImage()
},
savePagePreviewImage () {
var urlInfo = common.parseURL(window.location.href)
Expand All @@ -441,7 +445,7 @@
Server({
url: 'editor/pages/save',
method: 'post', // default
needLoading: true,
needLoading: false,
data: info
}).then(({data}) => {
}).catch((respond) => {
Expand Down
14 changes: 8 additions & 6 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,13 @@
},
preview: function () {
var urlInfo = common.parseURL(window.location.href)
this.openDialog({
name: 'd-Preview',
data: {
key: urlInfo.params && urlInfo.params.key
}
this.ema.fire('pageInfo.save', true, () => {
this.openDialog({
name: 'd-Preview',
data: {
key: urlInfo.params && urlInfo.params.key
}
})
})
},
revocation: function () {
Expand All @@ -343,7 +345,7 @@
this.ema.fire('history.forword')
},
save: function () {
this.ema.fire('pageInfo.save', true)
this.ema.fire('pageInfo.save')
},
psd: function () {
this.ema.fire('pageInfo.psd')
Expand Down
14 changes: 8 additions & 6 deletions src/components/SliderTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@
*/
preview: function () {
var urlInfo = common.parseURL(window.location.href)
this.openDialog({
name: 'd-Preview',
data: {
key: urlInfo.params && urlInfo.params.key
}
this.ema.fire('pageInfo.save', true, () => {
this.openDialog({
name: 'd-Preview',
data: {
key: urlInfo.params && urlInfo.params.key
}
})
})
},
/**
Expand All @@ -165,7 +167,7 @@
* 保存
**/
save: function () {
this.ema.fire('pageInfo.save', true)
this.ema.fire('pageInfo.save')
},
/**
* 保存模板
Expand Down

0 comments on commit 230d39d

Please sign in to comment.