Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
linyuchen 2024-11-16 23:01:39 +08:00
commit 2c1d12e04b
10 changed files with 49 additions and 44 deletions

View File

@ -107,8 +107,7 @@ export class NTQQFriendApi extends Service {
return ret.arkMsg return ret.arkMsg
} }
async setBuddyRemark(uid: string, remark?: string) { async setBuddyRemark(uid: string, remark = '') {
remark = remark ?? ''
return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{ return await invoke('nodeIKernelBuddyService/setBuddyRemark', [{
remarkParams: { uid, remark } remarkParams: { uid, remark }
}]) }])
@ -125,6 +124,6 @@ export class NTQQFriendApi extends Service {
} }
async setBuddyCategory(uid: string, categoryId: number) { async setBuddyCategory(uid: string, categoryId: number) {
return await invoke('nodeIKernelBuddyService/setBuddyCategory', [{uid, categoryId}]) return await invoke('nodeIKernelBuddyService/setBuddyCategory', [{ uid, categoryId }])
} }
} }

View File

@ -9,7 +9,8 @@ import {
PublishGroupBulletinReq, PublishGroupBulletinReq,
GroupAllInfo, GroupAllInfo,
GroupFileInfo, GroupFileInfo,
GroupBulletinListResult GroupBulletinListResult,
GroupMsgMask
} from '../types' } from '../types'
import { invoke, NTClass, NTMethod } from '../ntcall' import { invoke, NTClass, NTMethod } from '../ntcall'
import { GeneralCallResult } from '../services' import { GeneralCallResult } from '../services'
@ -22,12 +23,6 @@ declare module 'cordis' {
} }
} }
export enum GroupMsgMask {
ALLOW_NOTIFY = 1, // 允许提醒
ALLOW_NOT_NOTIFY = 4, // 接受消息不提醒
BOX_NOT_NOTIFY = 2, // 收进群助手不提醒
NOT_ALLOW = 3, // 屏蔽
}
export class NTQQGroupApi extends Service { export class NTQQGroupApi extends Service {
static inject = ['ntWindowApi'] static inject = ['ntWindowApi']
@ -348,12 +343,11 @@ export class NTQQGroupApi extends Service {
) )
} }
async setGroupMsgMask(groupCode: string, msgMask: GroupMsgMask){ async setGroupMsgMask(groupCode: string, msgMask: GroupMsgMask) {
return await invoke('nodeIKernelGroupService/setGroupMsgMask', [{ groupCode, msgMask }]) return await invoke('nodeIKernelGroupService/setGroupMsgMask', [{ groupCode, msgMask }])
} }
async setGroupRemark(groupCode: string, groupRemark?: string) { async setGroupRemark(groupCode: string, groupRemark = '') {
groupRemark = groupRemark ?? ''
return await invoke('nodeIKernelGroupService/modifyGroupRemark', [{ groupCode, groupRemark }]) return await invoke('nodeIKernelGroupService/modifyGroupRemark', [{ groupCode, groupRemark }])
} }
} }

View File

@ -8,13 +8,11 @@ declare module 'cordis' {
} }
export class NTQQSystemApi extends Service { export class NTQQSystemApi extends Service {
static inject = ['ntUserApi']
constructor(protected ctx: Context) { constructor(protected ctx: Context) {
super(ctx, 'ntSystemApi', true) super(ctx, 'ntSystemApi', true)
} }
async restart(){ async restart() {
// todo: 调用此接口后会将 NTQQ 设置里面的自动登录和无需手机确认打开,重启后将状态恢复到之前的状态 // todo: 调用此接口后会将 NTQQ 设置里面的自动登录和无需手机确认打开,重启后将状态恢复到之前的状态
// 设置自动登录 // 设置自动登录
@ -27,13 +25,14 @@ export class NTQQSystemApi extends Service {
// 等待登录界面,模拟点击登录按钮?还是直接调用登录方法? // 等待登录界面,模拟点击登录按钮?还是直接调用登录方法?
} }
// 是否自动登录 async getSettingAutoLogin() {
async getSettingAutoLogin(): Promise<boolean>{ // 查询是否自动登录
return invoke('nodeIKernelNodeMiscService/queryAutoRun', []) return invoke('nodeIKernelNodeMiscService/queryAutoRun', [])
} }
async setSettingAutoLogin(state: boolean){
await invoke('nodeIKernelSettingService/setNeedConfirmSwitch', [{state: 1}]) // 1不需要手机确认2需要手机确认
await invoke('nodeIKernelSettingService/setAutoLoginSwitch', [{state}]) async setSettingAutoLogin(state: boolean) {
await invoke('nodeIKernelSettingService/setNeedConfirmSwitch', [{ state: 1 }]) // 1不需要手机确认2需要手机确认
await invoke('nodeIKernelSettingService/setAutoLoginSwitch', [{ state }])
} }
} }

