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

@lin-media/contextmenu

v1.0.3

Published

contextmenu

Downloads

1

Readme

右键菜单

安装

npm i @lin-media/contextmenu

初始化

import MediaPlayer from "@lin-media/player";
import Contextmenu from "@lin-media/contextmenu";
MediaPlayer.use(Contextmenu);

const contextMenuList = [
  {
    label: "播放",
    desc: "描述信息",
    type: "MenuItem",
    callback: () => {
      player.play();
    },
    eventName: "click-play"
  },
  {
    label: "暂停",
    type: "MenuItem",
    callback: () => {
      player.pause();
    }
  },
  {
    label: "播放/暂停",
    type: "MenuItem",
    callback: () => {
      player.toggle();
    }
  },
  {
    type: "MenuLine"
  },
  {
    type: "SubMenuItem",
    label: "倍数",
    subMenuList: [
      {
        label: "0.5x",
        callback: () => {
          player.setSpeed(0.5);
        }
      },
      {
        label: "1x",
        callback: () => {
          player.setSpeed(1);
        }
      },
      {
        label: "1.5x",
        callback: () => {
          player.setSpeed(1.5);
        }
      }
    ]
  },
  {
    type: "SubMenuItem",
    label: "清晰度",
    subMenuList: [
      {
        label: "标清",
        callback: () => {
          player.switchDefinition(0);
        }
      },
      {
        label: "高清",
        callback: () => {
          player.switchDefinition(1);
        }
      }
    ]
  }
];
const player = new MediaPlayer({
  // ...
  Contextmenu: {
    // 一级菜单宽度
    menuItemWidth: "300px",
    // 二级菜单宽度
    subMenuItemWidth: "100px"
  }
});

player.$on("click-play", (item) => {
  console.log(item);
});

Contextmenu 参数

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ---------------- | -------------------- | ------ | ------ | ------ | | menuList | 菜单列表,格式见下方 | Array | — | — | | menuItemWidth | 一级菜单宽度 | string | — | 250px | | subMenuItemWidth | 二级菜单宽度 | string | — | 80% |

menuList 参数格式

菜单项分为三种格式,分别是:MenuItem,MenuItemLine,SubMenuItem

MenuItem:

| 字段 | 说明 | 类型 | | --------- | -------------------------------------------------------------- | ------ | | type | 菜单类型,值为:MenuItem | string | | label | 菜单文本 | string | | callback | 回调函数,可选。存在时,点击菜单项会执行,回调参数:MenuItem | Function | | eventName | 自定义事件,可选。存在时,点击菜单项会广播事件 | string | | desc | 描述信息,可选。 | string |

MenuItemLine:

| 字段 | 说明 | 类型 | | ---- | ------------------------- | ------ | | type | 菜单类型,值为:MenuLine | string |

SubMenuItem:

| 字段 | 说明 | 类型 | | ----------- | -------------------------------------- | ------ | | type | 菜单类型,值为:SubMenuItem | string | | label | 菜单文本 | string | | subMenuList | 二级菜单列表,列表项请参考:MenuItem | Array<MenuItem> |