沉冰浮水

沉冰浮水

做最终到的事,成为最终成为的人!
github
bilibili
mastodon
zhihu
douban

"Z-BlogPHP" Plugin Management Adds "Recently Used" Function

Whether it's online or local development, it's often difficult to find a recently installed or recently operated application in the plugin management. So I added the "Recently Used" function:

The function is added to an existing plugin:

Backend submenu - Z-Blog Application Center:

https://app.zblogcn.com/?id=1212

The plugin is free, and there are screenshots in the link;

"- -", "- -", "- -"

Here is part of the code, which can be used in other projects;

I have to say that GitHub Copilot is quite useful.

  // localStorage encapsulation
  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 = {
    // The complete list always read from the current page;
    curPlugList: null,
    // The last saved complete list, compared with cur to find differences - new installation or change in enabled status - pushed into his;
    lstPlugList: null,
    // The content recorded here is the project of "Recently Used" or "Recent Activity". It will also be recorded and pushed into this array when clicked in 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);
    },
  };
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.