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

file-preview-vue3-ts

v0.0.1

Published

A Vue 3 file preview component with Element Plus support

Readme

file-preview-vue3-ts

一个基于 Vue 3 + TypeScript + Element Plus 的多功能文件预览组件。 支持 PDF、Office 文档 (Docx, Excel, PPTX)、图片、视频、音频、文本等多种格式的在线预览。

特性

  • 📚 多格式支持:集成 @vue-office 实现 Office 文档预览,原生支持 PDF、图片、音视频及文本代码。
  • 懒加载:内置 IntersectionObserver,仅当文件进入视口时才加载资源,优化多文件预览性能。
  • 🎭 多展示模式
    • Tab 标签页:适合文档对比。
    • Carousel 走马灯:适合图片画廊。
    • List 列表:适合流式浏览。
  • 📦 开箱即用:基于 Element Plus UI,提供优雅的加载与错误处理状态。
  • 🛠 TypeScript:完全的类型定义支持。

安装

npm install file-preview-vue3-ts
# 确保已安装 peerDependencies
npm install vue element-plus

快速开始

全局注册

import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import FilePreview from 'file-preview-vue3-ts'
import 'file-preview-vue3-ts/dist/style.css'

const app = createApp(App)
app.use(ElementPlus)
app.use(FilePreview)
app.mount('#app')

局部引入

<script setup lang="ts">
import { FilePreview } from 'file-preview-vue3-ts'
import 'file-preview-vue3-ts/dist/style.css'

const file = {
  url: 'https://example.com/document.docx',
  name: '测试文档.docx',
  type: 'docx'
}
</script>

<template>
  <div style="height: 600px;">
    <FilePreview :file="file" />
  </div>
</template>

多文件预览

支持传入数组,并配置 displayMode

<script setup lang="ts">
import { FilePreview } from 'file-preview-vue3-ts'

const files = [
  { url: 'https://example.com/slide.pptx', name: '演示文稿', type: 'pptx' },
  { url: 'https://example.com/sheet.xlsx', name: '数据表', type: 'xlsx' },
  { url: 'https://example.com/image.png', name: '图片', type: 'png' }
]
</script>

<template>
  <!-- Tab 模式 (默认) -->
  <FilePreview :file="files" display-mode="tab" />
  
  <!-- 走马灯模式 -->
  <FilePreview :file="files" display-mode="carousel" />
  
  <!-- 列表模式 -->
  <FilePreview :file="files" display-mode="list" />
</template>

API

Props

| 属性名 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | file | IFileSource | IFileSource[] | - | 文件对象或数组 | | displayMode | 'tab' \| 'carousel' \| 'list' | 'tab' | 多文件展示模式 | | width | string \| number | '100%' | 容器宽度 | | height | string \| number | '100%' | 容器高度 | | multiFileConfig | object | - | 多文件模式的详细配置 (如 Tab 位置, 轮播间隔等) |

IFileSource 类型

interface IFileSource {
  url?: string;           // 文件 URL
  content?: Blob | File;  // 文件流 (优先级低于 url)
  name?: string;          // 文件名
  type?: string;          // 文件类型 (docx, pdf, xlsx, etc.)
}

支持格式

| 类型 | 实现方案 | 备注 | | --- | --- | --- | | PDF | @vue-office/pdf | 支持缩放、分页 | | Word | @vue-office/docx | 支持 .docx 格式 | | Excel | @vue-office/excel | 支持 .xlsx 格式 | | PPT | @vue-office/pptx | 支持 .pptx 格式 | | 图片 | 原生 <img> | jpg, png, svg, gif, webp | | 视频 | 原生 <video> | mp4, webm, ogv | | 音频 | 原生 <audio> | mp3, wav, ogg | | 文本 | 原生 <pre> | txt, json, md, code |

许可证

MIT