mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
opt
This commit is contained in:
parent
75d3fc27f0
commit
eabe891838
@ -1,4 +1,5 @@
|
|||||||
import { callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
import {
|
import {
|
||||||
CacheFileList,
|
CacheFileList,
|
||||||
CacheFileListItem,
|
CacheFileListItem,
|
||||||
@ -144,9 +145,9 @@ export class NTQQFileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getImageSize(filePath: string) {
|
static async getImageSize(filePath: string) {
|
||||||
return await callNTQQApi<{ width: number; height: number }>({
|
return await invoke<{ width: number; height: number }>({
|
||||||
className: NTQQApiClass.FS_API,
|
className: NTClass.FS_API,
|
||||||
methodName: NTQQApiMethod.IMAGE_SIZE,
|
methodName: NTMethod.IMAGE_SIZE,
|
||||||
args: [filePath],
|
args: [filePath],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -186,8 +187,8 @@ export class NTQQFileApi {
|
|||||||
|
|
||||||
export class NTQQFileCacheApi {
|
export class NTQQFileCacheApi {
|
||||||
static async setCacheSilentScan(isSilent: boolean = true) {
|
static async setCacheSilentScan(isSilent: boolean = true) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.CACHE_SET_SILENCE,
|
methodName: NTMethod.CACHE_SET_SILENCE,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
isSilent,
|
isSilent,
|
||||||
@ -198,21 +199,21 @@ export class NTQQFileCacheApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getCacheSessionPathList() {
|
static getCacheSessionPathList() {
|
||||||
return callNTQQApi<
|
return invoke<
|
||||||
{
|
{
|
||||||
key: string
|
key: string
|
||||||
value: string
|
value: string
|
||||||
}[]
|
}[]
|
||||||
>({
|
>({
|
||||||
className: NTQQApiClass.OS_API,
|
className: NTClass.OS_API,
|
||||||
methodName: NTQQApiMethod.CACHE_PATH_SESSION,
|
methodName: NTMethod.CACHE_PATH_SESSION,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static clearCache(cacheKeys: Array<string> = ['tmp', 'hotUpdate']) {
|
static clearCache(cacheKeys: Array<string> = ['tmp', 'hotUpdate']) {
|
||||||
return callNTQQApi<any>({
|
return invoke<any>({
|
||||||
// TODO: 目前还不知道真正的返回值是什么
|
// TODO: 目前还不知道真正的返回值是什么
|
||||||
methodName: NTQQApiMethod.CACHE_CLEAR,
|
methodName: NTMethod.CACHE_CLEAR,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
keys: cacheKeys,
|
keys: cacheKeys,
|
||||||
@ -223,8 +224,8 @@ export class NTQQFileCacheApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static addCacheScannedPaths(pathMap: object = {}) {
|
static addCacheScannedPaths(pathMap: object = {}) {
|
||||||
return callNTQQApi<GeneralCallResult>({
|
return invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.CACHE_ADD_SCANNED_PATH,
|
methodName: NTMethod.CACHE_ADD_SCANNED_PATH,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
pathMap: { ...pathMap },
|
pathMap: { ...pathMap },
|
||||||
@ -235,35 +236,35 @@ export class NTQQFileCacheApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static scanCache() {
|
static scanCache() {
|
||||||
callNTQQApi<GeneralCallResult>({
|
invoke<GeneralCallResult>({
|
||||||
methodName: ReceiveCmdS.CACHE_SCAN_FINISH,
|
methodName: ReceiveCmdS.CACHE_SCAN_FINISH,
|
||||||
classNameIsRegister: true,
|
classNameIsRegister: true,
|
||||||
}).then()
|
}).then()
|
||||||
return callNTQQApi<CacheScanResult>({
|
return invoke<CacheScanResult>({
|
||||||
methodName: NTQQApiMethod.CACHE_SCAN,
|
methodName: NTMethod.CACHE_SCAN,
|
||||||
args: [null, null],
|
args: [null, null],
|
||||||
timeout: 300 * Time.second,
|
timeout: 300 * Time.second,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static getHotUpdateCachePath() {
|
static getHotUpdateCachePath() {
|
||||||
return callNTQQApi<string>({
|
return invoke<string>({
|
||||||
className: NTQQApiClass.HOTUPDATE_API,
|
className: NTClass.HOTUPDATE_API,
|
||||||
methodName: NTQQApiMethod.CACHE_PATH_HOT_UPDATE,
|
methodName: NTMethod.CACHE_PATH_HOT_UPDATE,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDesktopTmpPath() {
|
static getDesktopTmpPath() {
|
||||||
return callNTQQApi<string>({
|
return invoke<string>({
|
||||||
className: NTQQApiClass.BUSINESS_API,
|
className: NTClass.BUSINESS_API,
|
||||||
methodName: NTQQApiMethod.CACHE_PATH_DESKTOP_TEMP,
|
methodName: NTMethod.CACHE_PATH_DESKTOP_TEMP,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) {
|
static getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) {
|
||||||
return new Promise<ChatCacheList>((res, rej) => {
|
return new Promise<ChatCacheList>((res, rej) => {
|
||||||
callNTQQApi<ChatCacheList>({
|
invoke<ChatCacheList>({
|
||||||
methodName: NTQQApiMethod.CACHE_CHAT_GET,
|
methodName: NTMethod.CACHE_CHAT_GET,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
chatType: type,
|
chatType: type,
|
||||||
@ -282,8 +283,8 @@ export class NTQQFileCacheApi {
|
|||||||
static getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) {
|
static getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) {
|
||||||
const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }
|
const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }
|
||||||
|
|
||||||
return callNTQQApi<CacheFileList>({
|
return invoke<CacheFileList>({
|
||||||
methodName: NTQQApiMethod.CACHE_FILE_GET,
|
methodName: NTMethod.CACHE_FILE_GET,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
fileType: fileType,
|
fileType: fileType,
|
||||||
@ -298,8 +299,8 @@ export class NTQQFileCacheApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
static async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.CACHE_CHAT_CLEAR,
|
methodName: NTMethod.CACHE_CHAT_CLEAR,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
chats,
|
chats,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Friend, FriendV2 } from '../types'
|
import { Friend, FriendV2 } from '../types'
|
||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { callNTQQApi, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
import { BuddyListReqType, NodeIKernelProfileService } from '../services'
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask'
|
import { NTEventDispatch } from '@/common/utils/EventTask'
|
||||||
@ -9,7 +9,7 @@ import { LimitedHashTable } from '@/common/utils/table'
|
|||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
/** 大于或等于 26702 应使用 getBuddyV2 */
|
/** 大于或等于 26702 应使用 getBuddyV2 */
|
||||||
static async getFriends(forced = false) {
|
static async getFriends(forced = false) {
|
||||||
const data = await callNTQQApi<{
|
const data = await invoke<{
|
||||||
data: {
|
data: {
|
||||||
categoryId: number
|
categoryId: number
|
||||||
categroyName: string
|
categroyName: string
|
||||||
@ -17,7 +17,7 @@ export class NTQQFriendApi {
|
|||||||
buddyList: Friend[]
|
buddyList: Friend[]
|
||||||
}[]
|
}[]
|
||||||
}>({
|
}>({
|
||||||
methodName: NTQQApiMethod.FRIENDS,
|
methodName: NTMethod.FRIENDS,
|
||||||
args: [{ force_update: forced }, undefined],
|
args: [{ force_update: forced }, undefined],
|
||||||
cbCmd: ReceiveCmdS.FRIENDS,
|
cbCmd: ReceiveCmdS.FRIENDS,
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
@ -101,7 +101,7 @@ export class NTQQFriendApi {
|
|||||||
if (session) {
|
if (session) {
|
||||||
return session.getBuddyService().isBuddy(uid)
|
return session.getBuddyService().isBuddy(uid)
|
||||||
} else {
|
} else {
|
||||||
return await callNTQQApi<boolean>({
|
return await invoke<boolean>({
|
||||||
methodName: 'nodeIKernelBuddyService/isBuddy',
|
methodName: 'nodeIKernelBuddyService/isBuddy',
|
||||||
args: [
|
args: [
|
||||||
{ uid },
|
{ uid },
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ReceiveCmdS } from '../hook'
|
import { ReceiveCmdS } from '../hook'
|
||||||
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes, GroupNotify } from '../types'
|
import { Group, GroupMember, GroupMemberRole, GroupNotifies, GroupRequestOperateTypes, GroupNotify } from '../types'
|
||||||
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
import { NTQQWindowApi, NTQQWindows } from './window'
|
import { NTQQWindowApi, NTQQWindows } from './window'
|
||||||
import { getSession } from '../wrapper'
|
import { getSession } from '../wrapper'
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask'
|
import { NTEventDispatch } from '@/common/utils/EventTask'
|
||||||
@ -31,8 +32,8 @@ export class NTQQGroupApi {
|
|||||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow')
|
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow')
|
||||||
result = await groupService.getNextMemberList(sceneId, undefined, num)
|
result = await groupService.getNextMemberList(sceneId, undefined, num)
|
||||||
} else {
|
} else {
|
||||||
const sceneId = await callNTQQApi<string>({
|
const sceneId = await invoke<string>({
|
||||||
methodName: NTQQApiMethod.GROUP_MEMBER_SCENE,
|
methodName: NTMethod.GROUP_MEMBER_SCENE,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
groupCode: groupQQ,
|
groupCode: groupQQ,
|
||||||
@ -40,10 +41,10 @@ export class NTQQGroupApi {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
result = await callNTQQApi<
|
result = await invoke<
|
||||||
ReturnType<NodeIKernelGroupService['getNextMemberList']>
|
ReturnType<NodeIKernelGroupService['getNextMemberList']>
|
||||||
>({
|
>({
|
||||||
methodName: NTQQApiMethod.GROUP_MEMBERS,
|
methodName: NTMethod.GROUP_MEMBERS,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
sceneId,
|
sceneId,
|
||||||
@ -62,12 +63,12 @@ export class NTQQGroupApi {
|
|||||||
static async getGroupNotifies() {
|
static async getGroupNotifies() {
|
||||||
// 获取管理员变更
|
// 获取管理员变更
|
||||||
// 加群通知,退出通知,需要管理员权限
|
// 加群通知,退出通知,需要管理员权限
|
||||||
callNTQQApi<GeneralCallResult>({
|
invoke<GeneralCallResult>({
|
||||||
methodName: ReceiveCmdS.GROUP_NOTIFY,
|
methodName: ReceiveCmdS.GROUP_NOTIFY,
|
||||||
classNameIsRegister: true,
|
classNameIsRegister: true,
|
||||||
}).then()
|
}).then()
|
||||||
return await callNTQQApi<GroupNotifies>({
|
return await invoke<GroupNotifies>({
|
||||||
methodName: NTQQApiMethod.GET_GROUP_NOTICE,
|
methodName: NTMethod.GET_GROUP_NOTICE,
|
||||||
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
cbCmd: ReceiveCmdS.GROUP_NOTIFY,
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
args: [{ doubt: false, startSeq: '', number: 14 }, null],
|
args: [{ doubt: false, startSeq: '', number: 14 }, null],
|
||||||
@ -167,7 +168,7 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getGroupAtAllRemainCount(groupCode: string) {
|
static async getGroupAtAllRemainCount(groupCode: string) {
|
||||||
return await callNTQQApi<
|
return await invoke<
|
||||||
GeneralCallResult & {
|
GeneralCallResult & {
|
||||||
atInfo: {
|
atInfo: {
|
||||||
canAtAll: boolean
|
canAtAll: boolean
|
||||||
@ -178,7 +179,7 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>({
|
>({
|
||||||
methodName: NTQQApiMethod.GROUP_AT_ALL_REMAIN_COUNT,
|
methodName: NTMethod.GROUP_AT_ALL_REMAIN_COUNT,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
groupCode,
|
groupCode,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
import { RawMessage, SendMessageElement, Peer, ChatType2 } from '../types'
|
||||||
import { getSelfNick, getSelfUid } from '../../common/data'
|
import { getSelfNick, getSelfUid } from '../../common/data'
|
||||||
import { getBuildVersion } from '../../common/utils'
|
import { getBuildVersion } from '../../common/utils'
|
||||||
@ -28,8 +29,8 @@ export class NTQQMsgApi {
|
|||||||
static async activateChat(peer: Peer) {
|
static async activateChat(peer: Peer) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.ACTIVE_CHAT_PREVIEW,
|
methodName: NTMethod.ACTIVE_CHAT_PREVIEW,
|
||||||
args: [{ peer, cnt: 20 }, null],
|
args: [{ peer, cnt: 20 }, null],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -37,8 +38,8 @@ export class NTQQMsgApi {
|
|||||||
static async activateChatAndGetHistory(peer: Peer) {
|
static async activateChatAndGetHistory(peer: Peer) {
|
||||||
// await this.fetchRecentContact();
|
// await this.fetchRecentContact();
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.ACTIVE_CHAT_HISTORY,
|
methodName: NTMethod.ACTIVE_CHAT_HISTORY,
|
||||||
// 参数似乎不是这样
|
// 参数似乎不是这样
|
||||||
args: [{ peer, cnt: 20 }, null],
|
args: [{ peer, cnt: 20 }, null],
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
//远端rkey获取
|
|
||||||
|
|
||||||
import { log } from '@/common/utils'
|
import { log } from '@/common/utils'
|
||||||
|
|
||||||
interface ServerRkeyData {
|
interface ServerRkeyData {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { callNTQQApi, GeneralCallResult, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTMethod } from '../ntcall'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListenerArg } from '../types'
|
||||||
import { friends, groupMembers, getSelfUin } from '@/common/data'
|
import { friends, groupMembers, getSelfUin } from '@/common/data'
|
||||||
import { CacheClassFuncAsync, getBuildVersion } from '@/common/utils'
|
import { CacheClassFuncAsync, getBuildVersion } from '@/common/utils'
|
||||||
@ -12,8 +13,8 @@ import { Time } from 'cosmokit'
|
|||||||
|
|
||||||
export class NTQQUserApi {
|
export class NTQQUserApi {
|
||||||
static async setQQAvatar(filePath: string) {
|
static async setQQAvatar(filePath: string) {
|
||||||
return await callNTQQApi<GeneralCallResult>({
|
return await invoke<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.SET_QQ_AVATAR,
|
methodName: NTMethod.SET_QQ_AVATAR,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
path: filePath,
|
path: filePath,
|
||||||
@ -44,7 +45,7 @@ export class NTQQUserApi {
|
|||||||
)
|
)
|
||||||
info = profile
|
info = profile
|
||||||
} else {
|
} else {
|
||||||
const result = await callNTQQApi<{ info: UserDetailInfoListenerArg }>({
|
const result = await invoke<{ info: UserDetailInfoListenerArg }>({
|
||||||
methodName: 'nodeIKernelProfileService/fetchUserDetailInfo',
|
methodName: 'nodeIKernelProfileService/fetchUserDetailInfo',
|
||||||
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
cbCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { callNTQQApi, GeneralCallResult, NTQQApiClass, NTQQApiMethod } from '../ntcall'
|
import { invoke, NTClass, NTMethod } from '../ntcall'
|
||||||
|
import { GeneralCallResult } from '../services'
|
||||||
import { ReceiveCmd } from '../hook'
|
import { ReceiveCmd } from '../hook'
|
||||||
import { BrowserWindow } from 'electron'
|
import { BrowserWindow } from 'electron'
|
||||||
|
|
||||||
@ -27,12 +28,12 @@ export class NTQQWindowApi {
|
|||||||
static async openWindow<R = GeneralCallResult>(
|
static async openWindow<R = GeneralCallResult>(
|
||||||
ntQQWindow: NTQQWindow,
|
ntQQWindow: NTQQWindow,
|
||||||
args: any[],
|
args: any[],
|
||||||
cbCmd: ReceiveCmd | null = null,
|
cbCmd: ReceiveCmd | undefined,
|
||||||
autoCloseSeconds: number = 2,
|
autoCloseSeconds: number = 2,
|
||||||
) {
|
) {
|
||||||
const result = await callNTQQApi<R>({
|
const result = await invoke<R>({
|
||||||
className: NTQQApiClass.WINDOW_API,
|
className: NTClass.WINDOW_API,
|
||||||
methodName: NTQQApiMethod.OPEN_EXTRA_WINDOW,
|
methodName: NTMethod.OPEN_EXTRA_WINDOW,
|
||||||
cbCmd,
|
cbCmd,
|
||||||
afterFirstCmd: false,
|
afterFirstCmd: false,
|
||||||
args: [ntQQWindow.windowName, ...args],
|
args: [ntQQWindow.windowName, ...args],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { BrowserWindow } from 'electron'
|
import type { BrowserWindow } from 'electron'
|
||||||
import { NTQQApiClass, NTQQApiMethod } from './ntcall'
|
import { NTClass, NTMethod } from './ntcall'
|
||||||
import { NTQQMsgApi } from './api/msg'
|
import { NTQQMsgApi } from './api/msg'
|
||||||
import {
|
import {
|
||||||
CategoryFriend,
|
CategoryFriend,
|
||||||
@ -53,16 +53,16 @@ export let ReceiveCmdS = {
|
|||||||
|
|
||||||
export type ReceiveCmd = (typeof ReceiveCmdS)[keyof typeof ReceiveCmdS]
|
export type ReceiveCmd = (typeof ReceiveCmdS)[keyof typeof ReceiveCmdS]
|
||||||
|
|
||||||
interface NTQQApiReturnData<PayloadType = unknown> extends Array<any> {
|
interface NTQQApiReturnData<Payload = unknown> extends Array<any> {
|
||||||
0: {
|
0: {
|
||||||
type: 'request'
|
type: 'request'
|
||||||
eventName: NTQQApiClass
|
eventName: NTClass
|
||||||
callbackId?: string
|
callbackId?: string
|
||||||
}
|
}
|
||||||
1: {
|
1: {
|
||||||
cmdName: ReceiveCmd
|
cmdName: ReceiveCmd
|
||||||
cmdType: 'event'
|
cmdType: 'event'
|
||||||
payload: PayloadType
|
payload: Payload
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ let receiveHooks: Array<{
|
|||||||
}> = []
|
}> = []
|
||||||
|
|
||||||
let callHooks: Array<{
|
let callHooks: Array<{
|
||||||
method: NTQQApiMethod[]
|
method: NTMethod[]
|
||||||
hookFunc: (callParams: unknown[]) => void | Promise<void>
|
hookFunc: (callParams: unknown[]) => void | Promise<void>
|
||||||
}> = []
|
}> = []
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ export function hookNTQQApiCall(window: BrowserWindow) {
|
|||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
try {
|
try {
|
||||||
const _args: unknown[] = args[3][1]
|
const _args: unknown[] = args[3][1]
|
||||||
const cmdName: NTQQApiMethod = _args[0] as NTQQApiMethod
|
const cmdName: NTMethod = _args[0] as NTMethod
|
||||||
const callParams = _args.slice(1)
|
const callParams = _args.slice(1)
|
||||||
callHooks.forEach((hook) => {
|
callHooks.forEach((hook) => {
|
||||||
if (hook.method.includes(cmdName)) {
|
if (hook.method.includes(cmdName)) {
|
||||||
@ -207,7 +207,7 @@ export function registerReceiveHook<PayloadType>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function registerCallHook(
|
export function registerCallHook(
|
||||||
method: NTQQApiMethod | NTQQApiMethod[],
|
method: NTMethod | NTMethod[],
|
||||||
hookFunc: (callParams: unknown[]) => void | Promise<void>,
|
hookFunc: (callParams: unknown[]) => void | Promise<void>,
|
||||||
): void {
|
): void {
|
||||||
if (!Array.isArray(method)) {
|
if (!Array.isArray(method)) {
|
||||||
@ -499,7 +499,7 @@ export async function startHook() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
registerCallHook(NTQQApiMethod.DELETE_ACTIVE_CHAT, async (payload) => {
|
registerCallHook(NTMethod.DELETE_ACTIVE_CHAT, async (payload) => {
|
||||||
const peerUid = payload[0] as string
|
const peerUid = payload[0] as string
|
||||||
log('激活的聊天窗口被删除,准备重新激活', peerUid)
|
log('激活的聊天窗口被删除,准备重新激活', peerUid)
|
||||||
let chatType = ChatType.friend
|
let chatType = ChatType.friend
|
||||||
|
@ -2,9 +2,9 @@ import { ipcMain } from 'electron'
|
|||||||
import { hookApiCallbacks, ReceiveCmd, registerReceiveHook, removeReceiveHook } from './hook'
|
import { hookApiCallbacks, ReceiveCmd, registerReceiveHook, removeReceiveHook } from './hook'
|
||||||
import { log } from '../common/utils/log'
|
import { log } from '../common/utils/log'
|
||||||
import { randomUUID } from 'node:crypto'
|
import { randomUUID } from 'node:crypto'
|
||||||
import { GeneralCallResult } from './services/common'
|
import { GeneralCallResult } from './services'
|
||||||
|
|
||||||
export enum NTQQApiClass {
|
export enum NTClass {
|
||||||
NT_API = 'ns-ntApi',
|
NT_API = 'ns-ntApi',
|
||||||
FS_API = 'ns-FsApi',
|
FS_API = 'ns-FsApi',
|
||||||
OS_API = 'ns-OsApi',
|
OS_API = 'ns-OsApi',
|
||||||
@ -18,8 +18,7 @@ export enum NTQQApiClass {
|
|||||||
NODE_STORE_API = 'ns-NodeStoreApi'
|
NODE_STORE_API = 'ns-NodeStoreApi'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NTQQApiMethod {
|
export enum NTMethod {
|
||||||
TEST = 'NodeIKernelTipOffService/getPskey',
|
|
||||||
RECENT_CONTACT = 'nodeIKernelRecentContactService/fetchAndSubscribeABatchOfRecentContact',
|
RECENT_CONTACT = 'nodeIKernelRecentContactService/fetchAndSubscribeABatchOfRecentContact',
|
||||||
ACTIVE_CHAT_PREVIEW = 'nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat', // 激活聊天窗口,有时候必须这样才能收到消息, 并返回最新预览消息
|
ACTIVE_CHAT_PREVIEW = 'nodeIKernelMsgService/getAioFirstViewLatestMsgsAndAddActiveChat', // 激活聊天窗口,有时候必须这样才能收到消息, 并返回最新预览消息
|
||||||
ACTIVE_CHAT_HISTORY = 'nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat', // 激活聊天窗口,有时候必须这样才能收到消息, 并返回历史消息
|
ACTIVE_CHAT_HISTORY = 'nodeIKernelMsgService/getMsgsIncludeSelfAndAddActiveChat', // 激活聊天窗口,有时候必须这样才能收到消息, 并返回历史消息
|
||||||
@ -94,27 +93,27 @@ export enum NTQQApiMethod {
|
|||||||
FETCH_UNITED_COMMEND_CONFIG = 'nodeIKernelUnitedConfigService/fetchUnitedCommendConfig', // 发包需要调用的
|
FETCH_UNITED_COMMEND_CONFIG = 'nodeIKernelUnitedConfigService/fetchUnitedCommendConfig', // 发包需要调用的
|
||||||
}
|
}
|
||||||
|
|
||||||
enum NTQQApiChannel {
|
export enum NTChannel {
|
||||||
IPC_UP_2 = 'IPC_UP_2',
|
IPC_UP_2 = 'IPC_UP_2',
|
||||||
IPC_UP_3 = 'IPC_UP_3',
|
IPC_UP_3 = 'IPC_UP_3',
|
||||||
IPC_UP_1 = 'IPC_UP_1',
|
IPC_UP_1 = 'IPC_UP_1',
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NTQQApiParams {
|
interface InvokeParams {
|
||||||
methodName: NTQQApiMethod | string
|
methodName: string
|
||||||
className?: NTQQApiClass
|
className?: NTClass
|
||||||
channel?: NTQQApiChannel
|
channel?: NTChannel
|
||||||
classNameIsRegister?: boolean
|
classNameIsRegister?: boolean
|
||||||
args?: unknown[]
|
args?: unknown[]
|
||||||
cbCmd?: ReceiveCmd | ReceiveCmd[] | null
|
cbCmd?: string | string[]
|
||||||
cmdCB?: (payload: any) => boolean
|
cmdCB?: (payload: any) => boolean
|
||||||
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
afterFirstCmd?: boolean // 是否在methodName调用完之后再去hook cbCmd
|
||||||
timeout?: number
|
timeout?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
export function invoke<ReturnType>(params: InvokeParams) {
|
||||||
const className = params.className ?? NTQQApiClass.NT_API
|
const className = params.className ?? NTClass.NT_API
|
||||||
const channel = params.channel ?? NTQQApiChannel.IPC_UP_2
|
const channel = params.channel ?? NTChannel.IPC_UP_2
|
||||||
const timeout = params.timeout ?? 5000
|
const timeout = params.timeout ?? 5000
|
||||||
const afterFirstCmd = params.afterFirstCmd ?? true
|
const afterFirstCmd = params.afterFirstCmd ?? true
|
||||||
const uuid = randomUUID()
|
const uuid = randomUUID()
|
||||||
@ -185,5 +184,3 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export { GeneralCallResult }
|
|
@ -1,3 +1,4 @@
|
|||||||
|
export * from './common'
|
||||||
export * from './NodeIKernelBuddyService'
|
export * from './NodeIKernelBuddyService'
|
||||||
export * from './NodeIKernelProfileService'
|
export * from './NodeIKernelProfileService'
|
||||||
export * from './NodeIKernelGroupService'
|
export * from './NodeIKernelGroupService'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user