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

quanshi-poster

v1.2.6

Published

a easy poster designer!

Downloads

9

Readme

功能介绍

海报模板设计端:

输入图片说明

海报模板内容合成端:

输入图片说明

模板端功能

1. 支持海报背景上传
2. 支持活动模板元素区域内任意拖动(需要参数配置)
3. 支持活动模板元素任意缩放(需要参数配置)
4. 支持活动元素内容的编辑(需要参数配置)
4. 支持重置模板元素位置
5. 智能记忆元素模板拖动位置
6. 支持生成海报模板截图

内容模板合成端功能

1. 支持海报内容与模板活动元素的融合。
2. 支持内容的人工调试,编辑(需要参数配置)
3. 支持最终海报生成截图

使用教程:

第一步:

npm install quanshi-poster --save-dev

第二步:使用端引入组件

import {PosterDesigner, PosterTool} from 'quanshi-poster'

PosterDesigner: 为模板端组件
PosterTool: 为内容合成端组件

第三步: 模板端组件调用方法

PosterDesigner.show({
        bizType: "designer", //业务类型: designer:模板设计端,composer:内容模板合成端,默认是设计端, 非必填参数
        title: "编辑模板", //主标题
        theme: "活动主题、活动时间、活动嘉宾、活动简介、活动二维码五个模块,可以拖拽改变位置",//副标题,描述信息 
        imageUrl: "",//海报背景图片地址
        imageExt: ["png"],//海报底图类型白名单   
        thumbnail: {scale: 1, dpi: 48},//海报截图缩放比例,及质量
        templateSize: {//海报区域的窗口尺寸
          width: 344,
          height: 612
        },
        activeElements: {//活动元素列表
            "1": {//元素id-》需要与服务端共同约定,在模板与动态内容合成时需要进行匹配
              id: "1",//元素id-》需要与服务端共同约定
              content: "",//元素中填充的内容非必填
              type: "text",//活动元素类型目前支持(type: text, image)
              title: "活动主题",//活动元素属性标题
              left : 22,//活动元素初始x坐标位置
              top: 22,//活动元素初始y坐标位置
              disableResize: false,//是否限制缩放 false: 不限制, true: 限制
              disableEdit: true,//是否限制编辑 false: 不限制, true: 限制
              maxHeight: 200,//内容编辑区域的最大高度限制
              minWidth: 50,//内容编辑区域的最小宽度限制
              minHeight: 30,//内容编辑区域的最小高度限制
              disableDrag: false,//是否限制拖拽 false: 不限制, true: 限制
              style: {//活动元素的css样式,方便后续可视化扩展
                  fontSize: "22px",
                  color: "#000",
                  width: 95,
                  height: 32
              }
          },
          "2": {
            id: "2",
            content: "",//元素中填充的内容非必填
            type: "text",
            title: "活动时间",
            left : 22,
            top: 80,
            disableEdit: true,
            disableResize: false,
            minWidth: 50,
            minHeight: 20,
            disableDrag: false,
            style: {
                fontSize: "12px",
                width: 52,
                height: 22
            }
           },
           "3": {
            id: "3",
            content: "",//元素中填充的内容非必填
            type: "text",
            title: "活动嘉宾",
            left : 22,
            top: 126,
            disableEdit: true,
            disableResize: false,
            minWidth: 50,
            minHeight: 30,
            disableDrag: false,
            style: {
                fontSize: "12px",
                width: 52,
                height: 22
            }
           },
           "4": {
            id: "4",
            content: "",//元素中填充的内容非必填
            type: "text",
            title: "活动简介",
            left : 22,
            top: 172,
            disableEdit: true,
            disableResize: false,
            minWidth: 50,
            minHeight: 30,
            disableDrag: false,
            style: {
                fontSize: "12px",
                width: 52,
                height: 22
            }
           },
           "5": {//海报二维码Id固定是5否则会出问题
             id: "5",
             content: "",//必须为base64的海报二维码,否则截图可能会出问题
             desc: "微信扫码参加活动",
             type: "image",
             title: "二维码",
             left: 22,
             top: 397,
             disableResize: false,
             disableDrag: false,
             minWidth: 64,
             minHeight: 64,
             style: {
               width: 64,
               height: 64,
               lineHeight: "64px",
               textAlign: "center",
               backgroundColor: "#FFF",
               fontSize: "12px" 
             } 
           }
        },
        defaultActiveElements: {//同activeElements的数据格式,当用户点击重制位置的时候会使用这里的元素设置


        },
        onConfirm(data, image, confirmOk, confirmFail) {//确认按钮事件回调 data:活动元素位置信息,image:海报截图base64字符串,confirmOk 函数类型, 保存成功时调用, confirmFail 函数类型,出错的时候调用。
            console.log(data, image);
        },
        uploadPic(file, setImageURL, err) {//海报上传事件的回调方法, file: 图片文件对象,setImageURL: 函数,开发者将图片云端地址回显到组件内, err: 图片上传错误结果对象
//例如          setImageURL("https://dss1.bdstatic.com/6OF1bjeh1BF3odCf/it/u=3204721291,2218979235&fm=218&app=92&f=PNG?w=121&h=75&s=27C8B34858FA3C9CA005455A0300C0D0");
        }
      }); 

