update 18-09
fix UI vs redirect page
This commit is contained in:
@ -667,11 +667,19 @@ class AApp extends window.AObject {
|
||||
this.cachePage.searchFlexPage(url, ((result) => {
|
||||
if (result) {
|
||||
this.cachePage.get(result.layout.linkID, ((result1) => {
|
||||
console.log(result);
|
||||
|
||||
if (result1) {
|
||||
console.log(result);
|
||||
this.setContentPage(result1, url);
|
||||
const a = result.layout.info;
|
||||
const doc2 = new DOMParser().parseFromString(result1.doc, "text/html");
|
||||
const doc = doc2.firstChild.querySelector("head");
|
||||
const obj = {
|
||||
html: result1.html,
|
||||
title: a.title,
|
||||
idPage: a.idPage,
|
||||
lName: a.lName,
|
||||
doc: doc,
|
||||
dynamicF: a.dynamicF
|
||||
};
|
||||
this.setContentPage(obj, url);
|
||||
} else {
|
||||
this.getPage(url, result)
|
||||
}
|
||||
@ -703,13 +711,13 @@ class AApp extends window.AObject {
|
||||
contentPage(page, url) {
|
||||
document.title = page.title + " - " + this.pageName;
|
||||
var meta = document.head.querySelector("meta[name=idPage]");
|
||||
document.body.setAttribute("page", page.idPage);
|
||||
meta.content = page.idPage;
|
||||
meta.setAttribute("layName", page.lName);
|
||||
this.loadContentPage(page.html);
|
||||
window.history.pushState({"url":url}, page.title, url);
|
||||
}
|
||||
setContentPage(page, url) {
|
||||
|
||||
this.contentPage(page, url);
|
||||
var l = new LoadScriptAsync("Page");
|
||||
if (this.isRedirectPage) {
|
||||
@ -773,8 +781,7 @@ class AApp extends window.AObject {
|
||||
}
|
||||
}
|
||||
callLoadLayout(lName) {
|
||||
this.cachePage.get(lName, ((result) => {
|
||||
|
||||
this.cachePage.get("layout|" + lName, ((result) => {
|
||||
if (result) {
|
||||
this.setLayout(result); // Set content page từ cache
|
||||
} else {
|
||||
@ -910,18 +917,17 @@ class CacheManager {
|
||||
(type === "page") ? callback(this.pageMap.get(id)) : callback(this.layoutMap.get(id));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Lấy dữ liệu từ cache (localStorage hoặc IndexedDB nếu cần)
|
||||
get(id, callback, type = "page") {
|
||||
get(id, callback, type = "cahce") {
|
||||
this._onReady(() => {
|
||||
const key = this._key(id, type);
|
||||
this.storage.get(key, (data) => {
|
||||
this.storage.get(id, (data) => {
|
||||
if (!data) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
callback(data);
|
||||
});
|
||||
}, false, type);
|
||||
});
|
||||
}
|
||||
searchFlexPage(url, callback) {
|
||||
@ -942,7 +948,7 @@ class CacheManager {
|
||||
html: obj.html,
|
||||
doc: obj.doc.innerHTML
|
||||
};
|
||||
const info = {
|
||||
let info = {
|
||||
title: obj.title,
|
||||
idPage: obj.idPage,
|
||||
lName: obj.lName,
|
||||
@ -950,7 +956,16 @@ class CacheManager {
|
||||
};
|
||||
// Lưu dữ liệu htmlData vào storage
|
||||
const idN = this.genShortID();
|
||||
let url = (obj.flexPageID !== "None") ? obj.flexPageID : window.getPathFromUrl(id);
|
||||
let url = window.getPathFromUrl(id);
|
||||
if (obj.flexPageID !== "None" && obj.flexPageID !== "") {
|
||||
if (obj.dynamicF !== null && obj.dynamicF !== undefined && obj.dynamicF != "") {
|
||||
url = obj.flexPageID;
|
||||
info = {
|
||||
lName: obj.lName,
|
||||
dynamicF: obj.dynamicF
|
||||
}
|
||||
}
|
||||
}
|
||||
this.flexPages.insert(url, { "linkID": idN, "info": info });
|
||||
this.storage.set(idN, htmlData, function () { }, type = "flex");
|
||||
if (this.countFP > 5) {
|
||||
|
||||
Reference in New Issue
Block a user