Compare commits

...

4 Commits

Author SHA1 Message Date
6019819123 chore(release): publish
- @egg/net-tool@1.6.4
2024-09-24 10:27:41 +00:00
b52682b96d chore(net-tool): 返回200成功时,无data不展示
All checks were successful
/ release (push) Successful in 29s
2024-09-24 10:27:17 +00:00
94005549bf chore(release): publish
- @egg/lark-msg-tool@1.2.1
2024-09-24 03:30:29 +00:00
ee271ed4cc chore(lark-msg): 删除无用类型注释
All checks were successful
/ release (push) Successful in 23s
2024-09-24 03:30:05 +00:00
8 changed files with 55 additions and 33 deletions

4
package-lock.json generated
View File

@ -12258,7 +12258,7 @@
},
"packages/lark-msg-tool": {
"name": "@egg/lark-msg-tool",
"version": "1.2.0",
"version": "1.2.1",
"license": "ISC"
},
"packages/logger": {
@ -12272,7 +12272,7 @@
},
"packages/net-tool": {
"name": "@egg/net-tool",
"version": "1.6.3",
"version": "1.6.4",
"license": "ISC",
"dependencies": {
"@egg/logger": "^1.4.2",

View File

@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 1.2.1 (2024-09-24)
### Bug Fixes
- **logger:** 修复正式环境下也输出彩色日志的问题 ([3290875](http://yingbo.im:3000/zhaoyingbo/egg_tools/commits/329087504de42b31adb35998b911fa509e1d8fd9))
# [1.2.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/lark-msg-tool@1.1.0...@egg/lark-msg-tool@1.2.0) (2024-08-21)
### Features

View File

@ -1,6 +1,6 @@
{
"name": "@egg/lark-msg-tool",
"version": "1.2.0",
"version": "1.2.1",
"description": "Lark Msg Tools for Egg projects",
"type": "module",
"main": "src/index.ts",

View File

@ -2,64 +2,64 @@ import { LarkAction, LarkEvent } from "./types"
/**
*
* @param {LarkEvent.Data} body -
* @returns {boolean}
* @param body
* @returns
*/
export const getIsEventMsg = (body: LarkEvent.Data): boolean => {
export const getIsEventMsg = (body: LarkEvent.Data) => {
return body?.header?.event_type === "im.message.receive_v1"
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {string | undefined}
* @param body
* @returns
*/
export const getMsgType = (body: LarkEvent.Data): string | undefined => {
export const getMsgType = (body: LarkEvent.Data) => {
return body?.event?.message?.message_type
}
/**
* Id
* @param {LarkEvent.Data} body -
* @returns {string | undefined} Id
* @param body
* @returns Id
*/
export const getChatId = (body: LarkEvent.Data): string | undefined => {
export const getChatId = (body: LarkEvent.Data) => {
return body?.event?.message?.chat_id
}
/**
* Id
* @param {LarkEvent.Data} body -
* @returns {string | undefined} Id
* @param body
* @returns Id
*/
export const getUserId = (body: LarkEvent.Data): string | undefined => {
export const getUserId = (body: LarkEvent.Data) => {
return body?.event?.sender?.sender_id?.user_id
}
/**
* Action消息
* @param {LarkAction.Data} body - Action消息体
* @returns {boolean} Action消息
* @param body Action消息体
* @returns Action消息
*/
export const getIsActionMsg = (body: LarkAction.Data): boolean => {
export const getIsActionMsg = (body: LarkAction.Data) => {
return !!body?.action
}
/**
* Action类型
* @param {LarkAction.Data} body - Action消息体
* @returns {string | undefined} Action类型
* @param body Action消息体
* @returns Action类型
*/
export const getActionType = (body: LarkAction.Data): string | undefined => {
export const getActionType = (body: LarkAction.Data) => {
return body?.action?.tag
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {string}
* @param body
* @returns
*/
export const getMsgText = (body: LarkEvent.Data): string => {
export const getMsgText = (body: LarkEvent.Data) => {
try {
const { text }: { text: string } = JSON.parse(body?.event?.message?.content)
// 去掉@_user_1相关的内容例如 '@_user_1 测试' -> '测试'
@ -72,19 +72,19 @@ export const getMsgText = (body: LarkEvent.Data): string => {
/**
*
* @param {LarkEvent.Data} body -
* @returns {string | undefined}
* @param body
* @returns
*/
export const getChatType = (body: LarkEvent.Data): string | undefined => {
export const getChatType = (body: LarkEvent.Data) => {
return body?.event?.message?.chat_type
}
/**
*
* @param {LarkEvent.Data} body -
* @returns {Array | undefined}
* @param body
* @returns
*/
export const getMentions = (body: LarkEvent.Data): Array<any> | undefined => {
export const getMentions = (body: LarkEvent.Data) => {
return body?.event?.message?.mentions
}

View File

@ -95,7 +95,17 @@ export namespace LarkEvent {
*
* @example textpostimagefileaudiomediastickerinteractiveshare_chatshare_user
*/
message_type: string
message_type:
| "text"
| "post"
| "image"
| "file"
| "audio"
| "media"
| "sticker"
| "interactive"
| "share_chat"
| "share_user"
}
/**

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.6.4](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.6.3...@egg/net-tool@1.6.4) (2024-09-24)
**Note:** Version bump only for package @egg/net-tool
## [1.6.3](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.6.2...@egg/net-tool@1.6.3) (2024-09-23)
**Note:** Version bump only for package @egg/net-tool

View File

@ -1,6 +1,6 @@
{
"name": "@egg/net-tool",
"version": "1.6.3",
"version": "1.6.4",
"description": "Net Tools for Egg projects",
"type": "module",
"main": "src/index.ts",

View File

@ -468,7 +468,9 @@ class NetTool extends NetToolBase {
* @returns 200 OK的响应对象
*/
ok(data?: any) {
this.logger.info(`return a ok response: ${JSON.stringify(data)}`)
this.logger.info(
`return a ok response${data ? ": " + JSON.stringify(data) : ""}`
)
return Response.json({
code: 0,
message: "success",