-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Angus2333/main
uniapp uikit 1.1.0
- Loading branch information
Showing
90 changed files
with
26,212 additions
and
3,319 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"symbol_url": "//at.alicdn.com/t/c/font_3429868_blvaz7v7n6p.js", | ||
"save_dir": "./iconfont", | ||
"use_rpx": false, | ||
"trim_icon_prefix": "", | ||
"default_icon_size": 16 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,98 @@ | ||
<script lang="ts"> | ||
import RootStore from '@xkit-yx/im-store' | ||
import { NimKitCore } from '@xkit-yx/core-kit/dist/uniapp-nim-core' | ||
import { customRedirectTo, customReLaunch, customSwitchTab } from './utils/customNavigate' | ||
const STORAGE_KEY = '__yx_im_options__' | ||
export default { | ||
onLaunch() { | ||
// #ifdef APP-PLUS | ||
plus.navigator.closeSplashscreen() | ||
// #endif | ||
if (uni.$UIKitStore && uni.$UIKitStore.connectStore.connectState === 'connected') { | ||
return | ||
} | ||
const imOptions = uni.getStorageSync(STORAGE_KEY); | ||
if (imOptions) { | ||
this.initNim(imOptions) | ||
} else { | ||
// 需要登录 im | ||
customRedirectTo({ | ||
url: '/pages/Login/index' | ||
}) | ||
} | ||
}, | ||
methods: { | ||
initNim(opts: { account: string, token: string }) { | ||
// 保存登录信息 | ||
uni.setStorage({ | ||
key: STORAGE_KEY, | ||
data: opts, | ||
success: function () { | ||
console.log('保存登录信息success'); | ||
} | ||
}); | ||
const nim = uni.$UIKitNIM = new NimKitCore({ | ||
initOptions: { | ||
"appkey": "", | ||
"lbsUrls": [ | ||
"https://lbs.netease.im/lbs/webconf.jsp" | ||
], | ||
"linkUrl": "weblink.netease.im", | ||
"needReconnect": true, | ||
// "reconnectionAttempts": 5, | ||
debugLevel: 'debug', | ||
...opts, | ||
<script> | ||
import RootStore from '@xkit-yx/im-store' | ||
import { NimKitCore } from '@xkit-yx/core-kit/dist/uniapp-nim-core' | ||
import { getMsgContentTipByType } from './utils/msg' | ||
export default { | ||
onLaunch: function() { | ||
const nim = uni.$UIKitNIM = new NimKitCore({ | ||
initOptions: { | ||
"appkey": "", //您在云信控制台注册的appkey | ||
"account": "", //云信控制台上的account | ||
"token": "", | ||
"lbsUrls": [ | ||
"https://lbs.netease.im/lbs/webconf.jsp" | ||
], | ||
"linkUrl": "weblink.netease.im", | ||
"needReconnect": true, | ||
// "reconnectionAttempts": 5, | ||
debugLevel: 'debug' | ||
}, | ||
platform: 'UniApp', | ||
}) | ||
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 }) | ||
// 如果是 at 消息,需要走离线强推 | ||
const { forcePushIDsList, needForcePush } = options.ext?.yxAitMsg | ||
// @ts-ignore | ||
? store.msgStore._formatExtAitToPushInfo(options.ext?.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 } | ||
}, | ||
}) | ||
nim.connect() | ||
}, | ||
platform: 'UniApp', | ||
}) | ||
uni.$UIKitStore = new RootStore(nim, { | ||
addFriendNeedVerify: false, | ||
teamBeInviteMode: 'noVerify', | ||
teamJoinMode: 'noVerify', | ||
teamUpdateExtMode: 'all', | ||
teamUpdateTeamMode: 'all', | ||
teamInviteMode: 'all', | ||
}) | ||
nim.connect() | ||
customSwitchTab({ | ||
url: '/pages/Conversation/index' | ||
}) | ||
}, | ||
logout() { | ||
uni.removeStorageSync(STORAGE_KEY); | ||
customReLaunch({ | ||
url: '/pages/Login/index' | ||
}) | ||
uni.$UIKitNIM.disconnect() | ||
uni.$UIKitStore.destroy() | ||
onShow: function() { | ||
console.log('App Show') | ||
}, | ||
onHide: function() { | ||
console.log('App Hide') | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
<style></style> | ||
<style> | ||
/*每个页面公共css */ | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<span class="appellation" :style="customStyle">{{ appellation }}</span> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { autorun } from 'mobx'; | ||
import type { CSSProperties } from 'vue'; | ||
import { defineProps, ref } from 'vue'; | ||
const store = uni.$UIKitStore | ||
const appellation = ref('') | ||
autorun(() => { | ||
appellation.value = store.uiStore.getAppellation({ account, teamId, ignoreAlias, nickFromMsg }) | ||
}) | ||
const { account, teamId, ignoreAlias, nickFromMsg } = defineProps<{ | ||
account: string | ||
teamId?: string | ||
ignoreAlias?: boolean | ||
nickFromMsg?: string | ||
customStyle?: CSSProperties | ||
}>() | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.appellation { | ||
color: #333; | ||
font-size: 16px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
</style> |
Oops, something went wrong.