View File

@ -28,7 +28,7 @@ export enum ReceiveCmdS {
MEDIA_UPLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaUploadComplete', MEDIA_UPLOAD_COMPLETE = 'nodeIKernelMsgListener/onRichMediaUploadComplete',
} }
const logHook = true const logHook = false
const receiveHooks: Map<string, { const receiveHooks: Map<string, {
method: ReceiveCmdS[] method: ReceiveCmdS[]

View File

@ -13,7 +13,7 @@ export interface NodeIKernelBuddyService {
}[] }[]
}> }>
setBuddyRemark(arg: unknown): void setBuddyRemark(arg: unknown): Promise<GeneralCallResult>
isBuddy(uid: string): boolean isBuddy(uid: string): boolean

View File

@ -12,4 +12,6 @@ export interface NodeIKernelNodeMiscService {
score: '' score: ''
}[] }[]
}> }>
queryAutoRun(): Promise<boolean>
} }

View File

@ -1,10 +1,3 @@
export enum GroupListUpdateType {
REFRESHALL,
GETALL,
MODIFIED,
REMOVE
}
export interface Group { export interface Group {
groupCode: string groupCode: string
maxMember: number maxMember: number
@ -188,3 +181,10 @@ export interface GroupBulletinListResult {
nextIndex: number nextIndex: number
jointime: string jointime: string
} }
export enum GroupMsgMask {
AllowNotify = 1, // 允许提醒
AllowNotNotify = 4, // 接受消息不提醒
BoxNotNotify = 2, // 收进群助手不提醒
NotAllow = 3, // 屏蔽
}

View File

@ -1,15 +1,19 @@
import { BaseAction } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
interface Payload { interface Payload {
user_id: string, user_id: number | string
category_id: number category_id: number | string
} }
export class SetFriendCategory extends BaseAction<Payload, null> { export class SetFriendCategory extends BaseAction<Payload, unknown> {
actionName = ActionName.SetFriendCategory actionName = ActionName.SetFriendCategory
payloadSchema = Schema.object({
user_id: Schema.union([Number, String]).required(),
category_id: Schema.union([Number, String]).required()
})
protected async _handle(payload: Payload): Promise<null> { protected async _handle(payload: Payload) {
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString()) const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
if (!uid) throw new Error('无法获取好友信息') if (!uid) throw new Error('无法获取好友信息')
return this.ctx.ntFriendApi.setBuddyCategory(uid, +payload.category_id) return this.ctx.ntFriendApi.setBuddyCategory(uid, +payload.category_id)

View File

@ -1,15 +1,19 @@
import { BaseAction } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
interface Payload { interface Payload {
user_id: string, user_id: number | string
remark?: string remark?: string
} }
export class SetFriendRemark extends BaseAction<Payload, null> { export class SetFriendRemark extends BaseAction<Payload, unknown> {
actionName = ActionName.SetFriendRemark actionName = ActionName.SetFriendRemark
payloadSchema = Schema.object({
user_id: Schema.union([Number, String]).required(),
remark: Schema.string()
})
protected async _handle(payload: Payload): Promise<null> { protected async _handle(payload: Payload) {
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString()) const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
if (!uid) throw new Error('无法获取好友信息') if (!uid) throw new Error('无法获取好友信息')
return this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark || '') return this.ctx.ntFriendApi.setBuddyRemark(uid, payload.remark || '')

View File

@ -1,16 +1,19 @@
import { BaseAction } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
import { ActionName } from '../types' import { ActionName } from '../types'
import { GroupMsgMask } from '@/ntqqapi/api'
interface Payload { interface Payload {
group_id: string, group_id: number | string
mask: GroupMsgMask mask: number | string // 1, 2, 3, 4
} }
export class SetGroupMsgMask extends BaseAction<Payload, unknown> { export class SetGroupMsgMask extends BaseAction<Payload, unknown> {
actionName = ActionName.SetGroupMsgMask actionName = ActionName.SetGroupMsgMask
payloadSchema = Schema.object({
group_id: Schema.union([Number, String]).required(),
mask: Schema.union([Number, String]).required()
})
protected async _handle(payload: Payload): Promise<unknown>{ protected async _handle(payload: Payload) {
return this.ctx.ntGroupApi.setGroupMsgMask(payload.group_id.toString(), +payload.mask) return this.ctx.ntGroupApi.setGroupMsgMask(payload.group_id.toString(), +payload.mask)
} }
} }