From 3d67619aa06d1d4f048b4bebbdcb82373b606a4a Mon Sep 17 00:00:00 2001 From: lixuan Date: Wed, 22 Apr 2026 19:08:33 -0700 Subject: [PATCH] fix: Modify preview url --- designer-demo/registry.js | 8 +++++++- packages/engine-cli/template/designer/registry.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/designer-demo/registry.js b/designer-demo/registry.js index bf89228632..b358c4f314 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 af0a653289..50ef87872a 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 } } }