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

ng-reuse-tab

v0.11.2

Published

``` title: reuse-tab

Downloads

2

Readme

title: reuse-tab

subtitle: 路由复用标签

module: ReuseTabModule

**latest版本: **版本

安装方式

npm i --save ng-reuse-tab

默认 ReuseTabModule 并不会注册 RouteReuseStrategy,除了引入模块以外,还需要在 手动注册 RouteReuseStrategy

app.module.ts

providers: [

 {

  provide: RouteReuseStrategy,

  useClass: ReuseTabStrategy,

  deps: [ReuseTabService],

 }

]

组件使用(在适当位置,一般是app.component.html中使用标签):

changeIndex:页面title是否显示为当前tab名(默认为:true)

change:切换页面时,当前地址及父级地址返回(currentUrl,parentUrl)

<reuse-tab [menus]="menus" [changeIndex]="false" (change)="selectPage($event)"></reuse-tab>

传入 menus 路由json


//简单粗暴使用
export const Menus = [
    {
      name: "项目管理",
      path: '/project'
    },
    ...
];
//也支持树结构(这里是为了同时拿来遍历菜单列表),如下:
export const Menus = [
    {
      name: "项目管理",
      icon: "appstore",
      img: "img base64",//未选中tab时图片显示
      selectImg: "img base64",//已选中tab时图片显示
      canClose: false, //是否可关闭(一般用于主页)
      path: '/project'
    },
    {
        name: "模型开发",
        icon: "user",
        children: [
          {
            name: "创建训练任务",
            path: "/dev/train"
          },
          {
            name: "模型任务管理",
            path: "/dev/task"
          }
        ]
      }
    {
      icon: "appstore",
      path: '/settings/staff'
    }
    
  ]

若有路由不需要复用,可在路由配置中加入 :

data:{
    useCache:false //不加则都复用
}

为了方便加入 onReuseInitonReuseDestroy 生命周期。

插件使用了ngZorro中的tab模块,当数量过多是会自动显现左右拉横条,并在最左侧加入slot,<ng-content select="[name=left-flod"></ng-content>,加入右侧slot,<ng-content select="[name=right-flod"></ng-content>

应用场景一(折叠展开菜单项目):

<reuse-tab [menus]="menus" (change)="selectPage($event)">
    <div name="left-slot" class="fold-div" (click)="isCollapsed = !isCollapsed"><i nz-icon [ngClass]="{'fold':isCollapsed}"
      nzType="menu-fold" nzTheme="outline"></i></div>
</reuse-tab>

插件加入了 页面切换 时的回调 应用场景一(切换tab时,左侧菜单项目对应打开并选中高亮):

调用界面

//拿到路由并高亮菜单栏
selectPage(route){
  this.currentUrl = route.currentUrl;
  this.parentUrl = route.parentUrl;
}