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

@hbtv/media-upload

v2.1.15

Published

上传组件

Downloads

13

Readme

@hbtv/media-upload 文件上传组件

安装

npm install @hbtv/media-upload --save

ChangeLog

更新记录

使用方法


import { MediaUpload } from '@hbtv/media-upload';

<MediaUpload
    services={services}
    fileSize="2m"
    rectSize="300*300"
    fileType={['image','video']}
    maxLength={1}
/>

API

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | fileKey | 上传时的key | string | file | | preview | 是否显示预览 | boolean | true | | multiple | 是否允许选择多个 | boolean | false | | returnUrlOnly | 是否进返回url, 否则返回整个media对象 | boolean | true | | services | 上传的接口 | 详见下方定义 | | | fileSize | 文件大小 | string,例如:512k, 1Mb等 | 2mb | | rectSize | 图片裁剪大小 | string,例如: 300*300 | undefined | | fileType | 文件类型 | array: ['image', 'file', 'video', 'audio', 'document'] | ['image'] | | maxLength | 允许上传的文件个数 | number | 1 | | buttonText | 上传按钮文章 | string | 上传 | | data | key-value 结构的数据,用于 services | object | {} | | value | 初始值 | []string | undefined | | onChange | 选中后的事件 | ( string或[] ) => void | undefined | | showButton | 是否显示上传按钮 | boolean | true | | visible | 是的显示对话框 | boolean | false | | onCancel | 对话框关闭后的回调 | () => void | undefined | | showTips | 是否显示上传提示信息 | boolean | false | | showTips | 是否显示上传提示信息 | boolean | false | | uploadByClient | 是否客户端直传oss | boolean | true |

services 的定义

services 必须实现5个方法,并返回 Promise

interface ServicesType {
    search: (params?: ParamsType) => Promise<any>; // 查询列表 ParamsType 见下方
    destroy: ({ id }: { id: number }) => Promise<any>; // 删除
    upload: (data: FormData) => Promise<any>; // 上传
    token: (disk: string, data: TokenDataType) => Promise<any>; // 获取上传七牛的token  disk=qiniu
    find: ({ id }: { id: number | string }) => Promise<any>; // 查询单个上传文件, 主要用来查询状态
}

interface ParamsType  {
    page?: string;
    pageSize?: string;
    fileSize?: string;
    fileType?: string;
    rectSize?: string;
}

interface TokenDataType {
    fileType: string;
    fileName: string;
    [k:string]: any; // 父组件传来的数据
}