Merge pull request #1812 from 2betop/jssdk

修复app 渲染器页面 schemaApi 用法会存在 api 请求混乱问题
This commit is contained in:
RickCole 2021-04-16 15:42:34 +08:00 committed by GitHub
commit 23a99afee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -571,6 +571,22 @@ export const examples = [
jumpTo: (to: string) => {
location.hash = to;
},
updateLocation: (to, replace) => {
if (to === 'goBack') {
return window.history.back();
}
if (replace && window.history.replaceState) {
window.history.replaceState(
'',
document.title,
normalizeLink(to)
);
return;
}
window.history.pushState('', document.title, normalizeLink(to));
},
isCurrentUrl: (to: string, ctx: any) => {
if (!to) {
return false;

View File

@ -386,7 +386,7 @@ export default class App extends React.Component<AppProps, object> {
) : null}
{render('page', store.schema, {
key: store.activePage?.id,
key: `${store.activePage?.id}-${store.schemaKey}`,
data: store.pageData
})}
</>

View File

@ -162,7 +162,9 @@ export const AppStore = ServiceStore.named('AppStore')
if (page.schema) {
self.schema = page.schema;
self.schemaKey = '' + Date.now();
} else if (page.schemaApi) {
self.schema = null;
self.fetchSchema(page.schemaApi, self.activePage);
} else if (page.redirect) {
env.jumpTo(page.redirect);
@ -171,6 +173,7 @@ export const AppStore = ServiceStore.named('AppStore')
this.rewrite(page.rewrite, env);
} else {
self.schema = null;
self.schemaKey = '';
}
},