Skip to content

Commit 5e7f6a6

Browse files
authored
Merge pull request #29 from Angus2333/main
v10.4.0
2 parents 871e78d + 5326ada commit 5e7f6a6

File tree

213 files changed

+37187
-3121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+37187
-3121
lines changed

NEUIKit/App.vue

Lines changed: 121 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const nimCallKit = (uni.$UIKitCallKit =
2626
uni.requireNativePlugin("netease-CallKit"));
2727
// #endif
2828
29+
let startByNotificationId = "";
30+
2931
export default {
3032
onLaunch() {
3133
// #ifdef APP-PLUS
@@ -45,6 +47,7 @@ export default {
4547
) {
4648
return;
4749
}
50+
4851
const imOptions = uni.getStorageSync(STORAGE_KEY);
4952
if (imOptions) {
5053
this.initNim(imOptions);
@@ -59,11 +62,26 @@ export default {
5962
// #ifdef APP-PLUS
6063
uni?.$UIKitNIM?.V2NIMSettingService?.setAppBackground(false);
6164
// #endif
65+
66+
// 点击通知栏推送监听
67+
nimPushPlugin.addOpenNotificationListener((res: any) => {
68+
if (typeof res == "object" && res?.sessionId && res?.sessionType) {
69+
// 当前登录账号id 具体获取根据您的业务逻辑调整
70+
const imOptions = uni.getStorageSync(STORAGE_KEY);
71+
// 会话类型
72+
const type = res?.sessionType;
73+
// 拼装会话ID
74+
startByNotificationId = `${imOptions.account}|${type}|${res?.sessionId}`;
75+
}
76+
});
6277
},
6378
onHide() {
6479
// #ifdef APP-PLUS
6580
uni?.$UIKitNIM?.V2NIMSettingService?.setAppBackground(true);
6681
// #endif
82+
83+
// 重置推送 startByNotificationId
84+
startByNotificationId = "";
6785
},
6886
methods: {
6987
initNim(opts: { account: string; token: string }) {
@@ -105,20 +123,23 @@ export default {
105123
));
106124
107125
/** 初始化 im store */
126+
// @ts-ignore
108127
const store = (uni.$UIKitStore = new RootStore(
109-
// @ts-ignore
110128
nim,
111129
{
112130
// 添加好友是否需要验证
113-
addFriendNeedVerify: false,
131+
addFriendNeedVerify: true,
114132
// 是否需要显示 p2p 消息、p2p会话列表消息已读未读,默认 false
115133
p2pMsgReceiptVisible: true,
116134
// 是否需要显示群组消息已读未读,默认 false
117135
teamMsgReceiptVisible: true,
136+
// 是否显示在线离线
137+
loginStateVisible: true,
118138
// 群组被邀请模式,默认需要验证
119139
teamAgreeMode:
120140
V2NIMConst.V2NIMTeamAgreeMode.V2NIM_TEAM_AGREE_MODE_NO_AUTH,
121141
// 发送消息前回调, 可对消息体进行修改,添加自定义参数
142+
// @ts-ignore
122143
sendMsgBefore: async (options: any) => {
123144
const pushContent = getMsgContentTipByType({
124145
text: options.msg.text,
@@ -129,7 +150,7 @@ export default {
129150
: { forcePushIDsList: "[]", needForcePush: false };
130151
131152
// 如果是 at 消息,需要走离线强推
132-
153+
// @ts-ignore
133154
const { forcePushIDsList, needForcePush } = yxAitMsg
134155
? // @ts-ignore
135156
store.msgStore._formatExtAitToPushInfo(
@@ -138,8 +159,6 @@ export default {
138159
)
139160
: { forcePushIDsList: "[]", needForcePush: false };
140161
141-
console.log("forcePushIDsList: ", forcePushIDsList);
142-
143162
const { conversationId } = options;
144163
const conversationType =
145164
nim.V2NIMConversationIdUtil.parseConversationType(conversationId);
@@ -148,49 +167,82 @@ export default {
148167
conversationId
149168
);
150169
170+
// 设置离线强推,厂商相关推送在此处配置
171+
// 具体参考文档 https://doc.yunxin.163.com/messaging2/guide/zc4MTg5MDY?platform=client#%E7%AC%AC%E4%B8%80%E6%AD%A5%E4%B8%8A%E4%BC%A0%E6%8E%A8%E9%80%81%E8%AF%81%E4%B9%A6
151172
const pushPayload = JSON.stringify({
152-
// oppo
153-
oppoField: {
154-
click_action_type: 4, // 参考 oppo 官网
155-
click_action_activity: "", // 各端不一样 TODO
156-
action_parameters: {
157-
sessionId: targetId,
158-
sessionType: conversationType,
159-
}, // 自定义
160-
},
161-
162-
// vivo
163-
vivoField: {
164-
pushMode: 0, //推送模式 0:正式推送;1:测试推送,不填默认为0
165-
},
166-
167-
// huawei
173+
pushTitle: "", // 必填,推送消息标题
174+
notify_effect: "2", //可选项,预定义通知栏消息的点击行为。1:通知栏点击后打开app的Launcher Activity,2:通知栏点击后打开app的任一Activity(开发者还需要传入intent_uri),3:通知栏点击后打开网页(开发者还需要传入web_uri)
175+
intent_uri:
176+
"intent:#Intent;action=com.netease.nimlib.uniapp.push.NotificationClickActivity;component=com.netease.nim.demo/com.netease.nimlib.uniapp.push.NotificationClickActivity;launchFlags=0x04000000;i.sessionType=0;S.sessionId=cs1;end", //可选项,打开当前app的任一组件。
168177
hwField: {
169178
click_action: {
170-
type: 1,
171-
action: "", // 各端不一样 TODO
179+
//必填,消息点击行为
180+
type: 1, //必填,消息点击行为类型,取值如下:1:打开应用自定义页面 2:点击后打开特定URL 3:点击后打开应用
181+
// 自定义页面中intent的实现,请参见指定intent参数​。当type为1时,字段intent和action至少二选一。scheme方式和指定activity方式都可以
182+
intent:
183+
"intent:#Intent;action=com.netease.nimlib.uniapp.push.NotificationClickActivity;component=com.netease.nim.demo/com.netease.nimlib.uniapp.push.NotificationClickActivity;launchFlags=0x04000000;i.sessionType=0;S.sessionId=cs1;end",
172184
},
173185
androidConfig: {
174-
category: "IM",
175-
data: JSON.stringify({
176-
sessionId: targetId,
177-
sessionType: conversationType,
178-
}),
186+
category: "IM", //可选项,标识消息类型,用于标识高优先级透传场景,详见官方文档 AndroidConfig.category
187+
},
188+
},
189+
honorField: {
190+
notification: {
191+
// AndroidNotification
192+
clickAction: {
193+
//必填,消息点击行为
194+
type: 1, //必填,消息点击行为类型,取值如下:1:打开应用自定义页面 2:点击后打开特定URL 3:点击后打开应用
195+
//自定义页面中intent的实现,请参见指定intent参数。当type为1时,字段intent和action至少二选一。
196+
intent: "",
197+
},
198+
importance: "NORMAL", //可选项,Android通知消息分类,决定用户设备消息通知行为,取值如下:LOW:资讯营销类消息 NORMAL:服务与通讯类消息
199+
},
200+
},
201+
vivoField: {
202+
skipType: "4", //必填,点击跳转类型 1:打开APP首页 2:打开链接 3:自定义 4:打开app内指定页面,默认为1
203+
skipContent: "",
204+
classification: "1", //可选项,消息类型 0:运营类消息,1:系统类消息。默认为0
205+
category: "IM", // 可选项,二级分类
206+
},
207+
oppoField: {
208+
channel_id: "", //可选项,指定下发的通道ID
209+
category: "IM", //可选项,通道类别名
210+
notify_level: 2, //通知栏消息提醒等级,1-通知栏;2-通知栏+锁屏;16-通知栏+锁屏+横幅+震动+铃声
211+
click_action_type: "1", //点击通知栏后触发的动作类型。0(默认0.启动应用;1.跳转指定应用内页(action标签名);2.跳转网页;4.跳转指定应用内页(全路径类名);5.跳转Intent scheme URL: "",
212+
click_action_activity: "",
213+
action_parameters: "",
214+
},
215+
fcmFieldV1: {
216+
message: {
217+
android: {
218+
priority: "",
219+
data: {
220+
sessionType: "0",
221+
sessionId: "cs1",
222+
},
223+
notification: {
224+
click_action: "",
225+
},
226+
},
179227
},
180228
},
181229
182-
// 通用
183-
sessionId: targetId,
230+
// IOS apns
231+
sessionId:
232+
conversationType == 1
233+
? uni.$UIKitStore.userStore.myUserInfo.accountId
234+
: targetId,
184235
sessionType: conversationType,
185236
});
186237
238+
// @ts-ignore
187239
const pushConfig = {
188240
pushEnabled: true,
189241
pushNickEnabled: true,
190242
forcePush: needForcePush,
191243
forcePushContent: pushContent,
192244
forcePushAccountIds: forcePushIDsList,
193-
pushPayload: "{}",
245+
pushPayload,
194246
pushContent,
195247
};
196248
@@ -199,50 +251,52 @@ export default {
199251
},
200252
"UniApp"
201253
));
254+
202255
// #ifdef APP-PLUS
203256
/** 注册推送 */
204257
nim.V2NIMSettingService.setOfflinePushConfig(nimPushPlugin, {
205258
miPush: {
206-
appId: "",
207-
appKey: "",
208-
certificateName: "",
259+
appId: "2882303761517864366",
260+
appKey: "5991786427366",
261+
certificateName: "KIT_UNIAPP_MI_PUSH",
209262
},
210263
211264
hwPush: {
212-
appId: "",
213-
certificateName: "",
265+
appId: "109540237",
266+
certificateName: "KIT_UNIAPP_HW_PUSH",
214267
},
215268
216269
oppoPush: {
217-
appId: "",
218-
appKey: "",
219-
certificateName: "",
220-
secret: "",
270+
appId: "30795055",
271+
appKey: "6ffe2c1198c5448e84b75f3b78b711ce",
272+
certificateName: "KIT_OPPO_PUSH",
273+
secret: "f55d519d05a04360a8ba3404a24594a0",
221274
},
222275
223276
vivoPush: {
224-
appId: "",
225-
appKey: "",
226-
certificateName: "",
277+
appId: "105693306",
278+
appKey: "c8ccf661e2aa7895c1a46b3631d5a163",
279+
certificateName: "KIT_UNIAPP_VIVO_PUSH",
227280
},
228281
229282
fcmPush: {
230-
certificateName: "",
283+
certificateName: "KIT_UNIAPP_FCM_PUSH",
231284
},
232285
233286
mzPush: {
234-
appId: "",
235-
appKey: "",
236-
certificateName: "",
287+
appId: "148192",
288+
appKey: "6068c5a8323542deaf83ad5b6d3ca9e2",
289+
certificateName: "KIT_MEIZU_PUSH",
237290
},
238291
239292
apns: {
240-
certificateName: "",
293+
certificateName: "dis_im",
241294
},
242295
});
243296
// #endif
297+
244298
/** nim sdk 登录 */
245-
nim.V2NIMLoginService.login(opts.account, opts.token).then(() => {
299+
nim.V2NIMLoginService.login(opts.account, opts.token).then(async () => {
246300
// #ifdef APP-PLUS
247301
/** 初始化音视频通话插件*/
248302
nimCallKit.initConfig(
@@ -273,10 +327,25 @@ export default {
273327
}
274328
}
275329
);
330+
276331
// #endif
277-
customSwitchTab({
278-
url: "/pages/Conversation/index",
279-
});
332+
// 判断时手动点击唤起 还是 点击推送通知栏唤起,点击通知栏唤起直接跳转到聊天页面
333+
if (!startByNotificationId) {
334+
customSwitchTab({
335+
url: "/pages/Conversation/index",
336+
});
337+
} else {
338+
if (startByNotificationId) {
339+
await uni.$UIKitStore.uiStore.selectConversation(
340+
startByNotificationId
341+
);
342+
343+
uni.navigateTo({
344+
url: `/pages/Chat/index?conversationId=${startByNotificationId}`,
345+
});
346+
startByNotificationId = "";
347+
}
348+
}
280349
});
281350
},
282351
logout() {

NEUIKit/components/Appellation.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88

99
<script lang="ts" setup>
1010
import { autorun } from 'mobx'
11-
import {
12-
onUnmounted,
13-
ref,
14-
defineProps,
15-
withDefaults,
16-
} from '../utils/transformVue'
11+
import { onUnmounted, ref, defineProps, withDefaults } from 'vue'
1712
1813
const appellation = ref('')
1914

NEUIKit/components/Avatar.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@
2626
<script lang="ts" setup>
2727
import { customNavigateTo, customRedirectTo } from '../utils/customNavigate'
2828
import { autorun } from 'mobx'
29-
import {
30-
ref,
31-
computed,
32-
onUnmounted,
33-
defineProps,
34-
withDefaults,
35-
} from '../utils/transformVue'
29+
import { ref, computed, onUnmounted, withDefaults } from 'vue'
3630
import { V2NIMUser } from 'nim-web-sdk-ng/dist/v2/NIM_UNIAPP_SDK/V2NIMUserService'
3731
const props = withDefaults(
3832
defineProps<{
@@ -104,21 +98,21 @@ const handleAvatarClick = () => {
10498
if (props.isRedirect) {
10599
if (props.account === uni.$UIKitStore?.userStore?.myUserInfo.accountId) {
106100
customRedirectTo({
107-
url: `/pages/user-card/my-detail/index`,
101+
url: `/pages/User/my-detail/index`,
108102
})
109103
} else {
110104
customRedirectTo({
111-
url: `/pages/user-card/friend/index?account=${props.account}`,
105+
url: `/pages/User/friend/index?account=${props.account}`,
112106
})
113107
}
114108
} else {
115109
if (props.account === uni.$UIKitStore?.userStore?.myUserInfo.accountId) {
116110
customNavigateTo({
117-
url: `/pages/user-card/my-detail/index`,
111+
url: `/pages/User/my-detail/index`,
118112
})
119113
} else {
120114
customNavigateTo({
121-
url: `/pages/user-card/friend/index?account=${props.account}`,
115+
url: `/pages/User/friend/index?account=${props.account}`,
122116
})
123117
}
124118
}

NEUIKit/components/Badge.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
</template>
88

99
<script lang="ts" setup>
10-
import {
11-
StyleValue,
12-
computed,
13-
defineProps,
14-
withDefaults,
15-
} from '../utils/transformVue'
10+
import { StyleValue, computed, withDefaults } from 'vue'
1611
1712
const props = withDefaults(
1813
defineProps<{

NEUIKit/components/Empty.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</template>
1010

1111
<script lang="ts" setup>
12-
import { defineProps, withDefaults } from '../utils/transformVue'
1312
withDefaults(
1413
defineProps<{
1514
text?: string

NEUIKit/components/FormInput.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@
2424
</template>
2525

2626
<script lang="ts" setup>
27-
import {
28-
ref,
29-
computed,
30-
defineProps,
31-
withDefaults,
32-
defineEmits,
33-
} from '../utils/transformVue'
27+
import { ref, computed } from 'vue'
3428
const $emit = defineEmits([
3529
'update:modelValue',
3630
'input',

0 commit comments

Comments
 (0)