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