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-upload-utils

v0.0.7

Published

一个上传辅助工具&自定义上传样式

Downloads

216

Readme

Vue-upload-utils

visitors Static Badge Static Badge

分片上传组件&上传工具 支持Vue2和Vue3

默认组件示例

内置默认上传组件

pkIaehD.png

使用示例

安装

npm i vue-upload-utils

main.js

import 'vue-upload-utils/style.css'

vue:

<script setup>
import {reactive} from "vue";
import {Uploader} from "vue-upload-utils";
const fileList = reactive([]);
const op= {
  baseUrl: 'http://127.0.0.1:8080', // 上传服务地址
  taskFileList: fileList, // 上传文件列表
}
</script>
<template>
  <Uploader :auto-upload="true" :option="op" desc="支持扩展名: .rar .zip .doc .docx .pdf .jpg, 单个文件不超过10Mb。"/>
</template>

option参数格式

| 参数名称 | 类型 | 描述 | | :----------------: | :------: | :----------------------------------------------------------: | | baseUrl | string | 服务地址,例:http://127.0.0.1:8080 | | uploadUrl | string | 上传文件地址,例:/file/chunk-upload | | mergeUrl | string | 合并地址,例:/file/merge | | secUrl | string | 秒传校验地址,例:/file/sec-upload | | taskFileList | object[] | 上传文件列表 | | bindUploadDOMById | string | 上传按钮的DOM元素(一个页面嵌套两个需要更改) | | checkChunkUploaded | Function | 和秒传校验地址搭配,校验文件片段是否已上传:function (chunk:Chunk, message:string) return boolean | | maxSize | number | 限制最大上传文件大小(单位:MB) | | accept | string[] | 限制上传文件类型,例:['jpg','png'] | | deleteUrl | string | 文件删除地址(有值就会调用)例:/file/delete | | deleteFile | boolean | 该值会被传入后端,用于判断是否删除真实文件,搭配deleteUrl参数使用 |

自定义组件示例

<script setup>
import {reactive, onMounted, watch} from "vue";
import {initUpload, uploadAllSubmit} from "vue-upload-utils";

const fileList = reactive([]);
const op = {
  baseUrl: 'http://127.0.0.1:8080', // 上传地址
  bindUploadDOMById: 'upBtn', // 绑定上传按钮的DOM元素ID
  taskFileList: fileList, // 上传文件列表
}
onMounted(() => {
  initUpload(op)
})
//监听 fileList
watch(fileList, (newVal, oldVal) => {
  console.log(newVal)
})

function uploadFile() {
  uploadAllSubmit()
}
</script>

<template>
  <div class="bt" id="upBtn">上传文件</div>
  <br/>
  <table>
    <thead>
    <tr>
      <th>序号</th>
      <th>文件名</th>
      <th>文件大小</th>
      <th>状态</th>
    </tr>
    </thead>
    <tbody>
    <tr v-for="(file, index) in fileList" :key="file.id">
      <td>{{ index }}</td>
      <td>{{ file.filename }}</td>
      <td>{{ file.fileSize }}</td>
      <td>{{ file.statusText }}</td>
    </tr>
    </tbody>
  </table>
  <button v-show="fileList.length > 0" style="padding: 2px;border: 1px solid #ccc;" @click="uploadFile">开始上传
  </button>
</template>

<style scoped>
.bt {
  border: 1px solid #ccc;
  padding: 0.75rem;
  margin-bottom: 1rem;
}
</style>

后端服务

可以参考下面后端服务来测试。

github:https://github.com/W-Lightr/fileUpload