Update New
This commit is contained in:
@ -5,20 +5,19 @@ namespace VinFontApp.Controllers
|
||||
{
|
||||
public class TypeFontsController : Controller
|
||||
{
|
||||
[PageInfor("2001", "Type Font", "/TypeFont/*")]
|
||||
[PageInfor("2001", "Type Font", "/TypeFonts/*")]
|
||||
[Layout(LayoutOptions.Custom, "Async1")]
|
||||
public async Task<IActionResult> Index(string? id)
|
||||
{
|
||||
if (id != null)
|
||||
{
|
||||
NavItem list = WSNavigation.GetListMenu()[1];
|
||||
NavItem? result = list.SubItem.FirstOrDefault(l => l.Url.Split('/').Last().Equals(id));
|
||||
if (result != null)
|
||||
NavItem list = (await WSNavigation.GetListMenu())[1];
|
||||
if (list.SubItem != null && list.SubItem.Count > 0)
|
||||
{
|
||||
ViewData["PageID"] = result.ID;
|
||||
NavItem? result = list.SubItem.FirstOrDefault(l => l.Url.Split('/').Last().Equals(id));
|
||||
if (result != null) ViewData["PageID"] = result.ID;
|
||||
}
|
||||
}
|
||||
|
||||
ViewBag.ID = id;
|
||||
return await this.ViewAsync();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ using AppLibs.Libs;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
|
||||
WSNavigation.LoadJson();
|
||||
await WSNavigation.LoadJson();
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
#if (!DEBUG)
|
||||
|
@ -1,6 +1,6 @@
|
||||
@using AppLibs.Libs
|
||||
@{
|
||||
List<NavItem> t = WSNavigation.GetListMenu();
|
||||
List<NavItem> t = await WSNavigation.GetListMenu();
|
||||
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
if (i.SubItem == null)
|
||||
{
|
||||
<div class="nav-i">
|
||||
<a href="@i.Url" @i.ToFlexPageAttribute() nav-id="@i.ID" class="nav-item">@i.Name</a>
|
||||
<a href="@i.Url" @Html.Raw(i.IsFlexPage) nav-id ="@i.ID" class="nav-item">@i.Name</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
@ -19,7 +19,7 @@
|
||||
<div class="sub-item">
|
||||
@foreach (var j in i.SubItem)
|
||||
{
|
||||
<div class="nav-i"><a href="@j.Url" @i.ToFlexPageAttribute() @Html.Raw(i.IsFlexPage) nav-id="@j.ID" class="nav-link"><span>@j.Name</span></a></div>
|
||||
<div class="nav-i"><a href="@j.Url" @j.ToFlexPageAttribute() nav-id="@j.ID" class="nav-link"><span>@j.Name</span></a></div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -168,8 +168,8 @@ export default class AGrid extends window.AObject {
|
||||
let i = 0;
|
||||
let col = 0;
|
||||
let l = 0;
|
||||
console.log(this.listGrid);
|
||||
console.log(this.listCols);
|
||||
//console.log(this.listgrid);
|
||||
//console.log(this.listcols);
|
||||
this.listGrid.forEach((v, k) => {
|
||||
let t = 0;
|
||||
let cVal;
|
||||
|
@ -125,7 +125,7 @@ export default class AMenu extends window.AObject {
|
||||
}
|
||||
|
||||
addEventClick(e) {
|
||||
window.app.initNavApp(e.currentTarget.getAttribute("href"));
|
||||
window.app.initNavApp(e.currentTarget.getAttribute("href"), e.currentTarget.hasAttribute("isflexpage"));
|
||||
}
|
||||
closeExpandMenu() {
|
||||
Array.from(this.navM.querySelectorAll(".nav-i.has-sub")).forEach(el => {
|
||||
|
@ -650,34 +650,47 @@ class AApp extends window.AObject {
|
||||
this.addSystemEvent("click", el, f1, groups)
|
||||
const f2 = (function (ev) {
|
||||
if (window.isValidPointerClick(ev)) return;
|
||||
this.initNavApp(ev.currentTarget.getAttribute("href"));
|
||||
|
||||
this.initNavApp(ev.currentTarget.getAttribute("href"), ev.currentTarget.hasAttribute("isflexpage"));
|
||||
}).bind(this);
|
||||
this.addSystemEvent(this.eventName, el, f2, groups);
|
||||
el.setAttribute("app-nav", true);
|
||||
}
|
||||
}).bind(this));
|
||||
}
|
||||
initNavApp(t) {
|
||||
initNavApp(t, flex=false) {
|
||||
this.isRedirectPage = true;
|
||||
this.callLoadPage(window.GetAbsoluteURL(t));
|
||||
this.callLoadPage(window.GetAbsoluteURL(t), flex);
|
||||
}
|
||||
callLoadPage(url, flex = false) {
|
||||
if (flex) {
|
||||
url = window.getPathFromUrl(url);
|
||||
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);
|
||||
} else {
|
||||
this.getPage(url, result)
|
||||
}
|
||||
}).bind(this), "flex");
|
||||
} else {
|
||||
this.getPage(url);
|
||||
}
|
||||
}).bind(this));
|
||||
} else {
|
||||
this.cachePage.get(url, ((result) => {
|
||||
if (result) {
|
||||
this.setContentPage(result, url); // Set content page từ cache
|
||||
} else {
|
||||
this.getPage(url); // Load mới nếu chưa có trong cache
|
||||
}
|
||||
}).bind(this));
|
||||
}
|
||||
//if (flex) {
|
||||
|
||||
//} else {
|
||||
// this.cachePage.get(url, ((result) => {
|
||||
// if (result) {
|
||||
// // Set content page từ cache
|
||||
// } else {
|
||||
// this.getPage(url); // Load mới nếu chưa có trong cache
|
||||
// }
|
||||
// }).bind(this));
|
||||
//}
|
||||
}
|
||||
loadContentPage(content) {
|
||||
const tpl = document.createElement('template');
|
||||
@ -709,7 +722,7 @@ class AApp extends window.AObject {
|
||||
}).bind(this));
|
||||
l.processScript(page.doc);
|
||||
}
|
||||
getPage(url) {
|
||||
getPage(url, rs = null) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", this.addAttributeURL(url, "?vr=cAsync"));
|
||||
xhr.send();
|
||||
@ -717,13 +730,13 @@ class AApp extends window.AObject {
|
||||
if (evt.currentTarget.readyState == 4 && evt.currentTarget.status == 200) {
|
||||
if (evt.currentTarget.responseText) {
|
||||
var jP = JSON.parse(evt.currentTarget.responseText);
|
||||
this.loadPage(jP, window.GetAbsoluteURL(url));
|
||||
this.loadPage(jP, window.GetAbsoluteURL(url), rs);
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
xhr.addEventListener("readystatechange", f, false);
|
||||
}
|
||||
loadPage(o, url) {
|
||||
loadPage(o, url, rs) {
|
||||
const title = o.Title;
|
||||
const idPage = o.PageId;
|
||||
const doc2 = new DOMParser().parseFromString(o.Scripts, "text/html");
|
||||
@ -761,6 +774,7 @@ class AApp extends window.AObject {
|
||||
}
|
||||
callLoadLayout(lName) {
|
||||
this.cachePage.get(lName, ((result) => {
|
||||
|
||||
if (result) {
|
||||
this.setLayout(result); // Set content page từ cache
|
||||
} else {
|
||||
@ -792,7 +806,6 @@ class AApp extends window.AObject {
|
||||
if (this.lName !== "None") {
|
||||
const l = window.ALayout.get(this.lName);
|
||||
if (!l.isLoaded) {
|
||||
console.log("render M");
|
||||
l.renderMenu();
|
||||
this.isLoadedLayout = true;
|
||||
this.trigger("layoutLoaded", null);
|
||||
@ -845,7 +858,7 @@ class CacheManager {
|
||||
this.countFP = 0;
|
||||
this._loadIndex();
|
||||
window.addEventListener("beforeunload", (function (e) {
|
||||
|
||||
this.storage.set("treePage", this.flexPages.toJSON(), function () { });
|
||||
}).bind(this));
|
||||
}
|
||||
|
||||
@ -863,8 +876,7 @@ class CacheManager {
|
||||
}
|
||||
|
||||
_loadIndex() {
|
||||
this.storage.getAllKeys(((keys, type) => {
|
||||
if (type == "cache") {
|
||||
this.storage.getAllKeys(((keys) => {
|
||||
let pending = 0;
|
||||
keys.forEach(((key) => {
|
||||
if (!key.startsWith(`${this.storage.prefix}|`)) return;
|
||||
@ -872,10 +884,10 @@ class CacheManager {
|
||||
const shortKey = key.replace(`${this.storage.prefix}|`, "");
|
||||
const [type, id] = shortKey.split("|");
|
||||
|
||||
if (type === "pI") {
|
||||
if (type === "treePage") {
|
||||
pending++;
|
||||
this.storage.get(key, (data) => {
|
||||
if (data) this.pageMap.set(id, data);
|
||||
if (data) this.flexPages.fromJSON(data);
|
||||
if (--pending === 0) this._finishInit();
|
||||
}, true);
|
||||
} else if (type === "layout") {
|
||||
@ -883,9 +895,6 @@ class CacheManager {
|
||||
}
|
||||
}).bind(this));
|
||||
if (pending === 0) this._finishInit(); // Trường hợp không có key nào là "pI"
|
||||
} else {
|
||||
|
||||
}
|
||||
}).bind(this));
|
||||
}
|
||||
|
||||
@ -911,18 +920,7 @@ class CacheManager {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === "page") {
|
||||
const pInfo = this.pageMap.get(id);
|
||||
if (!pInfo) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
data.doc = new DOMParser().parseFromString(data.doc, "text/html").head;
|
||||
callback(Object.assign(data, pInfo, { url: id }));
|
||||
} else {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -951,27 +949,17 @@ class CacheManager {
|
||||
dynamicF: obj.dynamicF
|
||||
};
|
||||
// Lưu dữ liệu htmlData vào storage
|
||||
if (obj.flexPageID !== "None") {
|
||||
const idN = this.genShortID();
|
||||
this.flexPages.insert(obj.flexPageID, { "id": idN, "info": info });
|
||||
|
||||
let url = (obj.flexPageID !== "None") ? obj.flexPageID : window.getPathFromUrl(id);
|
||||
this.flexPages.insert(url, { "linkID": idN, "info": info });
|
||||
this.storage.set(idN, htmlData, function () { }, type = "flex");
|
||||
if (this.countFP > 5) {
|
||||
this.countFP = 0
|
||||
}
|
||||
console.log(this.flexPages);
|
||||
this.countFP = 0;
|
||||
//this.storage.set("treePage", this.flexPages.toJSON(), function () { });
|
||||
} else {
|
||||
this.storage.set(key, htmlData, function () { });
|
||||
|
||||
|
||||
// Lưu thông tin trang vào pageMap và storage
|
||||
this.pageMap.set(id, info);
|
||||
this.storage.set(`pI|${id}`, info, function () { });
|
||||
this.countFP++;
|
||||
}
|
||||
|
||||
|
||||
} else if (type == "flex") {
|
||||
|
||||
this.storage.set("treePage", this.flexPages.toJSON(), function () { });
|
||||
} else {
|
||||
const layout = {
|
||||
Content: obj.Content,
|
||||
@ -1078,13 +1066,7 @@ class CacheStorage {
|
||||
let store = tx.objectStore("cache");
|
||||
let req = store.getAllKeys();
|
||||
req.onsuccess = (evt) => {
|
||||
callback(evt.target.result, "cache");
|
||||
};
|
||||
tx = this.db.transaction("fpCache", "readonly");
|
||||
store = tx.objectStore("fpCache");
|
||||
req = store.getAllKeys();
|
||||
req.onsuccess = (evt) => {
|
||||
callback(evt.target.result, "flex");
|
||||
callback(evt.target.result);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user