Skip to content

Commit

Permalink
Merge pull request #5 from Angus2333/main
Browse files Browse the repository at this point in the history
uniapp uikit v1.3.0
  • Loading branch information
shine2008 authored Mar 4, 2024
2 parents 60b3435 + 6dd69a5 commit 9e35b7e
Show file tree
Hide file tree
Showing 739 changed files with 46,870 additions and 20,114 deletions.
156 changes: 156 additions & 0 deletions NEUIKit/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<script>
import RootStore from '@xkit-yx/im-store'
import { NimKitCore } from '@xkit-yx/core-kit/dist/uniapp-nim-core'
import { getMsgContentTipByType } from './pages/NEUIKit/utils/msg'
import { getUniPlatform } from './pages/NEUIKit/utils'
// #ifdef APP-PLUS
const nimPushPlugin = uni.requireNativePlugin('NIMUniPlugin-PluginModule')
// #endif
export default {
onLaunch: function () {
const isWeixinApp = getUniPlatform() === 'mp-weixin'
// @ts-ignore
const nim = uni.$UIKitNIM = new NimKitCore({
initOptions: {
"appkey": "", // 请填写你的appkey
"account": "", // 请填写你的account
"token": "", // 请填写你的token
"lbsUrls": isWeixinApp ? [
"https://lbs.netease.im/lbs/wxwebconf.jsp"
] : [
"https://lbs.netease.im/lbs/webconf.jsp"
],
"linkUrl": "weblink.netease.im",
"needReconnect": true,
/**
* 使用固定设备ID,
*/
isFixedDeviceId: true,
// "reconnectionAttempts": 5,
debugLevel: 'debug',
},
platform: 'UniApp',
})
// @ts-ignore
const store = uni.$UIKitStore = new RootStore(nim, {
addFriendNeedVerify: false,
teamBeInviteMode: 'noVerify',
teamJoinMode: 'noVerify',
teamUpdateExtMode: 'all',
teamUpdateTeamMode: 'all',
teamInviteMode: 'all',
sendMsgBefore: async (options, type) => {
const pushContent = getMsgContentTipByType({ body: options.body, type })
const yxAitMsg = options.ext ? options.ext.yxAitMsg : { forcePushIDsList: '[]', needForcePush: false }
// 如果是 at 消息,需要走离线强推
const { forcePushIDsList, needForcePush } = yxAitMsg
// @ts-ignore
? store.msgStore._formatExtAitToPushInfo(yxAitMsg, options.body)
: { forcePushIDsList: '[]', needForcePush: false }
console.log('forcePushIDsList: ', forcePushIDsList)
// 不同产商的推送消息体
const { scene, to } = options
const pushPayload = JSON.stringify({
// oppo
oppoField: {
"click_action_type": 4, // 参考 oppo 官网
"click_action_activity": '', // 各端不一样 TODO
"action_parameters": { "sessionId": scene, "sessionType": to } // 自定义
},
// vivo
vivoField: {
"pushMode": 0 //推送模式 0:正式推送;1:测试推送,不填默认为0
},
// huawei
hwField: {
click_action: {
'type': 1,
'action': '' // 各端不一样 TODO
},
androidConfig: {
'category': 'IM',
'data': JSON.stringify({ 'sessionId': to, 'sessionType': scene })
}
},
// 通用
sessionId: to,
sessionType: scene
})
const pushInfo = {
needPush: true,
needPushBadge: true,
pushPayload: '{}',
pushContent,
needForcePush,
forcePushIDsList,
forcePushContent: pushContent,
}
return { ...options, pushInfo }
},
})
// #ifdef APP-PLUS
// 注册推送
nim.getNIM().offlinePush.setOfflinePushConfig({
plugin: nimPushPlugin,
authConfig: {
// xiaomi
xmAppId: "",
xmAppKey: "",
xmCertificateName: "KIT_UNIAPP_MI_PUSH",
// huawei
hwAppId: "",
hwCertificateName: "KIT_UNIAPP_HW_PUSH",
// oppo
oppoAppId: "",
oppoAppKey: "",
oppoAppSecret: "",
oppoCertificateName: "KIT_UNIAPP_OPPO_PUSH",
/**
* 注意vivo的appid和appkey需要同时在此处,以及manifest.json(即插件参数配置)中配置
*/
vivoAppId: "",
vivoAppKey: "",
vivoCertificateName: "KIT_UNIAPP_VIVO_PUSH",
// fcm
fcmCertificateName: "KIT_UNIAPP_FCM_PUSH",
// meizu
mzAppId: "",
mzAppKey: "",
mzCertificateName: "KIT_UNIAPP_MZ_PUSH",
// iOS
apnsCertificateName: "dis_im_uniapp"
}
})
// #endif
nim.connect()
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
}
}
</script>

