diff --git a/designer-demo/registry.js b/designer-demo/registry.js index bf8922863..b358c4f31 100644 --- a/designer-demo/registry.js +++ b/designer-demo/registry.js @@ -15,6 +15,12 @@ import { HttpService } from './src/composable' const baseURL = import.meta.env.BASE_URL || '.' const baseURLWithoutSlash = baseURL.replace(/\/$/, '') +const hasPreviewUrl = Object.prototype.hasOwnProperty.call(import.meta.env, 'VITE_PREVIEW_URL') +const previewUrl = hasPreviewUrl + ? import.meta.env.VITE_PREVIEW_URL + : ['production', 'alpha'].includes(import.meta.env.MODE) + ? `${baseURLWithoutSlash}/preview.html` + : '' export default { [META_SERVICE.Http]: HttpService, @@ -51,7 +57,7 @@ export default { options: { // 配置预览跳转的 url:根据实际业务需求进行配置 // 文档:https://opentiny.design/tiny-engine#/help-center/course/dev/preview-api - previewUrl: ['prod', 'alpha'].includes(import.meta.env.MODE) ? `${baseURLWithoutSlash}/preview.html` : '' + previewUrl } } } diff --git a/packages/engine-cli/template/designer/registry.js b/packages/engine-cli/template/designer/registry.js index af0a65328..50ef87872 100644 --- a/packages/engine-cli/template/designer/registry.js +++ b/packages/engine-cli/template/designer/registry.js @@ -15,6 +15,12 @@ import { HttpService } from './src/composable' const baseURL = import.meta.env.BASE_URL || '.' const baseURLWithoutSlash = baseURL.replace(/\/$/, '') +const hasPreviewUrl = Object.prototype.hasOwnProperty.call(import.meta.env, 'VITE_PREVIEW_URL') +const previewUrl = hasPreviewUrl + ? import.meta.env.VITE_PREVIEW_URL + : ['production', 'alpha'].includes(import.meta.env.MODE) + ? `${baseURLWithoutSlash}/preview.html` + : '' export default { [META_SERVICE.Http]: HttpService, @@ -51,7 +57,7 @@ export default { options: { // 配置预览跳转的 url:根据实际业务需求进行配置 // 文档:https://opentiny.design/tiny-engine#/help-center/course/dev/preview-api - previewUrl: ['prod', 'alpha'].includes(import.meta.env.MODE) ? `${baseURLWithoutSlash}/preview.html` : '' + previewUrl } } }