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

@heisea/viewer

v0.2.12

Published

Vue solution for quickly building pages

Downloads

17

Readme

viewer

基于vue2的资源预览控件,支持放大、缩小、旋转、拖拽,支持远程图片预览、调起下载、打印,支持多图预览。

更新说明

v0.2.9

  1. 优化:添加了请求错误打印

v0.2.8

  1. 修复: 图片文件后缀为大写时识别成文件id

v0.2.6

  1. 修复: node_modules下pdfjs-dist 插件源码不支持电子签章预览的bug,新增一个patch-package依赖包。

v0.2.5

  1. 修复:图片预览正则出错
  2. 新增:options支持传入fetch方法

v0.2.4

  1. 修复:PDF预览发票内容显示不全
  2. 优化:Esc关闭预览,禁止事件冒泡

v0.2.3

  1. 修复:PDF预览不需要@heisea/viewer/lib/vendors~pdfjsWorker.common.js

v0.2.2

  1. 优化:错误提示
  2. 优化:图片判断正则

v0.2.1

  1. 修复:PDF预览必须@heisea/viewer/lib/vendors~pdfjsWorker.common.js
  2. 优化:允许在绑定到全局时传人参数vue.use(Viewer,options),单独使用组件时不生效。

v0.2.0

  1. 新增 pdf-viewer pdf预览组件支持支持函数预览

v0.1.1

  1. 修改下载方法,目前只保留模拟a下载的逻辑
  2. 新增downloadFN允许自定义下载方法

v0.1.0

  1. 图片预览控件

兼容

  • chrome //谷歌
  • ie11 //IE
  • safari //mac safari
  • firefox // 火狐

目录说明

  • build 项目脚手架配置
  • lib 生产用代码
  • src 源码
  • index.html demo

命令

进行开发

npm start

打包出生产版本 commonjs 版本

npm run build:common

发布代码

  npm version <newversion> | major | minor | patch]
 npm publish

安装

npm i @heisea/viewer

初始化


import Viewer from '@heisea/viewer'
Vue.use(Viewer,{
    props: {
        fileId: 'id',
        fileName: 'originalFileName',
        fileSuffix: 'ext',
        fileUrl: 'url',
        data: 'data'
    },
    http: {
        filePath: 'http://hxgw.heisea.cn/base/fe/info'
    },
    fetch
}); // 当前组件
Vue.prototype.$fetch = fetch; // 当传参数时会调用当前获得文件

注意pdf预览,必须设置拷贝字体资源文件夹cmaps 到根目录

new CopyWebpackPlugin({
        patterns: [
            {
                from: path.resolve(__dirname, '../node_modules/@heisea/viewer/lib/cmaps/'),
                to: path.resolve(__dirname, '../dist/cmaps/')
            }]
    }),

使用

1.当组件使用

<template>
     <img-viewer v-bind="cfg" />
</template>
<script>
export default {
    data() {
        return {
            cfg: {
                mode: 'img',
                value: 'http://bucket-cert-test.oss-cn-shanghai.aliyuncs.com/2019/10/51df3ed3-fa5f-4334-9963-6767fe63aa06.jpg'
            },
        };
    }
};
</script>

2.函数调用 this.$viewer({value:url,options}) 支持单独配置配置当前预览器

    // 直接打开图片
    this.$viewer('http://bucket-cert-test.oss-cn-shanghai.aliyuncs.com/2019/10/51df3ed3-fa5f-4334-9963-6767fe63aa06.jpg');
    // 直接打开id对应的资源
    this.$viewer('1182133098524016641,1182222336212881410');

配置

属性名 | 类型 | 说明 --- | --- | --- mode|String|显示状态node:不显示,btn:按钮,img:图片 value|Auto|显示的内容object:作为资源对象,Array:多个资源对象,String:资源地址(支持用‘,’分割多个) btnLabel|String、Function|mode:btn时使用修改显示内容,默认:“查看文件”,同时支持直接 http | Object | 请求配置,必须配置$fetch http.filePath | String | 文件请求地址 props| Object | 配置字段 extend | Object | 站位节点属性配置 downloadFN | Function | 自定义资源下载逻辑(url,fileName)