<style>
/*每个页面公共css */
</style>



Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const { account, teamId, ignoreAlias, nickFromMsg } = defineProps({
})
autorun(() => {
appellation.value = deepClone(uni.$UIKitStore.uiStore.getAppellation({
// @ts-ignore
appellation.value = deepClone(uni.$UIKitStore?.uiStore?.getAppellation({
account,
teamId,
ignoreAlias,
Expand Down
13 changes: 9 additions & 4 deletions vue2/components/Avatar.vue → NEUIKit/components/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const avatarSize = props.size || 42
const user = ref<UserNameCard>()
let isLongPress = false // uniapp 长按事件也会触发点击事件,此时需要处理
const appellation = computed(() => {
// @ts-ignore
return uni.$UIKitStore.uiStore.getAppellation({
account: props.account,
teamId: props.teamId,
Expand All @@ -75,13 +76,15 @@ const appellation = computed(() => {
}).slice(0,2)
})
autorun(async () => {
const data = await uni.$UIKitStore.userStore.getUserActive(props.account)
// @ts-ignore
const data = await uni.$UIKitStore?.userStore?.getUserActive(props.account)
user.value = deepClone(data)
})
const avatarUrl = computed(() => {
user.value = deepClone(uni.$UIKitStore.userStore.users.get(props.account))
// @ts-ignore
user.value = deepClone(uni.$UIKitStore?.userStore?.users?.get(props.account))
return props.avatar || user.value?.avatar
})
Expand All @@ -105,7 +108,8 @@ if (!color) {
const handleAvatarClick = () => {
if (props.gotoUserCard && !isLongPress) {
if (props.isRedirect) {
if (props.account === uni.$UIKitStore.userStore.myUserInfo.account) {
// @ts-ignore
if (props.account === uni.$UIKitStore?.userStore?.myUserInfo.account) {
customRedirectTo({
url: `/pages/user-card/my-detail/index`,
})
Expand All @@ -115,7 +119,8 @@ const handleAvatarClick = () => {
})
}
} else {
if (props.account === uni.$UIKitStore.userStore.myUserInfo.account) {
// @ts-ignore
if (props.account === uni.$UIKitStore?.userStore?.myUserInfo.account) {
customNavigateTo({
url: `/pages/user-card/my-detail/index`,
})
Expand Down
2 changes: 1 addition & 1 deletion vue2/components/Badge.vue → NEUIKit/components/Badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script lang="ts" setup>
import { ref, onMounted, computed } from '../utils/transformVue'
import { computed } from '../utils/transformVue'
const props = defineProps({
num: {
Expand Down
2 changes: 1 addition & 1 deletion vue2/components/Empty.vue → NEUIKit/components/Empty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>

<script lang="ts" setup>
import { ref, onMounted } from '@vue/composition-api'
import { ref, onMounted } from '../utils/transformVue'
const props = defineProps({
text: {
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const inputError = ref(false);
// const inputKey = ref(0);
const inputClass = computed(() => {
// @ts-ignore
return [props.class, 'form-input-item', { 'focus': inputFocus.value, 'error': inputError.value }];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export type FriendSelectItem = IFriendInfo & { disable?: boolean; checked?: bool
const props = defineProps({
friendList: {
type: Array,
required: true
required: true,
default: () => []
},
showBtn: {
type: Boolean,
Expand Down
4 changes: 2 additions & 2 deletions vue2/components/Icon.vue → NEUIKit/components/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script lang="ts" setup>
// svg 解决方案参考:https://github.com/iconfont-cli/mini-program-iconfont-cli/tree/master
// import { ref } from 'vue'
import { ref, onMounted, computed } from '@vue/composition-api'
import { ref, onMounted, computed } from '../utils/transformVue'
const props = defineProps({
type: {
type: String,
Expand All @@ -27,7 +27,7 @@ const props = defineProps({
default: null,
},
iconStyle: {
default: () => { },
default: () => {},
}
})
const urlMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import { emojiMap, emojiRegExp } from '../utils/emoji'
import { ref, computed } from '../utils/transformVue';
const props = defineProps({
text: {
type: String,
default: '',
required: true
}
})
text: {
type: String,
default: '',
required: true
}
})
// 筛选出文本和表情
const parseText = (text: string) => {
Expand Down
1 change: 1 addition & 0 deletions vue2/components/Modal.vue → NEUIKit/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const props = defineProps({
})
const emit = defineEmits(["confirm", "cancel"]);
const handleMaskClick = () => {
emit('cancel')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<script lang="ts" setup>
import { getUniPlatform } from '../utils';
import Icon from './Icon.vue'
defineProps({
title: {
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script lang="ts" setup>
import { autorun } from 'mobx';
// import { ref } from 'vue';
import { ref, onMounted } from '@vue/composition-api'
import { ref, onMounted } from '../utils/transformVue'
import { t } from '../utils/i18n';
const isConnected = ref(true);
const text = ref('');
Expand All @@ -21,9 +21,11 @@ const text = ref('');
// });
autorun(() => {
if (uni.$UIKitStore.connectStore.connectState === 'connected') {
// @ts-ignore
if (uni.$UIKitStore?.connectStore?.connectState === 'connected') {
isConnected.value = true;
} else if (uni.$UIKitStore.connectStore.connectState === 'disconnected') {
// @ts-ignore
} else if (uni.$UIKitStore?.connectStore?.connectState === 'disconnected') {
isConnected.value = false;
text.value = t('offlineText');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
</div>
<div class="account-wrapper">
<div class="nick">{{ nick || account }}</div>
<div class="account" @tap.stop="copyAccount">
<div class="account">
{{ props.account }}
<Icon class="copy-icon" type="icon-fuzhi1" color="#A6ADB6" :size="20"></Icon>
<div @tap.stop="copyAccount">
<Icon class="copy-icon" type="icon-fuzhi1" color="#A6ADB6" :size="20"></Icon>
</div>
</div>
</div>
</div>
</div>
</template>

<script lang="ts" setup>
Expand All @@ -20,6 +22,7 @@ import Icon from './Icon.vue'
const props = defineProps({
account: {
type: String,
default: ''
},
nick: {
type: String,
Expand Down
2 changes: 1 addition & 1 deletion vue2/locale/en.json → NEUIKit/locale/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"messageText": "Message",
"cantactsText": "Cantact",
"mineText": "Me"
"mineText": "Me"
}
2 changes: 1 addition & 1 deletion vue2/locale/en.ts → NEUIKit/locale/en.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// en.js
export default {
export default {
appText: 'NIM',
messageText: 'Message',
contactText: 'Contacts',
Expand Down
2 changes: 1 addition & 1 deletion vue2/locale/zh-Hans.json → NEUIKit/locale/zh-Hans.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"messageText": "消息",
"cantactsText": "通讯录",
"mineText": "我的"
"mineText": "我的"
}
2 changes: 1 addition & 1 deletion vue2/locale/zh-Hans.ts → NEUIKit/locale/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
messageText: '消息',
contactText: '通讯录',
mineText: '我的',
logoutText: '退出登录',
logoutText: '退出登录',
commsEaseText: '关于云信',
logoutConfirmText: '确定退出登录吗?',
avatarText: '头像',
Expand Down
2 changes: 1 addition & 1 deletion vue2/pages.json → NEUIKit/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"path": "pages/Login/index",
"style": {
"navigationStyle": "custom"
}
}
},
{
"path": "pages/Chat/message/p2p-set",
Expand Down
Loading

0 comments on commit 9e35b7e

Please sign in to comment.