Skip to content

Commit

Permalink
Merge pull request #3 from Angus2333/main
Browse files Browse the repository at this point in the history
uniapp uikit 1.1.0
  • Loading branch information
shine2008 authored Nov 24, 2023
2 parents f8da719 + 7b2a77a commit e1b7fc1
Show file tree
Hide file tree
Showing 90 changed files with 26,212 additions and 3,319 deletions.
File renamed without changes.
325 changes: 119 additions & 206 deletions README.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions iconfont.json
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
}
12 changes: 8 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
<head>
<meta charset="UTF-8" />
<meta name="referrer" content="no-referrer" />
<title>即时通讯 IM</title>
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
var coverSupport =
'CSS' in window &&
typeof CSS.supports === 'function' &&
(CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
(coverSupport ? ', viewport-fit=cover' : '') +
'" />'
)
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
Expand Down
20,514 changes: 18,823 additions & 1,691 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"build:app-android-prod": "BUILD_ENV=prod uni build -p app-android",
"build:app-ios-prod": "BUILD_ENV=prod uni build -p app-ios",
"build:custom": "uni build -p",
"build:h5": "uni build",
"build:h5": "BUILD_ENV=prod uni build",
"build:h5:ssr": "uni build --ssr",
"build:mp-alipay": "uni build -p mp-alipay",
"build:mp-baidu": "uni build -p mp-baidu",
"build:mp-kuaishou": "uni build -p mp-kuaishou",
"build:mp-lark": "uni build -p mp-lark",
"build:mp-qq": "uni build -p mp-qq",
"build:mp-toutiao": "uni build -p mp-toutiao",
"build:mp-weixin": "uni build -p mp-weixin",
"build:mp-weixin": "BUILD_ENV=prod uni build -p mp-weixin",
"build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
Expand All @@ -52,14 +52,14 @@
"@dcloudio/uni-mp-toutiao": "3.0.0-3070320230222002",
"@dcloudio/uni-mp-weixin": "3.0.0-3070320230222002",
"@dcloudio/uni-quickapp-webview": "3.0.0-3070320230222002",
"@xkit-yx/core-kit": "^0.10.2",
"@xkit-yx/im-store": "^0.0.7",
"@xkit-yx/utils": "^0.5.3",
"@xkit-yx/core-kit": "^0.10.8",
"@xkit-yx/im-store": "^0.0.14",
"@xkit-yx/utils": "^0.5.6",
"dayjs": "^1.11.7",
"mobx": "^6.6.1",
"pinyin": "^3.0.0-alpha.5",
"vue": "^3.2.45",
"vue-i18n": "^9.2.2"
"vue-i18n": "9.6.5"
},
"devDependencies": {
"@dcloudio/types": "3.2.11",
Expand All @@ -68,6 +68,7 @@
"@dcloudio/uni-stacktracey": "3.0.0-3070320230222002",
"@dcloudio/vite-plugin-uni": "3.0.0-3070320230222002",
"@vue/tsconfig": "^0.1.3",
"mini-program-iconfont-cli": "^0.6.1",
"sass": "^1.58.1",
"sass-loader": "^13.2.0",
"typescript": "^4.9.4",
Expand Down
166 changes: 95 additions & 71 deletions src/App.vue
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>
8 changes: 4 additions & 4 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ git clone https://github.com/netease-kit/nim-uikit-uniapp.git
# 在自己的项目根目录下执行以下命令,将组件 copy 过来
mkdir -p ./pages/NEUIKit
# macOS
mv ${组件项目路径}/src ./pages/NEUIKit
mv ${NEUIKit组件项目路径}/src ./pages/NEUIKit
# windows
move ${组件项目路径}/src .\pages\NEUIKit
move ${NEUIKit组件项目路径}/src .\pages\NEUIKit
```

成功后目录结构如图所示:<br>
Expand All @@ -84,7 +84,7 @@ move ${组件项目路径}/src .\pages\NEUIKit

```sh
npm init -y
npm i @xkit-yx/core-kit@0.10.2 @xkit-yx/im-store@0.0.7 @xkit-yx/utils@0.5.3 dayjs mobx pinyin vue-i18n --save
npm i @xkit-yx/core-kit @xkit-yx/im-store @xkit-yx/utils dayjs mobx pinyin vue-i18n --save

# 在自己的项目根目录下执行以下命令,将组件需要的图片复制到static目录下
# macOS
Expand Down Expand Up @@ -439,7 +439,7 @@ iOS:<br>
├── msg.ts // 消息相关
├── permission.ts // 设备权限相关
├── reporter.ts // 埋点上报
├── stringReplace.ts // 文本替换
├── parseText.ts // 文本消息解析
└── svgString.ts // iconfont Symbol 的 js 内容,注意从 symbol 标签开始替换,不要从 svg 标签开始替换
```

Expand Down
36 changes: 36 additions & 0 deletions src/components/Appellation.vue
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>
Loading

0 comments on commit e1b7fc1

Please sign in to comment.