当前位置:网站首页>优雅地实时检测和更新 Web 应用
优雅地实时检测和更新 Web 应用
2022-08-08 14:26:00 【InfoQ】
一、背景

二、应用场景
三、功能简介
四、功能特点
五、效果截图




六、项目地址
七、使用方法
安装
npm install version-rocket
开始使用
使用默认主题
import { checkVersion } from 'version-rocket'
// 默认建议使用 package.json 中的 version 字段, 若有自定义 version, 请忽略此行
import { version } from '../package.json'
checkVersion({
localPackageVersion: version,
originVersionFileUrl: `${location.origin}/version.json`,
})
{
"name": "test",
"description": "test",
"private": true,
"version": "0.0.1",
"scripts": {
...
"generate:version": "generate-version-file dist public"
...
},
...
}
个性化设置弹窗文案和主题
import { checkVersion } from 'version-rocket'
import { version } from '../package.json'
checkVersion(
{
localPackageVersion: version,
originVersionFileUrl: `${location.origin}/version.json`,
},
{
title: 'Title',
description: 'Description',
primaryColor: '#758bfd',
rocketColor: '#ff8600',
buttonText: 'Button Text',
}
)
个性化设置弹窗提示图片
import { checkVersion } from 'version-rocket'
import { version } from '../package.json'
checkVersion(
{
localPackageVersion: version,
originVersionFileUrl: `${location.origin}/version.json`,
},
{
imageUrl: 'https://avatars.githubusercontent.com/u/26329117',
}
)
支持推送部署成功的通知到 Lark 群聊
{
"name": "test",
"description": "test",
"private": true,
"version": "0.0.1",
"scripts": {
...
"send-lark-message:test": "MESSAGE_PATH=./lark-message-staging-config.json PACKAGE_JSON_PATH=./packages/test/package.json send-lark-message"
...
},
...
}
{
// 消息卡片标题
"title": "TEST FE Deployed Successfully",
// 项目名称标签
"projectNameLabel": "Project name label",
// 项目名称
"projectName": "TEST",
// 项目分支标签
"branchLabel": "Branch label",
// 项目分支, 可用于区别部署环境
"branch": "Staging",
// 版本标签
"versionLabel": "Version label",
// 版本
"version": "1.1.1.0",
// 项目可访问地址标签
"accessUrlLabel": "Access URL label",
// 项目可访问地址
"accessUrl": "https://test.com",
// 是否@所有人标签
"isNotifyAllLabel": "Is notify all label",
// 是否@所有人: true / false
"isNotifyAll": true,
// Lark 机器人的 webhook 链接
"larkWebHook": "https://open.larksuite.com/open-apis/bot/v2/hook/xxxxxxxxxxxx",
// 可选: 部署工具描述
"deployToolsText": "Deploy tools text",
// 可选: 部署所使用的方式或平台
"deployTools": "Jenkins",
// 可选: 部署时间想要转换成的时区,默认 "Asia/Shanghai" (当你的项目要部署的目标服务器与你所在时区不同, 可以设置此字段来转换时区)
"expectConvertToTimezone": "America/New_York"
// 可选: 想要展示除模版之外的更多信息
"remark": "Trigger by bob, fix xxx bug"
}
支持传入动态生成的卡片文案
{
"name": "test",
"description": "test",
"private": true,
"version": "0.0.1",
"scripts": {
...
"send-lark-message:test": "MESSAGE_JSON='{\"title\":\"This is a dynamically generated title\",\"version\":\"1.1.0-beta\",\"accessUrl\":\"http://test.example.com\",\"isNotifyAll\":true}' send-lark-message"
...
},
...
}
个性化设置部署消息卡片
// send-lark-config.json 示例
{
// 消息卡片内容
"message": {
"msg_type": "text",
"content": {
"text": "New message reminder"
}
},
// Lark 机器人的 webhook 链接
"larkWebHook": "https://open.larksuite.com/open-apis/bot/v2/hook/xxxxxxxxxxxx"
}
八、属性/参数
checkVersion(config, options) 函数参数列表
九、相关链接
关于领创集团(Advance Intelligence Group)
往期回顾 BREAK AWAY
边栏推荐
猜你喜欢
LeetCode简单题之统计星号
「复盘」面试BAMT回来整理398道高频面试题,助你拿高薪offer
shell正则表达式,三剑客grep命令
【控制】动力学建模简介 --> 牛顿-欧拉 (Newton-Euler) 法和拉格朗日 (Lagrange) 法
从零开始,如何拥有自己的博客网站【华为云至简致远】
shell regular expression, Three Musketeers grep command
Full of dry goods, Yu Jingxin class of the Institute of Information Technology, Chinese Academy of Sciences will help you get academic research and thesis writing skills
pip install xxx 出现 AttributeError: ‘tuple’ object has no attribute ‘read’ 错误
QtWebassembly遇到的一些报错问题及解决方案
年初离职,学习半年源码,终于拿到了蚂蚁Offer,分享面试过程
随机推荐
WPF 常用布局方式
如何成为团队核心?从写出不可维护的代码开始
idea增加左右箭头
pip install xxx 出现 AttributeError: ‘tuple’ object has no attribute ‘read’ 错误
【LeetCode】761. 特殊的二进制序列
keil5——安装教程附资源包
华为云弹性云服务器ECS使用【华为云至简致远】
poj3744 Scout YYF I
兔起鹘落全端涵盖,Go lang1.18入门精炼教程,由白丁入鸿儒,全平台(Sublime 4)Go lang开发环境搭建EP00
【SWT】创建自己的SWT组件
Thesis understanding: "Self-adaptive loss balanced Physics-informed neural networks"
Verilog HDL Bits training 09 grammar foundation
基于QWebassembly的一个数据库监测工具
从零开始,如何拥有自己的博客网站【华为云至简致远】
2022-08-07 The fifth group Gu Xiangquan study notes day31-collection-Map collection
"Small yards artisan study room" friends of friends is not a friend
面试官:Redis 大 key 要如何处理?
P8352-[SDOI/SXOI2022]小N的独立集【dp套dp】
电商秒杀系统架构设计
[Redis] Redis installation and use of client redis-cli (batch operation)