我在SmartEdit中预览页面时遇到了一些问题。有时候装载量...永远卡在那里,这个问题似乎与DOM加载时间有关。
如果我打开了devtools控制台,页面可能会加载1/10次,在Mozilla上,它在没有浏览器控制台的情况下工作10/10次。因此,基本上,设置看起来很好,除了这个恼人的永久加载问题之外,一切都按预期工作。
在network选项卡中,cx-preview崩溃,出现200错误,加载仍然存在,尽管页面中的组件在加载覆盖图后面可见
同样在来自cx-preview调用的200错误之前,还有另一个红色错误,其末尾带有文本(已取消)。


更新:这里似乎有一个问题,在序列化程序中设置cx预览。如果我删除state.url.length条件,加载将是永久的。
import { RouterStateSnapshot } from '@angular/router';
import {
ActivatedRouterStateSnapshot,
CmsActivatedRouteSnapshot,
PageContext,
PageType
} from '@spartacus/core';
export class AokCuRouterStateSerializer {
serialize(routerState: RouterStateSnapshot): ActivatedRouterStateSnapshot {
const { url } = routerState;
const { queryParams } = routerState.root;
let state: CmsActivatedRouteSnapshot = routerState.root as CmsActivatedRouteSnapshot;
let cmsRequired = false;
let context: PageContext;
while (state.firstChild) {
state = state.firstChild as CmsActivatedRouteSnapshot;
if (state.data && state.data.cxCmsRouteContext) {
context = state.data.cxCmsRouteContext;
}
if (
!cmsRequired &&
(context ||
(state.routeConfig &&
state.routeConfig.canActivate &&
state.routeConfig.canActivate.find(
x => x && x.guardName === 'CmsPageGuard'
)))
) {
cmsRequired = true;
}
}
const { params } = state;
if (state.url.length > 0 && state.url[0].path === 'cx-preview') {
context = {
id: 'smartedit-preview',
type: PageType.CONTENT_PAGE
};
} else {
if (params['productCode']) {
context = { id: params['productCode'], type: PageType.PRODUCT_PAGE };
} else if (params['orderCode']) {
context = {
id: 'order-' + params['orderCode'],
type: PageType.CONTENT_PAGE
};
} else if (params['categoryCode']) {
context = { id: params['categoryCode'], type: PageType.CATEGORY_PAGE };
} else if (params['brandCode']) {
context = { id: params['brandCode'], type: PageType.CATEGORY_PAGE };
} else if (state.data.pageLabel !== undefined) {
context = { id: state.data.pageLabel, type: PageType.CONTENT_PAGE };
} else if (!context) {
if (state.url.length > 0) {
const pageLabel =
'/' + state.url.map(urlSegment => urlSegment.path).join('/');
context = {
id: pageLabel,
type: PageType.CONTENT_PAGE
};
} else {
context = {
id: 'homepage',
type: PageType.CONTENT_PAGE
};
}
}
}
return { url, queryParams, params, context, cmsRequired };
}
}发布于 2020-05-07 22:02:51
显然,这是一个与SmartEdit和Spartacus相关的问题,并将在未来的某个地方修复:https://github.com/SAP/spartacus/issues/2358 -检查最新更新
https://stackoverflow.com/questions/61658604
复制相似问题