npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@firesoon/plugin-layout

v0.2.5

Published

@firesoon/plugin-layout

Downloads

15

Readme

为了进一步降低研发成本,提供 @firesoon/plugin-layout 插件,将布局通过 umi 插件的方式内置。其中,packages/plugin-layout 为插件代码,packages/design-layout 为布局代码。

@firesoon/plugin-layout

安装

npm install @firesoon/plugin-layout --save-dev

使用

.umirc.ts文件

{
    plugins: [
        '@firesoon/plugin-layout',
    ],
    firesoonLayout: {},
}

app.ts文件

// 添加
export async function getInitialState() {
  // @umijs/plugin-initial-state插件
  const menuInfo = await api.getMenuList(); //获取服务端菜单数据
  const userInfo = await api.getUserInfo(); // 获取用户信息
  const roleInfo = await api.getRoleList(); // 获取角色信息
  if (
    (menuInfo && menuInfo.httpCode === 403) ||
    (menuInfo &&
      menuInfo.httpCode === 300 &&
      menuInfo.msg === '数据权限没有初始化,请联系管理员')
  ) {
    history.push('/errorPage?type=private');
  }
  if (
    menuInfo.httpCode === 200 &&
    userInfo.httpCode === 200 &&
    roleInfo.httpCode === 200
  ) {
    return {
      remoteMenu: menuInfo.data, //服务端菜单
      userInfo: userInfo.data, //用户信息
      roleList: roleInfo.data.sysRoleVoList.map((v) => ({
        //角色list
        name: v.roleName,
        value: v.id,
      })),
      breadcrumbMenus: [], //面包屑数据
      activeKey: '',
    };
  }
}

// 添加
export const firesoonLayout = {
  // @firesoon/plugin-layout插件
  logo, //项目logo
  homeId: 'home', // HOME_ID
  iconMap, //菜单图标
  localMenu, // 本地路透配置
  logoutAction: () => {
    //退出登录操作
    api.logout().then((res) => {
      if (res && res.httpCode === 200) {
        localStorage.clear();
        sessionStorage.clear();
        window.location.href = res.data;
      }
    });
  },
  onChangeRoleAction: (value) => {
    //切换角色操作
    api.modifyRole({ id: value }).then((res) => {
      if (res.httpCode === 200) {
        window.location.reload();
      }
    });
  },
  modifyPwdAction: (params, callback) => {
    //修改密码操作
    api.modifyPassword(params).then((res) => {
      if (res.httpCode === 200) {
        message.success('修改成功');
        callback(true);
      } else {
        callback(false, res);
      }
    });
  },
};

修改记录

V 0.1.5

  • 增加机构默认切换逻辑:当需要显示机构,且机构不显示全部选项,且当前hospitalAreaId为-1,则默认切换第一个机构

V 0.1.6

  • 增加免密登录逻辑,添加如下配置
import * as api from '@/services/index';

export const firesoonLayout = {
    ...,
      loginNotPwdService: api.loginNotPwd, // 免密登录接口,插件内部调用
    ...
}

V 0.1.7

  • 无菜单权限loading状态处理

V 0.1.8

  • 优化菜单接口状态码为300时的异常处理
  • 调整initDispatcher方法的返回参数,第一个参数为dispatch,第二个参数为对象,包含用户登录的userInfo和roleInfo

V 0.1.9

  • 新增修改密码时,表单验证是否使用后端接口返回值进行验证的逻辑,initAppService方法调整(api.getPasswordComplexity()非必传),如下:
  initAppService: () => {
    return [api.getMenuList(), api.getUserInfo(), api.getRoleList(), api.getPasswordComplexity()];
  },

V 0.1.21

  • 修复菜单中文映射远程返回值问题
  • 移除断网状态展示界面逻辑

V 0.1.22

  • 修复面包屑展示信息问题

V 0.1.23

  • 新增menuMode参数,当menuMode=local时,使用本地配置的菜单数据

V 0.1.24

  • 增加encryptedInfo配置,默认为false;设置为true,则开启storage敏感数据加密存储

V 0.1.25

  • 增加noLogin配置项,支撑忽略登录配置化;

V 0.1.31

  • 修复sid、signKey不存在时,访问应用内部路由,跳转登录页