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

eg-upload

v2.1.4

Published

上传文件组件

Downloads

55

Readme

eg-upload

这是一款基于eagle-ui开发的上传文件组件;

UI展示

ui展示

使用


	import {Upload} from 'eg-upload';
    import React, { Component ,PropTypes} from 'react';
    import ReactDom from 'react/lib/ReactDOM';
    
    //completeCallback 全部上传完成
    //successCallback  单张上传成功 会执行多次
    //failureCallback  上传失败
    ReactDom.render(
        <Upload uploadUrl="http://172.24.121.17:8080/attachment/upload" maxNumber={5} successCallback={(file,data)=>{}} 
          	completeCallback={()=>{}}
			failureCallback={(file,data)=>{}}
			filter={()=>{}}
			uploadBtnText="选择上传文件"
          />,
        document.getElementById('root')
    );

API

props

  • uploadUrl:提交服务器地址;
  • maxSize:允许上传文件大小;
  • maxNumber:文件最大上传数量;
  • minNumber:文件最少上传数量;
  • uploadBtnText:上传按钮文案;
  • maxNumberMessage:超出范围的提示文案;
  • egSize:上传按钮大小(default、xs、sm、lg);
  • egStyle:上传按钮颜色(error、warning、danger、link、gray、white、success、'');
  • width:略缩图容器的宽度;
  • height:略缩图容器的高度;
  • thumbWidth:略缩图宽度;
  • thumbHeight:略缩图高度;

callback

  • completeCallback(successImageList,imageListSize):上传单个文件成功后和删除文件后执行的方法,successImageList上传成功后的文件列表,imageListSize一共选择多少个文件;

  • failureCallback(file,responseText):上传单个文件失败后执行,file失败后的文件,responseText失败信息,由服务端返回;

  • successCallback(file,data):单个文件上传成功后执行,file上传成功的文件,data服务端返回的json数据;

  • renderItemCallback(files):返回自定义略缩图模板,用户可自定义容器中显示的内容模板,该方法的作用域为upload对象本身,files需要显示的文件列表,

      
        renderItemCallback([
            index:file.index,//文件的索引
            name:file.name,//文件的名字
            result:'',//base64
            type:file.type//类型
        ])
  • filter(files,maxSize):过滤不允许上传的文件

      
        filter=(files,maxSize)=>{
            var arrFiles = [];
            for (var i = 0, file; file = files[i]; i++) {
                arrFiles.push(file);
                if (file.type.indexOf("image") == 0) {
                    if (file.size >= maxSize) {
                        alert(`您这张${file.name}图片大小过大,应小于${maxSize}k`);
                    } else {
                        arrFiles.push(file);
                    }
                } else {
                    alert('文件"' + file.name + '"不是图片。');
                }
            }
            return arrFiles;
        }

项目示例

下载项目到本地安装依赖包后执行 npm run demo 即可查看示例演示。