不管線上還是本地開發,插件管理裡經常找不到剛安裝或最近操作過的某個應用,也是鴿了略久搞出了「最近使用」功能:
功能一如既往的塞進了某個已有插件裡:
後台二級菜單 - Z-Blog 應用中心:
插件免費,鏈接內也有截圖效果;
「- -」「- -」「- -」
下邊是部分代碼,感覺可以在其他項目利用;
想說GitHub Copilot
還是有點兒好用的。
// localStorage 封裝
const lsObj = {
setItem: function (key, value) {
localStorage.setItem(key, JSON.stringify(value));
},
getItem: function (key, def = "") {
const item = localStorage.getItem(key);
if (item) {
return JSON.parse(item);
}
return def;
},
};
const gob = {
// 永遠從當前頁面讀取的完整列表;
curPlugList: null,
// 上一次保存的完整列表,和 cur 對比不同 —— 新安裝或啟用狀態改變 —— 壓入 his;
lstPlugList: null,
// 此處記錄內容即為「最近使用」或者說「最近活動」的項目,main.php 點擊時也會記錄並壓入此數組;
hisPlugList: null,
lsKey: {
lst: "lstPlugList",
his: "hisPlugList",
},
load: function (lstDef, hisDef) {
this.lstPlugList = lsObj.getItem(this.lsKey.lst, lstDef);
this.hisPlugList = lsObj.getItem(this.lsKey.his, hisDef);
},
save: function () {
lsObj.setItem(this.lsKey.lst, this.lstPlugList);
lsObj.setItem(this.lsKey.his, this.hisPlugList);
},
};