fix: 规范化类型

This commit is contained in:
手瓜一十雪
2024-11-21 10:43:05 +08:00
parent 38a098c77d
commit 583ec10c7c
5 changed files with 101 additions and 33 deletions

View File

@@ -125,7 +125,7 @@ export class NTQQFileApi {
fileName: fileName, fileName: fileName,
sourcePath: path, sourcePath: path,
original: true, original: true,
picType: isGIF(picPath) ? PicType.gif : PicType.jpg, picType: isGIF(picPath) ? PicType.GIF : PicType.JGP,
picSubType: subType, picSubType: subType,
fileUuid: '', fileUuid: '',
fileSubId: '', fileSubId: '',

View File

@@ -0,0 +1,2 @@
export const IMAGE_HTTP_HOST = 'https://gchat.qpic.cn';
export const IMAGE_HTTP_HOST_NT = 'https://multimedia.nt.qq.com.cn';

View File

@@ -1,4 +1,4 @@
import { ElementType, FaceType, MessageElement, NTGrayTipElementSubTypeV2, PicSubType, PicType, TipAioOpGrayTipElement, TipGroupElement, viedo_type } from "./msg"; import { ElementType, FaceType, MessageElement, NTGrayTipElementSubTypeV2, PicSubType, PicType, TipAioOpGrayTipElement, TipGroupElement, NTVideoType } from "./msg";
type ElementFullBase = Omit<MessageElement, 'elementType' | 'elementId' | 'extBufForUI'>; type ElementFullBase = Omit<MessageElement, 'elementType' | 'elementId' | 'extBufForUI'>;
@@ -84,7 +84,7 @@ export interface VideoElement {
thumbMd5?: string; thumbMd5?: string;
fileTime?: number; // second fileTime?: number; // second
thumbSize?: number; // byte thumbSize?: number; // byte
fileFormat?: viedo_type; // 2表示mp4 参考下面条目 fileFormat?: NTVideoType; // 2表示mp4 参考下面条目
fileSize?: string; // byte fileSize?: string; // byte
thumbWidth?: number; thumbWidth?: number;
thumbHeight?: number; thumbHeight?: number;

View File

@@ -6,4 +6,5 @@ export * from './cache';
export * from './system'; export * from './system';
export * from './webapi'; export * from './webapi';
export * from './sign'; export * from './sign';
export * from './element'; export * from './element';
export * from './constant';

View File

@@ -1,14 +1,18 @@
import { GroupMemberRole } from '@/core'; import { GroupMemberRole } from '@/core';
import { ActionBarElement, ArkElement, AvRecordElement, CalendarElement, FaceBubbleElement, FaceElement, FileElement, GiphyElement, GrayTipElement, MarketFaceElement, PicElement, PttElement, RecommendedMsgElement, ReplyElement, ShareLocationElement, StructLongMsgElement, TaskTopMsgElement, TextElement, TofuRecordElement, VideoElement, YoloGameResultElement } from './element'; import { ActionBarElement, ArkElement, AvRecordElement, CalendarElement, FaceBubbleElement, FaceElement, FileElement, GiphyElement, GrayTipElement, MarketFaceElement, PicElement, PttElement, RecommendedMsgElement, ReplyElement, ShareLocationElement, StructLongMsgElement, TaskTopMsgElement, TextElement, TofuRecordElement, VideoElement, YoloGameResultElement } from './element';
// 表示对等方的信息 /**
* 表示对等方的信息
*/
export interface Peer { export interface Peer {
chatType: ChatType; // 聊天类型 chatType: ChatType; // 聊天类型
peerUid: string; // 对等方的唯一标识符 peerUid: string; // 对等方的唯一标识符
guildId?: string; // 可选的频道ID guildId?: string; // 可选的频道ID
} }
// 表示被踢下线的信息 /**
* 表示被踢下线的信息
*/
export interface KickedOffLineInfo { export interface KickedOffLineInfo {
appId: number; // 应用ID appId: number; // 应用ID
instanceId: number; // 实例ID instanceId: number; // 实例ID
@@ -19,6 +23,9 @@ export interface KickedOffLineInfo {
securityKickedType: number; // 安全踢出类型 securityKickedType: number; // 安全踢出类型
} }
/**
* 获取文件列表的参数
*/
export interface GetFileListParam { export interface GetFileListParam {
sortType: number; sortType: number;
fileCount: number; fileCount: number;
@@ -28,6 +35,9 @@ export interface GetFileListParam {
folderId?: string; folderId?: string;
} }
/**
* 消息元素类型枚举
*/
export enum ElementType { export enum ElementType {
UNKNOWN = 0, UNKNOWN = 0,
TEXT = 1, TEXT = 1,
@@ -63,6 +73,9 @@ export enum ElementType {
ACTIONBAR = 44 ACTIONBAR = 44
} }
/**
* 消息类型枚举
*/
export enum NTMsgType { export enum NTMsgType {
KMSGTYPEARKSTRUCT = 11, KMSGTYPEARKSTRUCT = 11,
KMSGTYPEFACEBUBBLE = 24, KMSGTYPEFACEBUBBLE = 24,
@@ -87,17 +100,26 @@ export enum NTMsgType {
KMSGTYPEWALLET = 10 KMSGTYPEWALLET = 10
} }
/**
* 图片类型枚举
*/
export enum PicType { export enum PicType {
gif = 2000, GIF = 2000,
jpg = 1000 JGP = 1000
} }
/**
* 图片子类型枚举
*/
export enum PicSubType { export enum PicSubType {
Normal = 0, // 普通图片 Normal = 0, // 普通图片
Face = 1 // 表情包小图 Face = 1 // 表情包小图
//...待补全 其余见NT Android //...待补全 其余见NT Android
} }
/**
* 消息@类型枚举
*/
export enum NTMsgAtType { export enum NTMsgAtType {
ATTYPEALL = 1, ATTYPEALL = 1,
ATTYPECATEGORY = 512, ATTYPECATEGORY = 512,
@@ -112,6 +134,9 @@ export enum NTMsgAtType {
ATTYPEUNKNOWN = 0 ATTYPEUNKNOWN = 0
} }
/**
* 消息元素接口
*/
export interface MessageElement { export interface MessageElement {
elementType: ElementType, elementType: ElementType,
elementId: string, elementId: string,
@@ -146,6 +171,9 @@ export interface MessageElement {
actionBarElement?: ActionBarElement actionBarElement?: ActionBarElement
} }
/**
* 消息来源类型枚举
*/
export enum MsgSourceType { export enum MsgSourceType {
K_DOWN_SOURCETYPE_AIOINNER = 1, K_DOWN_SOURCETYPE_AIOINNER = 1,
K_DOWN_SOURCETYPE_BIGSCREEN = 2, K_DOWN_SOURCETYPE_BIGSCREEN = 2,
@@ -153,7 +181,9 @@ export enum MsgSourceType {
K_DOWN_SOURCETYPE_UNKNOWN = 0 K_DOWN_SOURCETYPE_UNKNOWN = 0
} }
// 来自Android分析 /**
* 聊天类型枚举
*/
export enum ChatType { export enum ChatType {
KCHATTYPEADELIE = 42, KCHATTYPEADELIE = 42,
KCHATTYPEBUDDYNOTIFY = 5, KCHATTYPEBUDDYNOTIFY = 5,
@@ -197,9 +227,9 @@ export enum ChatType {
KCHATTYPEWEIYUN = 40, KCHATTYPEWEIYUN = 40,
} }
export const IMAGE_HTTP_HOST = 'https://gchat.qpic.cn'; /**
export const IMAGE_HTTP_HOST_NT = 'https://multimedia.nt.qq.com.cn'; * 灰色提示元素子类型枚举
*/
export enum NTGrayTipElementSubTypeV2 { export enum NTGrayTipElementSubTypeV2 {
GRAYTIP_ELEMENT_SUBTYPE_AIOOP = 15, GRAYTIP_ELEMENT_SUBTYPE_AIOOP = 15,
GRAYTIP_ELEMENT_SUBTYPE_BLOCK = 14, GRAYTIP_ELEMENT_SUBTYPE_BLOCK = 14,
@@ -221,20 +251,28 @@ export enum NTGrayTipElementSubTypeV2 {
GRAYTIP_ELEMENT_SUBTYPE_XMLMSG = 12, GRAYTIP_ELEMENT_SUBTYPE_XMLMSG = 12,
} }
/**
* 表情类型枚举
*/
export enum FaceType { export enum FaceType {
normal = 1, // 小黄脸 normal = 1, // 小黄脸
normal2 = 2, // 新小黄脸, 从faceIndex 222开始 normal2 = 2, // 新小黄脸
dice = 3, // 骰子 dice = 3, // 骰子
poke = 5 // 拍一拍 poke = 5 // 拍一拍
} }
/**
* 表情索引枚举
*/
export enum FaceIndex { export enum FaceIndex {
dice = 358, dice = 358,
rps = 359 rps = 359
} }
export enum viedo_type { /**
* 视频类型枚举
*/
export enum NTVideoType {
VIDEO_FORMAT_AFS = 7, VIDEO_FORMAT_AFS = 7,
VIDEO_FORMAT_AVI = 1, VIDEO_FORMAT_AVI = 1,
VIDEO_FORMAT_MKV = 4, VIDEO_FORMAT_MKV = 4,
@@ -248,10 +286,16 @@ export enum viedo_type {
VIDEO_FORMAT_WMV = 3, VIDEO_FORMAT_WMV = 3,
} }
/**
* Markdown元素接口
*/
export interface MarkdownElement { export interface MarkdownElement {
content: string; content: string;
} }
/**
* 内联键盘按钮接口
*/
export interface InlineKeyboardElementRowButton { export interface InlineKeyboardElementRowButton {
id: string; id: string;
label: string; label: string;
@@ -271,6 +315,9 @@ export interface InlineKeyboardElementRowButton {
subscribeDataTemplateIds: []; subscribeDataTemplateIds: [];
} }
/**
* 内联键盘元素接口
*/
export interface InlineKeyboardElement { export interface InlineKeyboardElement {
rows: [{ rows: [{
buttons: InlineKeyboardElementRowButton[] buttons: InlineKeyboardElementRowButton[]
@@ -278,31 +325,29 @@ export interface InlineKeyboardElement {
botAppid: string; botAppid: string;
} }
export interface TipAioOpGrayTipElement { // 这是什么提示来着? /**
* Aio操作灰色提示元素接口
*/
export interface TipAioOpGrayTipElement {
operateType: number; operateType: number;
peerUid: string; peerUid: string;
fromGrpCodeOfTmpChat: string; fromGrpCodeOfTmpChat: string;
} }
/**
* 群提示元素类型枚举
*/
export enum TipGroupElementType { export enum TipGroupElementType {
memberIncrease = 1, memberIncrease = 1,
kicked = 3, // 被移出群 kicked = 3, // 被移出群
ban = 8 ban = 8
} }
// public final class MemberAddShowType { /**
// public static final int KOTHERADD = 0; * 群提示元素接口
// public static final int KOTHERADDBYOTHERQRCODE = 2; */
// public static final int KOTHERADDBYYOURQRCODE = 3;
// public static final int KOTHERINVITEOTHER = 5;
// public static final int KOTHERINVITEYOU = 6;
// public static final int KYOUADD = 1;
// public static final int KYOUADDBYOTHERQRCODE = 4;
// public static final int KYOUALREADYMEMBER = 8;
// public static final int KYOUINVITEOTHER = 7;
// }
export interface TipGroupElement { export interface TipGroupElement {
type: TipGroupElementType; // 1表示有人加入群; 自己加入群也会收到这个 type: TipGroupElementType; // 1表示有人加入群; 自己加入群也会收到这个
role: 0; // 暂时不知 role: 0; // 暂时不知
groupName: string; // 暂时获取不到 groupName: string; // 暂时获取不到
memberUid: string; memberUid: string;
@@ -340,12 +385,18 @@ export interface TipGroupElement {
}; };
} }
/**
* 多条转发消息元素接口
*/
export interface MultiForwardMsgElement { export interface MultiForwardMsgElement {
xmlContent: string; // xml格式的消息内容 xmlContent: string; // xml格式的消息内容
resId: string; resId: string;
fileName: string; fileName: string;
} }
/**
* 发送状态类型枚举
*/
export enum SendStatusType { export enum SendStatusType {
KSEND_STATUS_FAILED = 0, KSEND_STATUS_FAILED = 0,
KSEND_STATUS_SENDING = 1, KSEND_STATUS_SENDING = 1,
@@ -353,7 +404,9 @@ export enum SendStatusType {
KSEND_STATUS_SUCCESS_NOSEQ = 3 KSEND_STATUS_SUCCESS_NOSEQ = 3
} }
// 原始消息 /**
* 原始消息接口
*/
export interface RawMessage { export interface RawMessage {
parentMsgPeer: Peer; // 父消息的Peer parentMsgPeer: Peer; // 父消息的Peer
parentMsgIdList: string[];// 父消息 ID 列表 parentMsgIdList: string[];// 父消息 ID 列表
@@ -382,6 +435,10 @@ export interface RawMessage {
sourceType: MsgSourceType;// 消息来源类型 sourceType: MsgSourceType;// 消息来源类型
isOnlineMsg: boolean;// 是否为在线消息 isOnlineMsg: boolean;// 是否为在线消息
} }
/**
* 查询消息参数接口
*/
export interface QueryMsgsParams { export interface QueryMsgsParams {
chatInfo: Peer; chatInfo: Peer;
filterMsgType: []; filterMsgType: [];
@@ -393,12 +450,18 @@ export interface QueryMsgsParams {
isIncludeCurrent: boolean; isIncludeCurrent: boolean;
} }
/**
* 临时聊天信息API接口
*/
export interface TmpChatInfoApi { export interface TmpChatInfoApi {
errMsg: string; errMsg: string;
result: number; result: number;
tmpChatInfo?: TmpChatInfo; tmpChatInfo?: TmpChatInfo;
} }
/**
* 临时聊天信息接口
*/
export interface TmpChatInfo { export interface TmpChatInfo {
chatType: number; chatType: number;
fromNick: string; fromNick: string;
@@ -407,6 +470,10 @@ export interface TmpChatInfo {
sessionType: number; sessionType: number;
sig: string; sig: string;
} }
/**
* 消息请求类型接口
*/
export interface MsgReqType { export interface MsgReqType {
peer: Peer, peer: Peer,
byType: number, byType: number,
@@ -419,6 +486,4 @@ export interface MsgReqType {
includeSelf: boolean, includeSelf: boolean,
includeDeleteMsg: boolean, includeDeleteMsg: boolean,
extraCnt: number extraCnt: number
} }
//getMsgsIncludeSelf Peer必须 byType 1
//getMsgsWithMsgTimeAndClientSeqForC2C Peer必须 byType 3