{ this.previewVisible = false }}
+ visible={this.previewDialogVisible}
+ handleClose={() => { this.previewDialogVisible = false }}
/>
}
diff --git a/front-end/h5/src/components/core/editor/modals/preview.vue b/front-end/h5/src/components/core/editor/modals/preview.vue
index 361ef6b6..73637d26 100644
--- a/front-end/h5/src/components/core/editor/modals/preview.vue
+++ b/front-end/h5/src/components/core/editor/modals/preview.vue
@@ -22,7 +22,7 @@ export default {
// work: state => state.work
// }),
releaseUrl () {
- return `${window.location.origin}/works/preview/${this.work.id}`
+ return `${window.location.origin}/works/preview/${this.work.id}?mode=preview`
}
},
data () {
@@ -67,7 +67,7 @@ export default {
},
openNewTab (urlType) {
switch (urlType) {
- case 'previewDebug':
+ case 'openPreviewPage':
window.open(this.releaseUrl)
break
case 'buildEngineDocs':
@@ -152,7 +152,7 @@ export default {
-
this.openNewTab('previewDebug')}>打开预览 URL(For Debug)
+
this.openNewTab('openPreviewPage')}>打开预览页面
this.openNewTab('buildEngineDocs')}>如果本地预览显示空白,点此查看文档
diff --git a/front-end/h5/src/components/core/models/work.js b/front-end/h5/src/components/core/models/work.js
index 20407d90..9383bf28 100644
--- a/front-end/h5/src/components/core/models/work.js
+++ b/front-end/h5/src/components/core/models/work.js
@@ -30,7 +30,7 @@ class Work {
// this.created_at = new Date()
// this.updated_at = new Date()
- this.is_publish = false
+ this.is_publish = !!work.is_publish
this.is_template = false
this.height = work.height || 568
this.mode = work.mode || PAGE_MODE.SWIPPER_PAGE
diff --git a/front-end/h5/src/engine-entry.js b/front-end/h5/src/engine-entry.js
index 85760bc5..6a5e038f 100644
--- a/front-end/h5/src/engine-entry.js
+++ b/front-end/h5/src/engine-entry.js
@@ -38,6 +38,7 @@ const Engine = {
},
methods: {
renderLongPage () {
+ if (!window.__work.pages.length) return
const work = window.__work
return this.renderPreview(work.pages[0].elements)
},
@@ -59,10 +60,9 @@ const Engine = {
)
},
- renderPreview (pageElements) {
+ renderPreview (pageElements = []) {
const pageWrapperStyle = this.isLongPage ? {
height: window.__work.height + 'px'
-
} : {}
const elements = pageElements.map(element => new Element(element))
@@ -88,12 +88,20 @@ const Engine = {
containerStyle['overflow-y'] = 'scroll'
}
return containerStyle
- }
+ },
+ renderUnPublishTip() {
+ return 页面可能暂未发布
+ },
},
render (h) {
const work = window.__work
- const containerStyle = this.getContainerStyle(work)
+ // 预览模式 或者 已经发布 的页面可以正常渲染,否则提示用户暂未发布
+ const query = new URLSearchParams(window.location.search)
+ const canRender = query.get('mode') === 'preview' || work.is_publish
+ if (!canRender) return this.renderUnPublishTip()
+
+ const containerStyle = this.getContainerStyle(work)
return
{
this.isLongPage ? this.renderLongPage() : this.renderSwiperPage()
diff --git a/front-end/h5/src/store/modules/work.js b/front-end/h5/src/store/modules/work.js
index 9f48b9cd..bfd4531c 100644
--- a/front-end/h5/src/store/modules/work.js
+++ b/front-end/h5/src/store/modules/work.js
@@ -39,13 +39,13 @@ export const actions = {
* 预览作品之前需要先保存,但希望 用户点击保存按钮 和 点击预览按钮 loading_name 能够不同(虽然都调用了 saveWork)
* 因为 loading 效果要放在不同的按钮上
*/
- saveWork ({ commit, dispatch, state }, { isSaveCover = false, loadingName = 'saveWork_loading' } = {}) {
+ saveWork ({ commit, dispatch, state }, { isSaveCover = false, loadingName = 'saveWork_loading', successMsg="保存作品成功" } = {}) {
const fn = (callback) => {
new AxiosWrapper({
dispatch,
commit,
loading_name: loadingName,
- successMsg: '保存作品成功',
+ successMsg,
customRequest: strapi.updateEntry.bind(strapi)
}).put('works', state.work.id, state.work).then(callback)
}