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

wowjoy-print

v1.0.0

Published

report print utils

Downloads

3

Readme

华卓平台中心打印工具

安装

npm install -D @wowjoy/print

API

htmlPrint 打印html

语法

htmlPrint(ele: HTMLElement, isPreview?: boolean): promise

printPdf 打印 pdf 当 isPreview 为true 是 会用浏览器的打印 否则是静默打印

语法

printPdf(pdfurl: string, isPreview?: boolean = false)

getLodop 获取lodop 对象 获取后可自行调用lodop打印接口 文档参考lodop文档

silentPrint 配置模版的静默打印

async function printTemplateSilent (templateId: string, params?:Record<string, any>) => Promise

参数

templateId: [string] - 积木报表生成的模板id params: [object] 拼接到url后面的参数

返回值

promise

setBaseUrl 设置打印模板的baseUrl 和 path 若不设置 会使用平台配置的参数管理里的值

语法

setBaseUrl(baseUrl: string, path?: string = '/jmreport/view/'): void

print 直接调出浏览器打印界面

语法

print(templateId: string, searchParams?: object): promise

参数

templateId: [string] 积木报表生成的模板id

searchParams?: [object] 拼接到url后面的参数

返回值

promise

print 使用注意事项

由于print 内部是使用 iframe 载入预览页面, 通过iframe.contentDocument 操作打印, 使用时请满足以下条件:

  1. 积木报表的二级域名 和 使用项目部署的二级域名必须相同
  2. 如果是嵌入到 qiankun 的子应用, 请将 qiankun 主应用的 document.domain 设置为二级域名

域名操作可以使用提供的工具函数 createDomainOperator

用法

  import {print} from '@wowjoy/print'
  print(templateId, {id: 1}).then(() => {
    console.log('获取资源完毕, 开始打印...')
  })

getUrl 返回打印页面的预览url 您可以使用 获取到的url 利用 iframe 自行嵌入到您需要的位置

语法

getUrl(templateId: string, searchParams?: object): string

参数

templateId: [string] 积木报表生成的模板id

searchParams?: [object] 拼接到url后面的参数

返回值

string eg: www.print.com/preview/{templateId}?{searchParams.key1=searchParams.value1}&{searchParams.key2=searchParams.value2}

用法

  import {getUrl, Modal} from '@wowjoy/print'
  const templateId = '123456'
  const searchParams = {id: 1}
  getUrl(templateId, searchParams).then((url) => {
    console.log(getUrl) // www.print.com/preview/123456?id=1
  })

printPreview弹窗预览 弹窗展示通过 geturl 获取到的 url 页面

语法

interface IPrintModalBaseParams {
  onOk?: () => any,
  onCancel?: () => any,
  params?: {[key: string]: string},
  width?: number | undefined,
  height?: number | undefined,
  cancelBtnText?: string | undefined,
  printBtnText?: string | undefined,
  title?: 'string',
}
interface IPrintModalWithTemplateParams extends IPrintModalBaseParams{
  templateId: string, 
}
interface IPrintModalWithUrlParams extends IPrintModalBaseParams {
  url: string,
}

function printModal(params: IPrintModalWithTemplateParams): void;
function printModal(params: IPrintModalWithUrlParams): void

打印接口的实现是通过 iframe 获取到里面的打印按钮,触发 click 事件, 浏览器同源策略需要同源才能获取到 iframe 里的 dom 信息,所以 调用 print 的域名 和 打印模板配置的部署域名 需要在同一个二级域名下, 这个接口用于将 document.domain 从当前域名提升到二级域名

语法

createDomainOperator()

返回值

domainOperator: { upper: ()=> void, /** 将 document.domain 设置为二级域名 */

reset: () => void, /** 还原 document.domain */ }

用法

import {createDomainOperator} from '@wowjoy/print'
const domainOperator = createDomainOperator()
domainOperator.upper()
print('templateId', {id: 1})
domainOperator.reset()