入口:EntryAbility -> onWindowStageCreate windowStage.loadContent
jsApi:JSNameConstants
App主页面:MainPage
消息主页面:MessageCenterPage
会话列表:SessionListView+IMHeaderView+AppImageKnifeComponent
会话详情:SessionPage
消息列表Item:SessionMessageListView->MessageListItemView
消息组件:
MsgReplyView
MsgRefView
TextMessageView
ImageMessageView
LocationMessageView
FileMessageView
EntityMessageView
GroupShareMessageView
UserCardMessageView
LinkMessageView
UserCardMessageView
NoticeMessageView
ExpressionMessageView
InnerMsgView
GroupSolitaireMessageView
MessageRecordView
AddOneMessageView
RevokeMessageView
ImageAndTxtView
MsgRichTxtView
VideoMessageView
VoiceMessageView
NotSupportMessageView
表情回复:MsgEmojiReplyView
消息长按操作菜单:menuContentBuilder
消息长按菜单点击:menuItemClick
群设置:GroupChatInfoPage
群成员:GroupMemberListPage
群管理:GroupManageNewPage
http接口请求:
接口在ImHttpFunctions中添加如:
getSessionGroup(callBack:imHttpCallBack){
let getHttpPo: ImHttpPO = new ImHttpPO()
getHttpPo.url = ImHttpAPIConstants.getSessionGroup
getHttpPo.method = 'get'
interface params {
'version':string
}
let par: params = {
'version': '1'
}
getHttpPo.params = par
ImHttpManager.getInstance().imSdkHttpGet(getHttpPo, {
onSuccess(data: string) {
let dataObj: ImHttpResponsePO = JSON.parse(data) as ImHttpResponsePO
if(dataObj.data){
callBack.onSuccess(dataObj.data)
}
},
onError(error: string) {
callBack.onError(error)
}
})
}
sdk请求
sdk相关码ImOpcode
通知code:IMSdkNotice sdk操作码:IMSdkOpcode
//只需回调成功、失败
ImSdkFunctions.getInstance().setSessionRemind(sessionVo, optType,{
onSuccess(jsonKey,JsonValue){
}
})
//ImSdkFunctions下
setSessionRemind(sessionVo:SessionListVO,optType:string,callBack: ImOnResponse){
let pStr = JSON.stringify({
'group_id': 'xxx',
'flag': 'xxx'
})
getDataAndSetCallback(IMSdkOpcode.kOPSetGroupAdmin, pStr, callBack)
}
//2.需要回调数据
ImSdkFunctions.getInstance().getGroupInfo(this.groupId, {
onSuccess(jsonKey: string, jsonStr: string) {
let data: GroupListData = JSON.parse(jsonStr);
if (data != null && data.datas != null && data.datas.length > 0) {
let itemData: GroupItemData = data.datas[0];
if (itemData != null && itemData.groupinfo != null) {
//...
}
}
}
})
//ImSdkFunctions下
getGroupInfo(groupId:string,callBack: ImOnResponse): boolean{
let pStr = JSON.stringify({
'group_ids': [groupId],
'api_get_type':"1",
})
return getDataAndSetCallback(IMSdkOpcode.kOPGetGroupInfo, pStr, callBack)
}
请求人员
PersonManager.getPerson(checkUtil.checkStr(messageVO.suid), checkUtil.checkStr(messageVO.scid), person => {
try {
if (person) {
// messageParser.parseAvatarInfo(messageVO, person)
}
resolve(messageVO)
} catch (e) {
reject(e)
}
})
消息开关:MsgInfoSettingUtils
界面路由
//ImPageOpenUtils
openGroupManagePage(session: SessionListVO | undefined) {
router.pushNamedRoute({
name: 'groupManageNewPage',
params: {
session: session ?? new SessionListVO()
}
})
}
@Entry({ routeName: 'groupManageNewPage' })
@Component
export struct GroupManageNewPage {
}
//main_pages下
{
"src": [
//...
"session/pages/GroupManageNewPage"
]
}
//imStaticLibrary/index下
export { GroupManageNewPage } from "./src/main/ets/session/pages/GroupManageNewPage"
多语言:
1、本地code多语言
LanguageUtils.getData(LanguageUtils.LABEL_TOPIC_SETTING, "话题设置");
2、网络code多语言
let moduleLabel: object = ImCacheFunctions.getInstance().moudleLabelPO_ALl.label as object let str = moduleLabel[txt.id18n] ? moduleLabel[txt.id18n] : ''