Commit 1b4932ef by Jaxon

修复(营销推送策略/页面配置): 优化iframe域名校验和配置加载逻辑

改用配置中的域名和路径构建iframeUrl,将iframe允许的跨域源改为读取配置值,新增可选链避免配置缺失时报错
1 parent 68569930
......@@ -182,6 +182,7 @@ export default {
file: [],
materialList: [],
iframeUrl: "",
iframeDomain: "",
rules: {
pageTitle: [
{ required: true, message: "请输入网页标题", trigger: ["blur"] },
......@@ -227,7 +228,10 @@ export default {
window.removeEventListener("message", this.eventListenerIframeReady);
},
async mounted() {
this.iframeUrl = baseConfig.marketingManagement.marketingPushStrategy.pageConfigH5Addres;
const pageConfig = baseConfig?.marketingManagement?.marketingPushStrategy?.pageConfig || {};
const pagePath = (pageConfig.path || "").replace(/^https?:/, "");
this.iframeUrl = `${pageConfig.domain}/${pagePath}`;
this.iframeDomain = pageConfig.domain;
window.addEventListener("message", this.eventListenerIframeReady);
},
......@@ -368,7 +372,7 @@ export default {
return hash ? `${finalUrl}#${hash}` : finalUrl;
},
async eventListenerIframeReady(e) {
if (!["http://single-pages.test.glsx.com.cn", "http://single-pages.glsx.com.cn"].includes(e.origin)) {
if (this.iframeDomain !== e.origin) {
return;
}
if (e.data.type !== "SOP_MATERIAL_PREVIEW_READY") {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!