Skip to content

EspoCRM – Open Source CRM Application

use bfcache

Yuri Kuznetsoved9cb77bbaef
diff --git a/html/main.html b/html/main.html
index cdb94e2aca..866326c552 100644
--- a/html/main.html
+++ b/html/main.html
@@ -13,22 +13,40 @@
<link rel="alternate icon" href="{{basePath}}{{faviconAlternate}}" type="image/x-icon">
<link rel="icon" href="{{basePath}}{{favicon}}" type="{{faviconType}}">
<script nonce="{{nonce}}">
- window.addEventListener('DOMContentLoaded', () => {
+ let loadedApp;
+
+ const run = app => {
+ {{runScript}}
+ };
+
+ const init = () => {
require('{{appClientClassName}}', App => {
new App({
id: '{{applicationId}}',
useCache: {{useCache}},
- cacheTimestamp: {{cacheTimestamp}},
- appTimestamp: {{appTimestamp}},
- basePath: '{{basePath}}',
- apiUrl: '{{apiUrl}}',
- ajaxTimeout: {{ajaxTimeout}},
- internalModuleList: {{internalModuleList}},
- bundledModuleList: {{bundledModuleList}},
- }, app => {
- {{runScript}}
+ cacheTimestamp: {{cacheTimestamp}},
+ appTimestamp: {{appTimestamp}},
+ basePath: '{{basePath}}',
+ apiUrl: '{{apiUrl}}',
+ ajaxTimeout: {{ajaxTimeout}},
+ internalModuleList: {{internalModuleList}},
+ bundledModuleList: {{bundledModuleList}},
+ }, app => {
+ loadedApp = app;
+
+ run(app);
});
});
+ };
+
+ window.addEventListener('pageshow', event => {
+ if (event.persisted && loadedApp) {
+ run(loadedApp);
+
+ return;
+ }
+
+ init();
});
</script>
</head>