Skip to content

Commit 3456d43

Browse files
committed
update 10.3.3
1 parent 3c71166 commit 3456d43

File tree

3 files changed

+54
-29
lines changed

3 files changed

+54
-29
lines changed

react/src/YXUIKit/im-kit-ui/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xkit-yx/im-kit-ui",
3-
"version": "10.3.1",
3+
"version": "10.3.3",
44
"description": "云信即时通讯组件",
55
"license": "MIT",
66
"main": "lib/index.js",
@@ -54,7 +54,7 @@
5454
},
5555
"dependencies": {
5656
"@ant-design/icons": "^5.0.1",
57-
"@xkit-yx/im-store-v2": "^0.2.0",
57+
"@xkit-yx/im-store-v2": "^0.2.1",
5858
"@xkit-yx/utils": "^0.7.1",
5959
"antd": "^4.16.3",
6060
"mobx": "^6.6.1",
@@ -63,5 +63,5 @@
6363
"react-string-replace": "^1.1.0",
6464
"react-virtualized": "^9.22.5"
6565
},
66-
"gitHead": "45e04861b1ab80e65b14e6b57c9fd1de60a9a1b0"
66+
"gitHead": "92925c6ca2358ac833adfd557c54b79e0345a01e"
6767
}

react/src/YXUIKit/im-kit-ui/src/chat/components/ChatAITranslate/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface ChatAITranslateProps {
1919
prefix?: string
2020
}
2121

