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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@allfile-preview/vue3

v0.1.4

Published

@allfile-preview/core 的 Vue3 封装(组件化 props/emits,无需配置 isCustomElement)

Readme

@allfile-preview/vue3

@allfile-preview/core 的 Vue3 封装组件:类型完整的 props / emits,无需配置 isCustomElement,在 SFC / JSX / 模板中直接使用。

支持预览的文件类型与全部功能(图片 / 视频 / 音频 / PDF / TXT / Markdown / Word / Excel 全家族、缩放、水印、下载、自定义操作栏等)见 core 文档。在线体验:https://allfile-preview.softinstall.top/

支持的文件格式:图片(jpg / jpeg / jfif / png / gif / webp / bmp / svg / avif / ico)、视频(mp4 / webm / mov / m4v / ogv)、音频(mp3 / wav / ogg / m4a / flac / aac / opus)、PDF、Word(docx)、Excel 家族(xlsx / xls / xlsm / xlt / xltm / xlam / xla / ods / fods / ots)、Markdown(md)、文本(txt / log / json / xml / csv / tsv / yaml / ini / sql / js / ts / css / html / vue / eml / rtf / java / php / py 等所有纯文本)。完整格式说明与暂不支持清单见 core 文档。

安装

npm install @allfile-preview/vue3 @allfile-preview/core
  • @allfile-preview/core 为 peer 依赖,必须同时安装(负责注册 <file-preview> 自定义元素)
  • 组件导出 ESM 与 CJS 两种格式

快速开始

<script setup lang="ts">
import { ref } from 'vue'
import { FilePreview } from '@allfile-preview/vue3'
import '@allfile-preview/core'

const url = ref('/media/movie.mp4')
const preview = ref()

function onZoom(detail: { scale: number }) {
  console.log('缩放:', detail.scale)
}
function play() {
  preview.value?.play() // 命令式 API
}
</script>

<template>
  <FilePreview
    ref="preview"
    :src="url"
    type="video"
    name="示例.mp4"
    color="#10b981"
    downloadable
    @load="onZoom"
    @zoom="onZoom"
    @error="(d) => console.log(d.message)"
    @timeupdate="(d) => console.log(d.currentTime)"
  />
</template>

Props

与 <file-preview> 元素属性一一对应(组件内部以 DOM property 方式透传,与 Lit 响应式属性语义一致):

| Prop | 类型 / 默认值 | 说明 | |---|---|---| | src | string / '' | 文件地址(http / blob / data URL) | | type | 'image' \| 'video' \| 'audio' \| 'pdf' \| 'text' \| 'markdown' \| 'docx' \| 'xlsx' \| 'auto' / auto | auto 时自动检测 | | name | string / '' | 文件名(扩展名参与检测;audio 模式下作标题) | | mime | string / '' | MIME 提示 | | poster | string / '' | 视频/音频封面 | | autoplay / muted / loop | boolean / false | 媒体播放控制 | | preload | string / 'metadata' | 预加载策略 | | crossorigin | string / '' | CORS 属性 | | color | string / '' | 主题色 | | cMapUrl | string / '' | pdfjs cMaps 目录(中文等非嵌入字体 PDF 需要) | | downloadable | boolean / false | 操作栏显示下载按钮 | | actions | string / array / '' | 操作栏自定义按钮,每项 { key, label, danger? } | | controls | string / object / array / '' | 播放器控件配置(仅 video / audio 生效,对象覆盖式或数组白名单) | | watermark | string / object / '' | 水印配置(所有预览类型生效):{ text, image, width, height, fontSize, color, opacity, rotate, gap } |

事件

与 core 的 CustomEvent 一一对应,回调参数即 event.detail:

@load @error @zoom @rotate @reset @play @pause @ended @timeupdate @seek @volumechange @ratechange @fullscreenchange @pagechange @download @action

各事件 detail 结构见 core 文档事件表。

命令式方法(ref 调用)

const preview = ref()

preview.value?.play()            // 播放
preview.value?.pause()           // 暂停
preview.value?.seek(30)          // 跳转
preview.value?.skip(-15)         // 快退 15 秒
preview.value?.setRate(1.5)      // 倍速
preview.value?.goToPage(3)       // PDF 跳页
preview.value?.zoomTo(2)         // 缩放
preview.value?.fitWidth()        // 适应宽度
preview.value?.rotateBy(90)      // 旋转
preview.value?.reset()           // 重置
preview.value?.download()        // 下载
preview.value?.reload()          // 重新加载
preview.value?.el                // 内部 <file-preview> 元素

与直接使用自定义元素的对比

| | 直接用 <file-preview> | 用本封装组件 | |---|---|---| | vite 配置 | 需 isCustomElement | 无需 | | 事件 | 手动 addEventListener | @load 等模板绑定 | | 类型提示 | 弱 | 完整 props / emits / 方法 | | 属性响应 | DOM attribute | Vue 响应式透传 |

License

MIT