第三步: 模板内容合成端组件调用方法

 /**从服务端获取的模板元数据信息 */
  let templalteData = {
                bizType: "composer", 
                imageUrl: "",//海报底图云端图片地址
                thumbnail: {scale: 1, dpi: 48},//海报截图缩略图,分辨率参数
                templateSize: {//海报设计区域的尺寸,需要用户根据服务端模板数据进行二次合并
                  width: 270,
                  height: 480
                },
                activeElements: {//活动元素列表
                  "1": {
                    id: "1",
                    type: "text",
                    title: "活动主题:",
                    content: "农业与鸡蛋大会· 杭州国际博览农业展",//活动元素对应的具体内容, 需要从服务端获取后进行合并.
                    left : 22,
                    top: 22,
                    disableResize: true,
                    disableEdit: true,
                    maxHeight: 200,
                    minWidth: 50,
                    minHeight: 30,
                    disableDrag: true,
                    style: {
                        fontSize: "22px",
                        color: "#000"
                    }
                },
                "2": {
                  id: "2",
                  type: "text",
                  title: "活动时间:",
                  content: "2021-03-23 周三 10:30-12:00",
                  left : 22,
                  top: 100,
                  disableEdit: true,
                  disableResize: true,
                  minWidth: 50,
                  minHeight: 30,
                  disableDrag: true,
                  style: {
                      fontSize: "12px"
                  }
                },
                "3": {
                  id: "3",
                  type: "text",
                  title: "活动嘉宾:",
                  inputTips: "请输入嘉宾信息",//输入框提示文案
                  content: "",
                  left : 22,
                  top: 126,
                  disableEdit: false,
                  disableResize: false,
                  minWidth: 56,
                  minHeight: 22,
                  disableDrag: false,
                  style: {
                      fontSize: "12px",
                      height: 22
                  }
                },
                "4": {
                  id: "4",
                  type: "text",
                  title: "活动简介:",
                  inputTips: "请输入简介信息",
                  content: "你们你们你们你们你们你们你们你们你们你们你们你们", 
                  left : 22,
                  top: 172,
                  disableEdit: false,
                  disableResize: false,
                  minWidth: 56,
                  minHeight: 30,
                  disableDrag: false,
                  style: {
                      fontSize: "12px",
                      height: 22
                  }
                },
                "5": {
                  id: "5",
                  type: "image",
                  title: "二维码",
                  content: "https://img1.baidu.com/it/u=3700526141,2671696428&fm=224&fmt=auto&gp=0.jpg",
                  left: 22,
                  top: 397,
                  disableResize: true,
                  disableDrag: false,
                  minWidth: 64,
                  minHeight: 64,
                  style: {
                    width: 64,
                    height: 64,
                    lineHeight: "64px",
                    textAlign: "center",
                    backgroundColor: "#FFF",
                    fontSize: "12px" 
                  } 
                }
    }
   , designSize: {//不需要用户手动设置,主要用于编辑区域等比例缩放使用(使用者不用关心,会自动记录)
      width: 270,
      height: 480
  }}
return (
    <div className="App">
        <PosterTool {...templalteData} style={{}}></PosterTool>
    </div>
  );

PosterTool API

1. 截图
PosterTool.capturePic((base64)=> {

})
2. 获取json格式的海报元数据
let data = PosterTool.getResult()