22+
const defaultLangs = ['英语', '日语', '韩语', '俄语', '法语', '德语']
23+
2224
export const ChatAITranslate: FC<ChatAITranslateProps> = observer(
2325
({ inputValue, setInputValue, onClose, visible, prefix = 'chat' }) => {
2426
const _prefix = `${prefix}-ai-translate`
@@ -28,7 +30,11 @@ export const ChatAITranslate: FC<ChatAITranslateProps> = observer(
2830

2931
const aiErrorMap = getAIErrorMap(t)
3032

31-
const options = store.aiUserStore.getAITranslateLangs().map((lang) => ({
33+
const options = (
34+
store.aiUserStore.getAITranslateLangs().length
35+
? store.aiUserStore.getAITranslateLangs()
36+
: defaultLangs
37+
).map((lang) => ({
3238
label: lang,
3339
value: lang,
3440
}))
@@ -37,10 +43,10 @@ export const ChatAITranslate: FC<ChatAITranslateProps> = observer(
3743
? store.aiUserStore.aiResMsgs[0]
3844
: ''
3945

40-
const [selectedLang, setSelectedLang] = useState(options[0].value)
46+
const [selectedLang, setSelectedLang] = useState(options[0]?.value || '')
4147

4248
const resetState = () => {
43-
setSelectedLang(options[0].value)
49+
setSelectedLang(options[0]?.value || '')
4450
}
4551

4652
useEffect(() => {

react/src/components/IMApp/index.tsx

+42-23
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ import {
5454
import { LocalOptions } from '@xkit-yx/im-store-v2/dist/types/types'
5555
import V2NIM, { V2NIMConst } from 'nim-web-sdk-ng'
5656
import { V2NIMAIUser } from 'nim-web-sdk-ng/dist/v2/NIM_BROWSER_SDK/V2NIMAIService'
57-
import { RenderP2pCustomMessageOptions } from '@xkit-yx/im-kit-ui/src/chat/components/ChatP2pMessageList'
57+
import {
58+
NIMInitializeOptions,
59+
NIMOtherOptions,
60+
} from 'nim-web-sdk-ng/dist/v2/NIM_BROWSER_SDK/NIMInterface'
61+
import { RenderP2pCustomMessageOptions } from '@xkit-yx/im-kit-ui/es/chat/components/ChatP2pMessageList'
5862

5963
interface IMContainerProps {
6064
appkey: string //传入您的App Key
6165
account: string // 传入您的云信IM账号
6266
token: string // 传入您的Token
67+
initOptions?: NIMInitializeOptions
68+
otherOptions?: NIMOtherOptions
6369
onLogout?: () => void
6470
changeLanguage?: (value: 'zh' | 'en') => void
6571
}
@@ -319,7 +325,6 @@ const IMApp: React.FC<IMAppProps> = observer((props) => {
319325
[nim.V2NIMConversationIdUtil, nim.V2NIMMessageCreator, store.msgStore]
320326
)
321327

322-
323328
const renderContent = useCallback(() => {
324329
return (
325330
<>
@@ -341,7 +346,7 @@ const IMApp: React.FC<IMAppProps> = observer((props) => {
341346
className={classNames('chat-icon', {
342347
active: model === 'chat',
343348
})}
344-
onClick={goChat}
349+
onClick={() => setModel('chat')}
345350
>
346351
<i className="iconfont">&#xe6c9;</i>
347352
<div className="icon-label">{t('session')}</div>
@@ -430,11 +435,10 @@ const IMApp: React.FC<IMAppProps> = observer((props) => {
430435
teamMsgReceiptVisible,
431436
renderP2pCustomMessage,
432437
store.sysMsgStore,
433-
store.msgStore,
434-
nim.V2NIMMessageCreator,
435-
nim.V2NIMConversationIdUtil,
436438
needMention,
437439
teamManagerVisible,
440+
afterAcceptApplyFriend,
441+
goChat,
438442
])
439443

440444
return (
@@ -456,7 +460,7 @@ const IMApp: React.FC<IMAppProps> = observer((props) => {
456460
})
457461

458462
const IMAppContainer: React.FC<IMContainerProps> = (props) => {
459-
const { appkey, account, token, onLogout } = props
463+
const { appkey, account, token, initOptions, otherOptions, onLogout } = props
460464
// 国际化语言类型
461465
const [curLanguage, setCurLanguage] = useState<'zh' | 'en'>('zh')
462466
// 添加好友是否需要验证
@@ -566,26 +570,41 @@ const IMAppContainer: React.FC<IMContainerProps> = (props) => {
566570
}, [])
567571

568572
const nim = useMemo(() => {
569-
const nim = V2NIM.getInstance({
570-
appkey,
571-
account,
572-
token,
573-
debugLevel: 'debug',
574-
apiVersion: 'v2',
575-
})
573+
console.log(
574+
'V2NIM.getInstance: ',
575+
{
576+
appkey,
577+
debugLevel: 'debug',
578+
apiVersion: 'v2',
579+
...initOptions,
580+
},
581+
otherOptions
582+
)
583+
const nim = V2NIM.getInstance(
584+
{
585+
appkey,
586+
debugLevel: 'debug',
587+
apiVersion: 'v2',
588+
...initOptions,
589+
},
590+
otherOptions
591+
)
576592

577593
return nim
578-
}, [account, token, appkey])
594+
}, [appkey, initOptions, otherOptions])
579595

580596
useEffect(() => {
581-
nim.V2NIMLoginService.login(account, token, {
582-
retryCount: 5,
583-
})
584-
585-
return () => {
586-
nim.V2NIMLoginService.logout()
597+
if (account && token) {
598+
nim.V2NIMLoginService.login(account, token, {
599+
retryCount: 5,
600+
})
587601
}
588-
}, [nim, account, token])
602+
}, [account, token, nim.V2NIMLoginService])
603+
604+
const handleLogout = useCallback(async () => {
605+
await nim.V2NIMLoginService.logout()
606+
onLogout?.()
607+
}, [onLogout, nim.V2NIMLoginService])
589608

590609
return (
591610
<ConfigProvider locale={curLanguage === 'zh' ? zhCN : enUS}>
@@ -598,7 +617,7 @@ const IMAppContainer: React.FC<IMContainerProps> = (props) => {
598617
singleton={true}
599618
>
600619
<IMApp
601-
onLogout={onLogout}
620+
onLogout={handleLogout}
602621
appkey={appkey}
603622
account={account}
604623
locale={curLanguage}

0 commit comments

Comments
 (0)