Skip to content

Commit

Permalink
🎈 perf(log): 过多 频繁打印信息
Browse files Browse the repository at this point in the history
修正 README 错别字
  • Loading branch information
CCKNBC committed May 25, 2023
1 parent 305131d commit e3fc4f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

本仓库/插件 内容根据 **[原仓库](https://github.com/glazec/hexo-web-push-notification)** 进行修改,感谢原作者 **[@glazec](https://github.com/glazec)** 以及贡献者: **[@GoodBoyboy666](https://github.com/GoodBoyboy666)**

## 注意
> 0.2.0 版本即将发布,与最新版本无较大差异,待逻辑测试没问题后发布版本
升级至目前最新版本,请注意查看配置项变更
`action_buttons` `delay`

当文章头设置 `webpushr: false` 时,可关闭本篇文章推送,此参数主要防止久远文章更新推送

## 安装

![node-current](https://img.shields.io/node/v/hexo?label=%E6%8E%A8%E8%8D%90&logo=node.js&style=for-the-badge)
Expand Down Expand Up @@ -36,7 +43,7 @@ npm install https://github.com/Rock-Candy-Tea/hexo-webpushr-notification.git

## 使用

如果你想了解推送效果,或者如何获取`key`可前往博客查看[文档](https://blog.ccknbc.cc/posts/hexo-webpushr-notification/)否则建议您直接查看配置,因为博客配置内容不会及时更新
如果你想了解推送效果,或者如何获取`key`可前往博客查看[文档](https://blog.ccknbc.cc/posts/hexo-webpushr-notification/)否则建议您直接优先选择查看`GitHub`配置,因为博客配置内容不会及时更新

## 配置

Expand All @@ -57,19 +64,19 @@ webpushr:
# 如果您的仓库私有,则无需担心此问题

trackingCode: "BB9Y-w9p3u0CKA7UP9nupB6I-_NqE2MuODmKJjyC4W2YflX06Ff_hEhrNJfonrut5l6gCa28gC83q2OII7Qv-oA"
icon: "https://cdn1.tianli0.top/gh/ccknbc-backup/cdn/image/pwa/192.png" # 必须为192*192 png图片
icon: "https://.../192.png" # 必须为192*192 png图片
# auto_hide: "0" # 默认为 1,代表true,即自动隐藏
# sort: "date" # 默认为updated,即只要最新文章更改了更新时间即推送新文章,改为date即文章第一次发布时间
# delay: "30" # 延时推送,考虑到CDN缓存更新,默认定时为在 hexo d 10分钟后推送,单位为分钟(最短时间为5min
# delay: "0" # 延时推送,考虑到CDN缓存更新,默认定时为在 hexo d 10分钟后推送,单位为分钟(最短延时为5分钟,设置 0 则会立即推送
# expire: "15d" # 推送过期时长,默认值为7天,格式如下:'5m'代表5分钟,'5h'代表5小时, '5d'代表5天.
# image: # 默认为文章封面,Front-matter 属性为'cover'(butterfly主题友好选项),如果您没有定义默认封面或此属性,请在这里设置默认image
action_buttons: # 如果你需要额外自定义按钮 可按照如下格式:
- title: 阅读全文 # 当 title 未配置时 默认值为 “前往查看”
# url: # 当 url 未配置时 默认值为 最新文章链接
- title: 订阅页面
url: https://blog.ccknbc.cc/sub/
# 最多可配置 3 个按钮,但 action_buttons 为未定义时也默认保留了一个按钮,即前往查看,除非设置为 false
# action_buttons: false # 当设为 false 则不显示额外的按钮,因为隐藏按钮即为当前文章链接,所以其实没必要配置
# 最多可配置 3 个按钮,但 action_buttons 未定义时也默认保留了一个按钮,即前往查看,除非设置为 false
# action_buttons: false # 当设为 false 则不显示额外的按钮,因为隐藏按钮即为当前文章链接

# 以下配置为按订阅主题推送给不同订阅用户,请按照数组形式,一一对应,具体位置请看使用文档
categories: [工作, 博客, 工具, 生活, 音乐, 学习]
Expand All @@ -81,8 +88,6 @@ webpushr:
# 您也可以将segment 设置为 all-users 对应的ID,同样也可以实现推送至所有用户
sid: "119810055" # 单个用户ID 可在控制台查看 https://app.webpushr.com/subscribers

sw_self: true #兼容service worker的其他功能选项(自行注册)

# 此外,在文章 Front-Matter 处
# 可覆盖 auto_hide 和 expire 配置,针对需要特别提醒文章可以设置不自动隐藏及过期时间延长等操作
# 以及可指定schedule参数(例如:schedule: 2022-10-01 00:00:00),定时推送
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-webpushr-notification",
"version": "0.1.10",
"version": "0.1.11",
"description": "Hexo Push Posts Update Notification Automatically With Webpushr",
"main": "webpushr.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions webpushr.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ if (hexo.config.webpushr.enable) {
if (!hexo.config.webpushr.sw_self) {
hexo.on('generateAfter', async () => {
await fs.writeFile('public/webpushr-sw.js', 'importScripts("https://cdn.webpushr.com/sw-server.min.js");');
hexo.log.info('已自动生成: webpushr-sw.js');
});
}
}
Expand All @@ -62,7 +61,7 @@ hexo.extend.filter.register('after_render:html', data => {

// 部署前获取在线 newPost.json(旧版本)
hexo.on("deployBefore", async () => {
hexo.log.info('正在获取 在线 文章信息');
hexo.log.info('正在获取 在线 最新文章信息');
newPostOnlineSite = async () => {
try {
var result = await axios.get(`${hexo.config.url}/newPost.json`, {
Expand All @@ -82,13 +81,13 @@ hexo.on('deployAfter', async () => {
var newPostLocal = await fs.readFileSync('public/newPost.json');
newPostLocal = JSON.parse(newPostLocal);
if (!newPostLocal) {
hexo.log.warn('获取本地版本 "newPost.json" 失败,可能为未生成文件或读取超时');
hexo.log.error('获取本地版本 "newPost.json" 失败,可能为未生成文件或读取超时');
return false;
}
newPostOnlineSite = await newPostOnlineSite();
newPostOnlineSite = await JSON.parse(JSON.stringify(newPostOnlineSite));
if (!newPostOnlineSite) {
hexo.log.warn('获取在线版本 "newPost.json" 失败,可能为首次推送更新或站点无法访问');
hexo.log.error('获取在线版本 "newPost.json" 失败,可能为首次推送更新或站点无法访问');
return false;
}
// console.log('本地版本 \n', newPostLocal);
Expand Down

0 comments on commit e3fc4f5

Please sign in to comment.