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

test-crop

v1.0.9

Published

简单版裁剪 压缩工具

Downloads

5

Readme

简单版截图,暂时制作截图+压缩(自用,还未完成)

我是工具搬运工,搬这搬那,合在一起方便自己用! github地址,里面有具体使用方式(APP.vue文件)

因为看到有人下载使用,所以先声明下:如果有人需要使用先到一个新的项目中引用试一下,因为暂时为自己的一个项目简单写的,所以很多没有考虑到,不建议使用,如果尝试使用首先建议使用vue,其次可以参考下面的方法。

使用的插件: 截图工具:cropperjs 压缩工具:lrz

该插件是以vue-cli3.x的快速原型开发进行开发,如想自己编辑开发,下载后,操作如下:

npm install -g @vue/cli-service-global
//进入src下
vue serve App.vue

下载:

npm install --save test-crop

使用:

注:需要配合input使用,传入imgSrc,具体使用可以参考src目录下App.vue的引用

以下例子以Vue为主

1、引入:

//局部引入
import TestCrop from 'test-crop'
import 'test-crop/test-crop.css'

2、创建input,注册change事件,加入该方法

<input type="file" @change="uploadImg">

注:imgSrc:传入截图工具的图片地址,isShow:手动控制截图工具的显示隐藏(默认false)

uploadImg (e) {
  //...其他操作
  var file = e.target.files[0];
  var reader = new FileReader(file);
  //检测是不是文件
  if (file.type.split('/')[0] !== 'image') {
    alert('you should choose an image file');
    return;
  }
  //
  reader.onload = () => {
    const img_data = reader.result;
    if (img_data.length > 0) {
      this.imgSrc = img_data; //图片地址
      this.isShow = true; //控制是否显示
    }
  };
  reader.readAsDataURL(file);
  //...其他操作
}

3、页面引入组件:

 <test-crop
    :imgSrc="imgSrc"
    :config="config"
    @post="postFile"
    @handleCancel="handleCancel"
  >
    <template slot="end">
      <span class="btn-end">Cropper</span>
    </template>
    <template slot="cancel">
      <span class="btn-cancel">Cancel</span>
    </template>
  </test-crop>

imgSrc:如2所说,传入图片的数据base64

config:

config: {
  Compression: {
    isTrue: true,  //是否开启压缩
  },
  options: {    
    //该配置是cropperjs的配置项,支持大部分的内容,可以参考cropperjs
    // viewMode: 1,
    minContainerWidth: 680, //此处按照需求改变,手机端可以采用获取全屏的大小
    minContainerHeight: 360,
  }
},

post:返回事件,返回值为图片file,进行上传操作

handleCancel:返回事件,返回是否点击取消处理,手动对截图工具控制隐藏

其他: 按钮样式自己设置,整个test-crop可以套上div对其限制位置显示,注意必要时候加上overflow:hidden