Skip to content

Commit cf953c2

Browse files
committed
fix: replace router.place with window.open new tab to aviod could not save and preview the work when create the work
zh: 用 window.open new tab 替换 router.replace,避免最创建作品保存和预览无效的情况
1 parent 1dcef06 commit cf953c2

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

front-end/h5/src/store/modules/work.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@ export const actions = {
1919
},
2020
createWork ({ commit }, payload) {
2121
strapi.createEntry('works', new Work()).then(entry => {
22-
commit('setWork', entry)
23-
router.replace({ name: 'editor', params: { workId: entry.id } })
24-
// window.location = `${window.location.origin}/#/editor/${entry.id}`
22+
const routeData = router.resolve({ name: 'editor', params: { workId: entry.id } })
23+
window.open(routeData.href, '_blank')
2524
})
26-
// commit('createWork')
27-
// commit('pageManager', { type: 'add' })
28-
// commit('setEditingPage')
2925
},
3026
updateWork ({ commit, state }, payload = {}) {
3127
// update work with strapi
@@ -248,9 +244,6 @@ export const mutations = {
248244
})
249245
state.work = work
250246
},
251-
// createWork (state) {
252-
// state.work = new Work()
253-
// },
254247
previewWork (state, { type, value }) {},
255248
deployWork (state, { type, value }) {},
256249
formDetailOfWork (state, { type, value }) {

front-end/h5/src/views/work-manager/list.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ export default {
112112
},
113113
methods: {
114114
...mapActions('editor', [
115-
'fetchWorks'
115+
'fetchWorks',
116+
'createWork'
116117
]),
117118
deleteWork (item) {
118119
// TODO delete work from work list
119-
},
120-
createWork () {
121-
this.$router.push({ name: 'editor' })
122120
}
123121
},
124122
render (h) {

front-end/h5/src/views/work-manager/templates.vue

-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ export default {
104104
]),
105105
deleteWork (item) {
106106
// TODO delete work from work list
107-
},
108-
createWork () {
109-
this.$router.push({ name: 'editor' })
110-
// window.open('#/editor', '_blank')
111107
}
112108
},
113109
render (h) {

0 commit comments

Comments
 (0)