Skip to content

Commit

Permalink
fix: 优化 colors 在非 Node 端的导入;优化文档说明
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed Feb 18, 2022
1 parent 38cc4a5 commit 100ab96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</a>
</p>

> Push All In One!支持 Server酱、酷推、邮件、钉钉机器人、企业微信机器人、企业微信应用、pushplus、iGot 等多种推送方式
> Push All In One!支持 Server酱、酷推、邮件、钉钉机器人、企业微信机器人、企业微信应用、pushplus、iGot 、Qmsg、息知等多种推送方式
>
> 温馨提示:出于安全考虑,**所有**推送方式请在**服务端**使用!请勿在**客户端**使用!
> 温馨提示:出于安全考虑,**所有**推送方式请在**服务端**使用!请勿在**客户端(网页端)**使用!网页端使用还将额外产生跨域问题。
### 🏠 [主页](https://github.com/CaoMeiYouRen/push-all-in-one#readme)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "push-all-in-one",
"version": "2.1.0",
"description": "Push All In One!支持 Server酱、酷推、邮件、钉钉机器人、企业微信机器人、企业微信应用、pushplus、iGot等多种推送方式",
"description": "Push All In One!支持 Server酱、酷推、邮件、钉钉机器人、企业微信机器人、企业微信应用、pushplus、iGot 、Qmsg、息知等多种推送方式",
"author": "CaoMeiYouRen",
"license": "MIT",
"main": "dist/index.js",
Expand Down
20 changes: 17 additions & 3 deletions src/utils/helper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import colors from 'colors'
// import colors from 'colors'

let colors: any

if (globalThis.process && typeof globalThis.process.on === 'function') {
import('colors').then((value) => {
colors = value.default
}).catch(console.error)
}

export function warn(text: any): void {
console.warn(colors.yellow(text))
if (colors) {
text = colors.yellow(text)
}
console.warn(text)
}

export function error(text: any): void {
console.error(colors.red(text))
if (colors) {
text = colors.red(text)
}
console.error(text)
}

0 comments on commit 100ab96

Please sign in to comment.