惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

diss带码

datart系列04:基于threejs自定义插件3D-MAP datart系列03:图表插件开发 datart系列02:图表插件开发作品 datart系列01:图表插件开发作品大赛 我的2021年新Mac设置 小程序:mqtt+webview控制显示内容 小程序:webview + PDF预览 小程序:数十年Lite 验证码:五福临门 开源论坛:社区选择Discourse 牛年开篇:网站拜年 github自定义主页秀 Davinci-二次开发系列08:mongoDB(JDBC查询)四种解决方案 Davinci-二次开发系列07:BI新元素尝试 Davinci-二次开发系列06:导出excel合并单元格 Metabase-BI系列12:0.35版本表达式是真的香 Davinci-二次开发系列05:echarts-gl map3D扩展 Davinci-二次开发系列04:自定义水印扩展 Davinci-二次开发系列03:区域地图下钻与选择
小程序:Painter画布
2021-08-03 · via diss带码

发表于 | 分类于 | |

Painter这个小程序画布组件应该很多人在用,github上超3K的star就已经说明这个组件的强大了。这里我们用这个组件实现短讯(如24小时动态)的分享和海报生成。

效果

p001

图二生成的图片,也是分享出去的效果,可以点击分享跳转到短讯的详情即可,分享到群如下:

p002

介绍

Painter组件地址:https://github.com/Kujiale-Mobile/Painter

可以通过源代码看一下组件的实现方式,其实Painter的readMe里面已经把组件的实现方式描述的很详细了,组件接收json格式,然后通过pen.js(画笔)画出json格式不同类型(文本、图片、矩形、qrcode )的view绘制,这种方式设计巧妙,对于很多复杂的情况需求都能满足。而且代码完善,优化调整也很方便。

Painter提供的工具能够将json数据直接转换效果,方便调试,链接地址:

链接1:https://painterjs.github.io/

链接2:https://lingxiaoyi.github.io/painter-custom-poster/

我们上面短讯的效果,只需利用Painter封装两个组件,一个用于分享,一个用于生成海报,控制两个组件显示隐藏即可。通过按钮传递标题、时间、标签、内容等信息,并通过组件接收,然后拼装json文件传递给Painter组件。

1
2
3
4
5
<!-- 分享绘图组件 -->
<share-box wx:if="{{isCanDraw}}" isCanDraw="{{isCanDraw}}" time="{{timeShare}}" source="{{sourceShare}}" id="{{idShare}}" title="{{titleShare}}" content="{{contentShare}}" bind:close="handleClose" bind:initData="initData" bind:createPoster="createPoster"/>

<!-- 海报组件 -->
<poster-box isPoster="{{isPoster}}" time="{{timeShare}}" source="{{sourceShare}}" id="{{idShare}}" title="{{titleShare}}" content="{{contentShare}}" bind:closePoster="handleClosePoster"/>

此外,我们利用lin-ui实现了日期的吸顶效果(备:lin-ui对于吸顶效果的封装很易用,可以尝试一下)、内容展示的卡片效果,不再赘述,详细实现可直接查看下面的代码地址。

代码

diss

已提交github,扫码关注公众号(diss带码),回复:webview,获得源码github地址