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

ngx-ty-menu

v1.2.6

Published

- npm i ngx-ty-menu --save - 在app.module.ts中添加代码:

Downloads

35

Readme

ngx-ty-menu 左侧菜单组件使用方法:

  • npm i ngx-ty-menu --save
  • 在app.module.ts中添加代码:
  ...

  // add ++
  import { HttpClient, HttpClientModule } from '@angular/common/http';
  import { TranslateHttpLoader } from '@ngx-translate/http-loader';
  import { TranslateLoader, TranslateModule } from '@ngx-translate/core';

  // add ++
  export function createTranslateLoader(http: HttpClient) {
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
  }

  @NgModule({
    ...
    imports: [
      ...
      // add ++
      HttpClientModule,
      TranslateModule.forRoot({
        loader: {
          provide: TranslateLoader,
          useFactory: createTranslateLoader,
          deps: [HttpClient]
        }
      }),
    ]
  })

  ...
  • 引入菜单module
  import { MenuModule } from 'ngx-ty-menu';
  • 组件引用
<app-menu 
    [data]="menuList"
    [appName]="loginName"
    (menuFoldStatus)="menuFoldStatus($event)">
</app-menu>
  • 自定义下方配置实例
<app-menu 
  [data]="menuList"
  [optionsContent]="optionsContent"
  [appName]="loginName"
  (menuFoldStatus)="menuFoldStatus($event)">
  <ng-template #optionsContent>
    <ul>
      <li>自定义</li>
    </ul>
  </ng-template>
</app-menu>
  • 组件data数据请求menu接口
  this._http.post('menus?c=' + new Date().getTime(), {}, this.ctx_auto).subscribe(data => {
    if (data && data.status === 200) {
      this.menuList = data.data;
    }
  });
  • 组件data数据格式
data = [
    {
      id: 1,              // 菜单id 【必填】
      title: '测试1',     // 菜单标题 【必填】
      enable: true,      // 菜单权限【非必填,不传该字段默认为false】true:该项菜单正常可点击;false:该项菜单禁用。
      children: [        // 菜单子集 【非必填】
        {
          id: 2,
          title: '测试二级',
          children: [
            {
              id: 3,
              title: '测试三级',
              link: '/test1'
            },
          ]
        }
      ]
    }, {
        id: 4,
        title: '测试2',
        enable: false,
        link: '/test2'  // 菜单当前路由 【最后一级必填 否则点击无效】
    },
]
  • 组件api:

|参数|说明|类型|默认值| |----|----|----|----| |[data]|【必填】菜单数据数组|any[]|-| |[productType]|【非必填】当前项目菜单productType|Array[]当前菜单项productType值包含在传入数组:路由跳转当前菜单项productType值不包含在传入数组:href跳转|[]不传入该项时,默认全部为href跳转| |[favoritesAction]|【非必填】快捷访问收藏/取消保存接口|Object{mark: 'xxx', unmark: 'xxx'}mark: 收藏接口unmark: 取消收藏接口|不传入该项时,不显示「快捷访问」菜单| |[favoritesQueryBody]|【非必填】快捷访问收藏/取消保存接口参数|Object|{menuId: ${menuId}}| |[menuConfig]|【非必填】是否展示 菜单头(logo/展开收起)、下方配置项|Booleantrue:显示菜单头与配置项false:隐藏菜单头与配置项|true| |[logoContent]|【非必填】自定义logo图标|TemplateRef|听云logologo图标点击事件跳转-> window.open('/platform/product/view', '_self');| |[mode]|【非必填】菜单类型,支持垂直和水平模式两种|垂直:'vertical'水平:'horizontal'|vertical| |[unreadMessage]|【非必填】下方默认配置中<我的消息>是否有未读信息|booleantrue:有未读消息false:无未读消息|false| |[helpDocument]|【非必填】下方默认配置中<帮助文档>跳转路径|string|/platform/onlinehelp| |[theme]|【非必填,当前仅支持白色版】主题颜色|白色版:'light'黑色版:'black'|light| |[language]|【非必填】国际化参数|中文:'zh'英文:'en'|zh| |[optionsContent]|【非必填】自定义配置项|TemplateRef|我的消息、language、帮助文档、主题、退出| |(menuFoldStatus)|菜单收起展开状态change事件回调函数|EventEmitter<boolean> 展开:false 收起:true|false| |(myMessageClick)|下方默认配置中<我的消息>点击事件|EventEmitter<boolean>|-| |(languageChange)|下方默认配置中<Language>点击change事件|EventEmitter<string>中文:'zh'英文:'en'|默认为[language]传入值| |(themeChange)|下方默认配置中<主题>换肤change事件|EventEmitter<string>白色版:'light'黑色版:'black'|默认为[theme]传入值| |(logout)|下方默认配置中<退出>点击事件|EventEmitter<boolean>|-|