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

vue-easycm-shortcuts

v1.0.10

Published

easy contextMenu

Downloads

13

Readme

vue-easycm

一个简单好用的 VUE 环境菜单 (Context Menu)

更多demo: http://boenfu.github.io/vue-easycm/

http://boho.image.alimmdn.com/github/easycmdemo.gif?t=1524493555136

  • 配置简单 自定义程度高

  • 多种引用方式

  • 最高三层菜单

  • 可添加字体图标

  • 边界检测

Install

npm install vue-easycm --save

Use

  1.Import 导入

ES6

// 方法1.通过use挂载
import VueEasyCm from 'vue-easycm'
Vue.use(VueEasyCm)


//  方法2.通过require 导入
var VueEasyCm = require('VueEasyCm')



// 方法3.或者直接导入js文件
<script src="./dist/vue-easycm.js"></script>

  2.Basic Usage 基础用法

  1. 在需要触发 环境菜单 的容器标签上加上(固定写法)

    例:

    <div @contextmenu="$easycm($event,$root)"></div>

  2. 任意位置导入组件(选项数组必传,格式见配置项)

    例:

    <easy-cm :list=""></easy-cm>

3.Options 配置项

| 选项名 | 是否必须 | 默认值 | 介绍 | | :----------: | :------: | :--------------: | :--------------: | | :list | true | 无 | 选项数组 | | :tag | false | 无 | 配置多个时的标记 | | @ecmcb | false | 无 | 返回触发元素序号 | | :underline | false | false | 是否开启下划线 | | :arrow | false | false | 是否开启箭头 | | :border | false | true | 是否开启边界检测 | | :itemWidth | false | 140 | 列表项宽度 | | :itemHeight | false | 36 | 列表项高度 | | :itemSize | false | 14 | 列表项字体大小 | | :offset | false | { x: 6, y: 2 } | 显示点偏移量 | | :borderWidth | false | 6 | 边界距离 |

详细介绍:

  1. 数组格式如下

    [{
          text: 'Play Now',
          icon: 'iconfont icon-bofang',  //选填 字体图标 class
          children: [] //选填
    }]

    *嵌套的子项格式一致

  2. tag --> 标记

    需要配置多个菜单时添加 tag , 类似取个 id

    此时 @contextmenu="$easycm($event,$root,[tag])" 需要加上 tag 的值

    如:

    <div @contextmenu="$easycm($event,$root,1)">
        <p @contextmenu="$easycm($event,$root,2)"></p>
    </div>
    <easy-cm :tag="1"></easy-cm>
    <easy-cm :tag="2"></easy-cm>

    这个时候 在 p 元素上会触发 tag 为 2 的菜单

    div 的其他部分会触发 tag 为 1 的菜单

  3. ecmcb --> 回调函数

    解释:返回触发的序号数组,便于触发相应逻辑

    如:

    ​ [0] 代表第一层的第一项

    ​ [0,1] 代表第一层的第一项的第二个子项

    详见 demo code

  4. 边界检测 见 demo gif

  5. offset --> 显示点偏移量

    解释: 菜单显示位置的左上角离鼠标的距离

    如: {x:10,y:10}

    *数值参数均无需带单位

自定义样式

编写 预置的空 easy-cm-ul 样式类来修改样式

// 代码结构
<ul class="easy-cm-ul">
    <li>
      <div></div>
      <ul class="easy-cm-ul">
        <li>
          <div></div>
          <ul class="easy-cm-ul">
            <li>
              <div></div>
            </li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>

例如:

http://boho.image.alimmdn.com/github/p1.png?t=1524498301156

http://boho.image.alimmdn.com/github/p2.png

Demo Code

// gif 图源码
<template>
  <div id="app" @contextmenu="$easycm($event,$root)">
    <easy-cm :list="cmList"
             @ecmcb="test"
             :underline="true"
             :arrow="true">
    </easy-cm>
  </div>
</template>
<script>
export default {
  name: 'app',
  data () {
    return {
        // 配置数组
      cmList: [{
        text: 'Play Now',
        icon: 'iconfont icon-bofang'
      },{
        text: 'Play Next',
        icon: 'iconfont icon-xiayishou'
      },{
        text: 'More',
        children: [{
          text: 'Download',
          children: []
        },{
          text: 'Report'
        },{
          text: 'Other',
          icon: 'iconfont icon-bofang',
          children:[{
            text: 'Other-1'
          },{
            text: 'Other-2'
          },{
            text: 'Other-3'
          }]
        }]
      }]
    }
  },
  methods:{
      // 回调函数
    test(indexList){
      switch (indexList[0]){
        case 0:
          console.log('立即播放');
          break
        case 1:
          console.log('下一首播放')
          break
      }
    }
  }
}
</script>