@smart-link/rn-im 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/addressList.d.ts +2 -0
- package/dist/api/addressList.js +1 -0
- package/dist/api/user.d.ts +2 -1
- package/dist/api/user.js +1 -0
- package/dist/components/Camera/Camera.d.ts +1 -1
- package/dist/components/Camera/Camera.js +2 -1
- package/dist/components/Camera/CameraCapture.d.ts +0 -24
- package/dist/components/Camera/CameraCapture.js +10 -76
- package/dist/components/Camera/CameraResult.js +6 -5
- package/dist/components/FormatTimeText.js +2 -2
- package/dist/components/Highlighter.js +5 -6
- package/dist/components/IndicatorText.js +4 -4
- package/dist/components/NetworkUnconnected.js +4 -4
- package/dist/components/VideoPlayer.js +5 -5
- package/dist/hooks/useImSelector.d.ts +3 -1
- package/dist/hooks/useImSelector.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/init.js +17 -2
- package/dist/pages/address-list/AddressList.js +8 -8
- package/dist/pages/address-list/ChooseContact.js +40 -22
- package/dist/pages/address-list/MyGroups.js +4 -4
- package/dist/pages/address-list/Organization.js +3 -3
- package/dist/pages/address-list/UserDetail.js +26 -21
- package/dist/pages/address-list/UserSearch.js +3 -3
- package/dist/pages/address-list/components/OrgPath.js +4 -4
- package/dist/pages/address-list/components/RenderUserItem.d.ts +4 -3
- package/dist/pages/address-list/components/RenderUserItem.js +5 -5
- package/dist/pages/address-list/components/UserJobs.d.ts +3 -3
- package/dist/pages/address-list/components/UserJobs.js +23 -8
- package/dist/pages/collection/Collection.js +5 -5
- package/dist/pages/collection/ContentFactory.js +11 -11
- package/dist/pages/conversation/ConversationList.js +5 -5
- package/dist/pages/conversation/ForwardToConversation.js +8 -8
- package/dist/pages/conversation/components/ConversationCard.js +8 -8
- package/dist/pages/conversation/components/ConversationOption.js +3 -3
- package/dist/pages/conversation/setting/GroupTransfer.js +4 -4
- package/dist/pages/conversation/setting/OptionAvatars.js +6 -6
- package/dist/pages/conversation/setting/OptionGroup.js +4 -4
- package/dist/pages/conversation/setting/OptionGroupMoreMember.js +3 -3
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +4 -4
- package/dist/pages/message/ChooseMember.js +7 -7
- package/dist/pages/message/FileSelector.js +19 -13
- package/dist/pages/message/MessageBackup/MessageBackup.js +3 -3
- package/dist/pages/message/MessageBackup/RestoreBackupPage.js +4 -4
- package/dist/pages/message/MessageBackup/StartBackupPage.js +4 -4
- package/dist/pages/message/MessageList.js +17 -22
- package/dist/pages/message/MessageRecord.js +3 -3
- package/dist/pages/message/components/BusiNotifyCard.js +9 -9
- package/dist/pages/message/components/MessageItem.d.ts +1 -2
- package/dist/pages/message/components/MessageItem.js +11 -11
- package/dist/pages/message/components/MessageItemQuote.js +4 -4
- package/dist/pages/message/components/MessageItemTips.js +5 -5
- package/dist/pages/message/components/MessageOption.d.ts +2 -3
- package/dist/pages/message/components/MessageOption.js +18 -18
- package/dist/pages/message/components/MessagePayload.d.ts +1 -2
- package/dist/pages/message/components/MessagePayload.js +2 -2
- package/dist/pages/message/components/MessageUndo.js +6 -9
- package/dist/pages/message/components/MultipleBar/index.js +5 -5
- package/dist/pages/message/components/Payload/PayloadContact.js +6 -6
- package/dist/pages/message/components/Payload/PayloadFile.js +4 -4
- package/dist/pages/message/components/Payload/PayloadMultiple.js +8 -8
- package/dist/pages/message/components/Payload/PayloadNotify.js +12 -11
- package/dist/pages/message/components/Payload/PayloadPicture.js +1 -1
- package/dist/pages/message/components/Payload/PayloadShare.js +5 -5
- package/dist/pages/message/components/Payload/PayloadVideo.js +3 -3
- package/dist/pages/message/components/Payload/PayloadVoice.js +3 -3
- package/dist/pages/message/components/Payload/PayloadWrapper.d.ts +2 -3
- package/dist/pages/message/components/Payload/PayloadWrapper.js +6 -5
- package/dist/pages/message/components/Payload/type.d.ts +1 -2
- package/dist/pages/message/components/ReceiptBack.js +8 -8
- package/dist/pages/message/components/TextMixMessage.js +9 -8
- package/dist/pages/message/components/TextMixQuote.js +23 -23
- package/dist/pages/message/components/UploadProgress.js +3 -3
- package/dist/pages/message/components/messageBar/EmojiPanel.js +3 -2
- package/dist/pages/message/components/messageBar/MessageBar.js +1 -0
- package/dist/pages/message/components/messageBar/MessageInput.js +1 -0
- package/dist/pages/message/components/messageBar/OptionPanel.js +40 -29
- package/dist/pages/message/components/messageBar/VoiceBar.js +6 -6
- package/dist/pages/search/SearchChatRecords.js +6 -6
- package/dist/pages/search/SearchFile.js +9 -9
- package/dist/pages/search/SearchPicturePage.js +3 -3
- package/dist/pages/search/components/ChatRecords.js +7 -7
- package/dist/pages/search/components/MyGroupChat.js +5 -5
- package/dist/pages/search/components/PictureMulipleBar.js +5 -5
- package/dist/pages/search/components/SearchFileList.js +8 -8
- package/dist/pages/search/components/SearchPictures.js +4 -4
- package/dist/pages/search/components/SearchShareLinkList.js +8 -8
- package/dist/pages/search/components/SearchUser.js +5 -5
- package/dist/slice/video/video.action.js +6 -2
- package/dist/utils/camera.d.ts +25 -0
- package/dist/utils/camera.js +75 -0
- package/dist/utils/file.d.ts +2 -1
- package/dist/utils/file.js +26 -22
- package/dist/utils/request.js +0 -1
- package/dist/utils/summary.js +2 -2
- package/dist/utils/upload.js +10 -4
- package/package.json +3 -4
|
@@ -13,9 +13,9 @@ import useTranslation from '../../../hooks/useTranslation';
|
|
|
13
13
|
import { getImManager } from '../../../init';
|
|
14
14
|
import { getSummary } from '../../../utils/summary';
|
|
15
15
|
import { ConversationType } from '@smart-link/im-base';
|
|
16
|
-
import { dp, useNavigation } from '@smart-link/rn-ui';
|
|
16
|
+
import { CaihText, dp, useNavigation } from '@smart-link/rn-ui';
|
|
17
17
|
import React, { memo } from 'react';
|
|
18
|
-
import { View, StyleSheet,
|
|
18
|
+
import { View, StyleSheet, FlatList, TouchableOpacity } from 'react-native';
|
|
19
19
|
const MyGroupChat = memo(({ keyword }) => {
|
|
20
20
|
const { chatGroups } = useChatGroup();
|
|
21
21
|
const { t } = useTranslation();
|
|
@@ -30,7 +30,7 @@ const MyGroupChat = memo(({ keyword }) => {
|
|
|
30
30
|
justifyContent: 'center',
|
|
31
31
|
alignItems: 'center',
|
|
32
32
|
}}>
|
|
33
|
-
<
|
|
33
|
+
<CaihText>{t('noSearchResult')}</CaihText>
|
|
34
34
|
</View>
|
|
35
35
|
</View>);
|
|
36
36
|
}
|
|
@@ -44,9 +44,9 @@ const MyGroupChat = memo(({ keyword }) => {
|
|
|
44
44
|
<ChatAvatar type={ConversationType.C2G} name={chatGroupName} disabled={true} id={chatGroupId} url={avatars} size={dp(42)}/>
|
|
45
45
|
<View style={styles.width10}/>
|
|
46
46
|
<View style={styles.left}>
|
|
47
|
-
<
|
|
47
|
+
<CaihText style={styles.name} numberOfLines={1}>
|
|
48
48
|
{getSummary(chatGroupName, keyword, 20)}
|
|
49
|
-
</
|
|
49
|
+
</CaihText>
|
|
50
50
|
</View>
|
|
51
51
|
</TouchableOpacity>);
|
|
52
52
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { memo, useEffect, useState } from 'react';
|
|
2
|
-
import { StyleSheet, TouchableOpacity,
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View, Animated } from 'react-native';
|
|
3
3
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
|
4
4
|
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
5
5
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
6
6
|
import useTranslation from '../../../hooks/useTranslation';
|
|
7
|
-
import { dp } from '@smart-link/rn-ui';
|
|
7
|
+
import { CaihText, dp } from '@smart-link/rn-ui';
|
|
8
8
|
const PictureMultipleBar = memo((props) => {
|
|
9
9
|
const { disabled, onPicMultipleForward, onPicMultipleCollect, onPicMultipleSave, onPicMultipleDelete } = props;
|
|
10
10
|
const { t } = useTranslation();
|
|
@@ -25,7 +25,7 @@ const PictureMultipleBar = memo((props) => {
|
|
|
25
25
|
}}>
|
|
26
26
|
<View style={styles.item}>
|
|
27
27
|
<FontAwesome5 name="reply" size={dp(20)} color={color}/>
|
|
28
|
-
<
|
|
28
|
+
<CaihText style={fontStyle}>{t('forward')}</CaihText>
|
|
29
29
|
</View>
|
|
30
30
|
</TouchableOpacity>
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ const PictureMultipleBar = memo((props) => {
|
|
|
33
33
|
onPicMultipleCollect && onPicMultipleCollect();
|
|
34
34
|
}}>
|
|
35
35
|
<MaterialIcons name="collections" size={dp(20)} color={color}/>
|
|
36
|
-
<
|
|
36
|
+
<CaihText style={fontStyle}>{t('collect')}</CaihText>
|
|
37
37
|
</TouchableOpacity>
|
|
38
38
|
|
|
39
39
|
{/* <TouchableOpacity
|
|
@@ -51,7 +51,7 @@ const PictureMultipleBar = memo((props) => {
|
|
|
51
51
|
onPicMultipleDelete && onPicMultipleDelete();
|
|
52
52
|
}}>
|
|
53
53
|
<AntDesign name="delete" size={dp(20)} color={color}/>
|
|
54
|
-
<
|
|
54
|
+
<CaihText style={fontStyle}>{t('delete')}</CaihText>
|
|
55
55
|
</TouchableOpacity>
|
|
56
56
|
</Animated.View>);
|
|
57
57
|
});
|
|
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { View, StyleSheet, PixelRatio, SectionList, TouchableOpacity } from "react-native";
|
|
11
11
|
import { memo } from "react";
|
|
12
12
|
import { useSearchMessage } from "../../../pages/search/components/useSearchMessage";
|
|
13
13
|
import useTranslation from "../../../hooks/useTranslation";
|
|
14
|
-
import { ActionSheet, dp } from "@smart-link/rn-ui";
|
|
14
|
+
import { ActionSheet, CaihText, dp } from "@smart-link/rn-ui";
|
|
15
15
|
import { borderStyle } from "../../../components/styles";
|
|
16
16
|
import ChatAvatar from "../../../components/ChatAvatar";
|
|
17
17
|
import dayjs from "dayjs";
|
|
@@ -31,12 +31,12 @@ const SearchFileList = ({ keyword, conversationId }) => {
|
|
|
31
31
|
});
|
|
32
32
|
if (data.length === 0) {
|
|
33
33
|
return <View style={styles.empty}>
|
|
34
|
-
<
|
|
34
|
+
<CaihText>{t('noSearchResult')}</CaihText>
|
|
35
35
|
</View>;
|
|
36
36
|
}
|
|
37
37
|
const keyExtractor = (item) => item.messageSeq;
|
|
38
38
|
const renderSectionHeader = ({ section }) => {
|
|
39
|
-
return (<
|
|
39
|
+
return (<CaihText style={styles.dateTxt}>{section.date}</CaihText>);
|
|
40
40
|
};
|
|
41
41
|
const renderItem = ({ item }) => {
|
|
42
42
|
const { messageSeq, messageFrom, messageFromName, payload = {}, } = item;
|
|
@@ -93,13 +93,13 @@ const SearchFileList = ({ keyword, conversationId }) => {
|
|
|
93
93
|
}}>
|
|
94
94
|
<View style={styles.itemTop}>
|
|
95
95
|
<ChatAvatar disabled={true} id={messageFrom} name={messageFromName} size={dp(24)}/>
|
|
96
|
-
<
|
|
97
|
-
<
|
|
96
|
+
<CaihText style={styles.name} numberOfLines={1}>{messageFromName}</CaihText>
|
|
97
|
+
<CaihText style={styles.time}>{dayjs(item.messageTime).format("YYYY-MM-DD")}</CaihText>
|
|
98
98
|
</View>
|
|
99
99
|
<View style={styles.file}>
|
|
100
100
|
<View style={styles.fileInfo}>
|
|
101
|
-
<
|
|
102
|
-
<
|
|
101
|
+
<CaihText style={styles.fileName} numberOfLines={2} ellipsizeMode={'middle'}>{payload.filename}</CaihText>
|
|
102
|
+
<CaihText style={styles.fileSize}>{numberToFileSize(payload.size)}</CaihText>
|
|
103
103
|
</View>
|
|
104
104
|
<Icon style={styles.imageIcon}/>
|
|
105
105
|
</View>
|
|
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Dimensions, SectionList, StyleSheet,
|
|
10
|
+
import { Dimensions, SectionList, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
11
11
|
import CachedImage from "../../../components/CachedImage";
|
|
12
|
-
import { Checkbox, dp, Toast, useNavigation } from "@smart-link/rn-ui";
|
|
12
|
+
import { CaihText, Checkbox, dp, Toast, useNavigation } from "@smart-link/rn-ui";
|
|
13
13
|
import PictureMultipleBar from "./PictureMulipleBar";
|
|
14
14
|
import React, { useMemo, useState } from "react";
|
|
15
15
|
import dayjs from "dayjs";
|
|
@@ -159,7 +159,7 @@ export const SearchPictures = ({ conversationId, multiple }) => {
|
|
|
159
159
|
date = title;
|
|
160
160
|
}
|
|
161
161
|
return (<View style={styles.header}>
|
|
162
|
-
<
|
|
162
|
+
<CaihText style={styles.headerText}>{date}</CaihText>
|
|
163
163
|
</View>);
|
|
164
164
|
}} renderItem={({ item }) => {
|
|
165
165
|
return (<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
@@ -204,7 +204,7 @@ export const SearchPictures = ({ conversationId, multiple }) => {
|
|
|
204
204
|
<CachedImage style={styles.img} localPath={message.payload.localPath} fileId={message.payload.fileId}/>
|
|
205
205
|
{/* 视频播放图标 */}
|
|
206
206
|
<View style={styles.playIcon}>
|
|
207
|
-
<
|
|
207
|
+
<CaihText style={styles.playIconText}>▶</CaihText>
|
|
208
208
|
</View>
|
|
209
209
|
</>)}
|
|
210
210
|
</View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { borderStyle } from "../../../components/styles";
|
|
2
|
-
import { dp } from '@smart-link/rn-ui';
|
|
3
|
-
import { PixelRatio, SectionList, TouchableOpacity, View,
|
|
2
|
+
import { CaihText, dp } from '@smart-link/rn-ui';
|
|
3
|
+
import { PixelRatio, SectionList, TouchableOpacity, View, StyleSheet, Linking } from "react-native";
|
|
4
4
|
import ChatAvatar from "../../../components/ChatAvatar";
|
|
5
5
|
import dayjs from "dayjs";
|
|
6
6
|
import { memo } from "react";
|
|
@@ -18,12 +18,12 @@ const SearchShareLinkList = ({ keyword, conversationId }) => {
|
|
|
18
18
|
});
|
|
19
19
|
if (data.length === 0) {
|
|
20
20
|
return <View style={styles.empty}>
|
|
21
|
-
<
|
|
21
|
+
<CaihText>{t('noSearchResult')}</CaihText>
|
|
22
22
|
</View>;
|
|
23
23
|
}
|
|
24
24
|
const keyExtractor = (item) => item.messageSeq;
|
|
25
25
|
const renderSectionHeader = ({ section }) => {
|
|
26
|
-
return (<
|
|
26
|
+
return (<CaihText style={styles.dateTxt}>{section.date}</CaihText>);
|
|
27
27
|
};
|
|
28
28
|
const renderItem = ({ item }) => {
|
|
29
29
|
const { messageFrom, messageFromName, payload = {}, } = item;
|
|
@@ -34,13 +34,13 @@ const SearchShareLinkList = ({ keyword, conversationId }) => {
|
|
|
34
34
|
}}>
|
|
35
35
|
<View style={styles.itemTop}>
|
|
36
36
|
<ChatAvatar disabled={true} id={messageFrom} name={messageFromName} size={dp(24)}/>
|
|
37
|
-
<
|
|
38
|
-
<
|
|
37
|
+
<CaihText style={styles.name} numberOfLines={1}>{messageFromName}</CaihText>
|
|
38
|
+
<CaihText style={styles.time}>{dayjs(item.messageTime).format("YYYY-MM-DD")}</CaihText>
|
|
39
39
|
</View>
|
|
40
40
|
<View style={styles.link}>
|
|
41
41
|
<View style={styles.linkInfo}>
|
|
42
|
-
<
|
|
43
|
-
<
|
|
42
|
+
<CaihText style={styles.title} numberOfLines={1} ellipsizeMode={'middle'}>{payload.title || payload.description}</CaihText>
|
|
43
|
+
<CaihText style={styles.description} numberOfLines={2} ellipsizeMode={'middle'}>{payload.description}</CaihText>
|
|
44
44
|
</View>
|
|
45
45
|
<Favicon url={payload.url} size={size}/>
|
|
46
46
|
</View>
|
|
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { dp, ListRow, useNavigation } from '@smart-link/rn-ui';
|
|
10
|
+
import { CaihText, dp, ListRow, useNavigation } from '@smart-link/rn-ui';
|
|
11
11
|
import React, { memo, useEffect, useState } from 'react';
|
|
12
|
-
import { ScrollView,
|
|
12
|
+
import { ScrollView, View } from 'react-native';
|
|
13
13
|
import { searchUser } from '../../../api/user';
|
|
14
14
|
import ChatAvatar from '../../../components/ChatAvatar/ChatAvatar';
|
|
15
15
|
import Highlighter from '../../../components/Highlighter';
|
|
@@ -21,7 +21,7 @@ const RenderUserItem = (props) => {
|
|
|
21
21
|
<ChatAvatar needUpdate id={data.userId} url={data.avatars} name={data.userName}/>
|
|
22
22
|
<View style={{ marginLeft: dp(10), flex: 1 }}>
|
|
23
23
|
<Highlighter searchWord={keyword} textToHighlight={data.userName} numberOfLines={1}/>
|
|
24
|
-
<
|
|
24
|
+
<CaihText numberOfLines={1} style={{ fontSize: dp(12), color: '#999' }}>{data.groupNamePaths}</CaihText>
|
|
25
25
|
</View>
|
|
26
26
|
|
|
27
27
|
</View>);
|
|
@@ -35,7 +35,7 @@ const SearchUser = ({ keyword }) => {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
searchUser({
|
|
38
|
-
|
|
38
|
+
userNameLike: keyword,
|
|
39
39
|
}).then(({ data }) => {
|
|
40
40
|
setUserList(data);
|
|
41
41
|
});
|
|
@@ -46,7 +46,7 @@ const SearchUser = ({ keyword }) => {
|
|
|
46
46
|
justifyContent: 'center',
|
|
47
47
|
alignItems: 'center',
|
|
48
48
|
}}>
|
|
49
|
-
<
|
|
49
|
+
<CaihText>{t('noSearchResult')}</CaihText>
|
|
50
50
|
</View>);
|
|
51
51
|
}
|
|
52
52
|
return (<ScrollView style={{ flex: 1 }}>
|
|
@@ -17,7 +17,7 @@ let stopFn = () => { };
|
|
|
17
17
|
export const loadVideoPlayer = message => (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
console.log('loadVideoPlayer: ', message);
|
|
19
19
|
const { payload, messageSeq, isRecord } = message;
|
|
20
|
-
const { width = dp(100), height = dp(163), localPath } = payload;
|
|
20
|
+
const { width = dp(100), height = dp(163), localPath, sourcePath } = payload;
|
|
21
21
|
const thumbnail = payload.imagePath
|
|
22
22
|
? { uri: toAbsolutePath(payload.imagePath) }
|
|
23
23
|
: { uri: getDownloadUrl(payload.imageFileId) };
|
|
@@ -40,6 +40,10 @@ export const loadVideoPlayer = message => (dispatch) => __awaiter(void 0, void 0
|
|
|
40
40
|
catch (e) {
|
|
41
41
|
dispatch(setVideoDownloadError());
|
|
42
42
|
console.log('download error: ', e);
|
|
43
|
+
imManager.updateResource({
|
|
44
|
+
url: payload.fileId,
|
|
45
|
+
localPath: '',
|
|
46
|
+
});
|
|
43
47
|
throw new Error('download error');
|
|
44
48
|
}
|
|
45
49
|
});
|
|
@@ -96,7 +100,7 @@ export const loadVideoPlayer = message => (dispatch) => __awaiter(void 0, void 0
|
|
|
96
100
|
}
|
|
97
101
|
else {
|
|
98
102
|
dispatch(showVideoPlayer({
|
|
99
|
-
videoLocalPath: localPath,
|
|
103
|
+
videoLocalPath: (sourcePath || localPath),
|
|
100
104
|
videoImageHeight: height,
|
|
101
105
|
videoImageWidth: width,
|
|
102
106
|
videoImagePath: thumbnail.uri,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PhotoFile, VideoFile } from "react-native-vision-camera";
|
|
2
|
+
export interface PictureData {
|
|
3
|
+
filename: string;
|
|
4
|
+
localPath: string;
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
ext: string;
|
|
8
|
+
type: string;
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildPictureData(data: PhotoFile): Promise<{
|
|
12
|
+
filename: string;
|
|
13
|
+
localPath: string;
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
ext: string | undefined;
|
|
17
|
+
type: string;
|
|
18
|
+
size: string;
|
|
19
|
+
}>;
|
|
20
|
+
export interface VideoData extends PictureData {
|
|
21
|
+
imageName: string;
|
|
22
|
+
imagePath: string;
|
|
23
|
+
duration: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function buildVideoData(data: VideoFile): Promise<VideoData | null>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { moveFile, toAbsolutePath, toFullPath } from "./file";
|
|
11
|
+
import { createVideoThumbnail, Image, getFileSize, uuidv4 } from 'react-native-compressor';
|
|
12
|
+
import { ResourceType } from "@smart-link/im-base";
|
|
13
|
+
const { PICTURE, VIDEO } = ResourceType;
|
|
14
|
+
export function buildPictureData(data) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const uid = uuidv4();
|
|
17
|
+
const path = data.path;
|
|
18
|
+
const ext = path.split('.').pop();
|
|
19
|
+
const filename = PICTURE + '_' + uid + '.' + ext;
|
|
20
|
+
const tmp = yield Image.compress(path, {
|
|
21
|
+
compressionMethod: 'auto'
|
|
22
|
+
});
|
|
23
|
+
const localPath = yield moveFile(tmp, filename, PICTURE);
|
|
24
|
+
const size = yield getFileSize(toFullPath(localPath));
|
|
25
|
+
let width = data.width;
|
|
26
|
+
let height = data.height;
|
|
27
|
+
if (data.orientation === 'portrait') {
|
|
28
|
+
if (width > height) {
|
|
29
|
+
[width, height] = [height, width];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
filename: filename,
|
|
34
|
+
localPath: localPath,
|
|
35
|
+
height: height,
|
|
36
|
+
width: width,
|
|
37
|
+
ext: ext,
|
|
38
|
+
type: 'image/' + ext,
|
|
39
|
+
size,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function buildVideoData(data) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const uid = uuidv4();
|
|
46
|
+
const path = data.path;
|
|
47
|
+
try {
|
|
48
|
+
const ext = path.split('.').pop();
|
|
49
|
+
const filename = VIDEO + '_' + uid + '.' + ext;
|
|
50
|
+
const size = yield getFileSize(path);
|
|
51
|
+
console.log('video size', size);
|
|
52
|
+
let thumb = yield createVideoThumbnail(toAbsolutePath(path));
|
|
53
|
+
console.log('RNThumbnail', thumb);
|
|
54
|
+
const imageName = 'thumb_' + uid + '.jpg';
|
|
55
|
+
const imagePath = yield moveFile(thumb.path, imageName, VIDEO);
|
|
56
|
+
const localPath = yield moveFile(path, filename, VIDEO);
|
|
57
|
+
return {
|
|
58
|
+
filename,
|
|
59
|
+
localPath: localPath,
|
|
60
|
+
imageName,
|
|
61
|
+
imagePath,
|
|
62
|
+
duration: data.duration,
|
|
63
|
+
ext: ext,
|
|
64
|
+
type: 'video/' + ext,
|
|
65
|
+
width: thumb.width,
|
|
66
|
+
height: thumb.height,
|
|
67
|
+
size: Number(size),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.log('RNThumbnail', e);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
package/dist/utils/file.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare const getSuffix: (filename: string) => string;
|
|
|
22
22
|
export declare const download: ({ fileId, resourceType, filename, onProgress, onStart }: IDownloadOptions) => Promise<string>;
|
|
23
23
|
export declare function saveToAlbum(imManager: ImManager, localPath: string, showTips?: boolean): Promise<boolean>;
|
|
24
24
|
export declare function requestSaveFilePermissionIfAndroid(imManager: ImManager): Promise<boolean>;
|
|
25
|
+
export declare function getMimeFromExtension(ext: string): string;
|
|
25
26
|
export declare function getExtensionFromMime(mime: string): string;
|
|
26
27
|
export declare function selectFile(imManager: ImManager, filePath: string, filename: string): Promise<string | undefined>;
|
|
27
28
|
export declare function readFileDir(imManager: ImManager, path: string, keyword?: string): Promise<IPathItem[]>;
|
|
@@ -30,6 +31,7 @@ export declare function getFileRootItem(imManager: ImManager): Promise<IPathItem
|
|
|
30
31
|
export declare function createRootItem(imManager: ImManager, name: string, path: string): Promise<IPathItem>;
|
|
31
32
|
export declare function getFileType(path: string): string;
|
|
32
33
|
export declare function isImage(path: string): boolean;
|
|
34
|
+
export declare function isVideo(path: string): boolean;
|
|
33
35
|
export declare function sanitizeFilename(filename: string): string;
|
|
34
36
|
export declare function getSafeFilename(filename: string): string;
|
|
35
37
|
/**
|
|
@@ -40,5 +42,4 @@ export declare function getSafeFilename(filename: string): string;
|
|
|
40
42
|
*/
|
|
41
43
|
export declare function truncateFilenameMiddle(filename: string, maxLength?: number): string;
|
|
42
44
|
export declare function getFileSize(filePath: string): Promise<number>;
|
|
43
|
-
export declare function sliceFile(filePath: string, start: number, end: number): Promise<string>;
|
|
44
45
|
export {};
|
package/dist/utils/file.js
CHANGED
|
@@ -42,6 +42,10 @@ export function toAbsolutePath(filePath) {
|
|
|
42
42
|
if (filePath.startsWith('Documents') || filePath.startsWith('file://') || filePath.startsWith('file://' + documentPath)) {
|
|
43
43
|
return filePath;
|
|
44
44
|
}
|
|
45
|
+
if (Platform.OS === 'android' && !filePath.startsWith('file://')
|
|
46
|
+
&& filePath.startsWith('/data')) {
|
|
47
|
+
return 'file://' + filePath;
|
|
48
|
+
}
|
|
45
49
|
return 'file://' + documentPath + filePath;
|
|
46
50
|
}
|
|
47
51
|
export function toFullPath(filePath) {
|
|
@@ -73,7 +77,7 @@ export const moveFile = (filePath, filename, resourceType) => __awaiter(void 0,
|
|
|
73
77
|
const relativePath = resourceDir[resourceType] + "/" + filename;
|
|
74
78
|
const destPath = documentPath + relativePath;
|
|
75
79
|
if (yield RNFS.exists(destPath)) {
|
|
76
|
-
|
|
80
|
+
yield RNFS.unlink(destPath);
|
|
77
81
|
}
|
|
78
82
|
yield RNFS.moveFile(filePath, destPath);
|
|
79
83
|
return relativePath;
|
|
@@ -81,9 +85,6 @@ export const moveFile = (filePath, filename, resourceType) => __awaiter(void 0,
|
|
|
81
85
|
export const copyFile = (filePath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
86
|
const relativePath = resourceDir[resourceType] + "/" + filename;
|
|
83
87
|
const destPath = documentPath + relativePath;
|
|
84
|
-
if (yield RNFS.exists(destPath)) {
|
|
85
|
-
return relativePath;
|
|
86
|
-
}
|
|
87
88
|
console.log('copyFile', filePath, destPath);
|
|
88
89
|
yield RNFS.copyFile(filePath, destPath);
|
|
89
90
|
return relativePath;
|
|
@@ -93,9 +94,7 @@ export const getSuffix = (filename) => {
|
|
|
93
94
|
return filename.substring(index);
|
|
94
95
|
};
|
|
95
96
|
export const download = ({ fileId, resourceType, filename, onProgress, onStart }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
// const cookie = await getCookieString();
|
|
97
97
|
const fileUrl = getDownloadUrl(fileId);
|
|
98
|
-
// console.log('download url: ', fileUrl);
|
|
99
98
|
let relativePath = resourceDir[resourceType] + "/" + getSafeFilename(filename);
|
|
100
99
|
let destPath = documentPath + relativePath;
|
|
101
100
|
// 如果文件已经存在,则使用文件 id 作为文件名
|
|
@@ -106,11 +105,9 @@ export const download = ({ fileId, resourceType, filename, onProgress, onStart }
|
|
|
106
105
|
const { jobId, promise } = RNFS.downloadFile({
|
|
107
106
|
fromUrl: fileUrl,
|
|
108
107
|
toFile: destPath,
|
|
109
|
-
// headers: {
|
|
110
|
-
// 'Cookie': cookie,
|
|
111
|
-
// },
|
|
112
108
|
progressInterval: 300,
|
|
113
109
|
progressDivider: 5,
|
|
110
|
+
background: true,
|
|
114
111
|
begin: (e) => {
|
|
115
112
|
// 这个方法不能注释,否则 ios 不响应进度
|
|
116
113
|
console.log('download begin: ', e.jobId);
|
|
@@ -187,6 +184,7 @@ const extensions = {
|
|
|
187
184
|
'image/x-icon': '.ico',
|
|
188
185
|
'image/vnd.microsoft.icon': '.ico',
|
|
189
186
|
'image/x-ms-bmp': '.bmp',
|
|
187
|
+
'image/*': '.jpg',
|
|
190
188
|
// 文本
|
|
191
189
|
'text/plain': '.txt',
|
|
192
190
|
'text/html': '.html',
|
|
@@ -206,6 +204,7 @@ const extensions = {
|
|
|
206
204
|
'audio/aac': '.aac',
|
|
207
205
|
// 视频
|
|
208
206
|
'video/mp4': '.mp4',
|
|
207
|
+
'video/*': '.mp4',
|
|
209
208
|
'video/webm': '.webm',
|
|
210
209
|
'video/quicktime': '.mov',
|
|
211
210
|
'video/x-msvideo': '.avi',
|
|
@@ -238,14 +237,21 @@ const extensions = {
|
|
|
238
237
|
'application/octet-stream': '.apk',
|
|
239
238
|
'application/vnd.android.package-archive': '.apk',
|
|
240
239
|
'application/x-apk': '.apk',
|
|
240
|
+
'*/*': '.unknown',
|
|
241
241
|
};
|
|
242
|
+
const mimeFormExt = Object.entries(extensions).reduce((acc, [mime, ext]) => {
|
|
243
|
+
acc[ext.slice(1)] = mime;
|
|
244
|
+
return acc;
|
|
245
|
+
}, {});
|
|
246
|
+
export function getMimeFromExtension(ext) {
|
|
247
|
+
return mimeFormExt[ext];
|
|
248
|
+
}
|
|
242
249
|
export function getExtensionFromMime(mime) {
|
|
243
250
|
return extensions[mime] || '';
|
|
244
251
|
}
|
|
245
252
|
export function selectFile(imManager, filePath, filename) {
|
|
246
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
254
|
const success = yield requestSaveFilePermissionIfAndroid(imManager);
|
|
248
|
-
// console.log("获取写入内存的权限", success)
|
|
249
255
|
if (!success) {
|
|
250
256
|
return;
|
|
251
257
|
}
|
|
@@ -363,18 +369,25 @@ export function createRootItem(imManager, name, path) {
|
|
|
363
369
|
});
|
|
364
370
|
}
|
|
365
371
|
export function getFileType(path) {
|
|
372
|
+
if (!path)
|
|
373
|
+
return '';
|
|
366
374
|
if (path.lastIndexOf('.') === -1) {
|
|
367
375
|
return '';
|
|
368
376
|
}
|
|
369
|
-
return path.slice(path.lastIndexOf('.') + 1);
|
|
377
|
+
return path.slice(path.lastIndexOf('.') + 1).toLowerCase();
|
|
370
378
|
}
|
|
371
379
|
export function isImage(path) {
|
|
372
|
-
const imageTypes = ['jpg', 'jpeg', 'gif', 'bmp', 'png', 'webp'];
|
|
380
|
+
const imageTypes = ['jpg', 'jpeg', 'gif', 'bmp', 'png', 'webp', 'ico'];
|
|
373
381
|
const fileType = getFileType(path);
|
|
374
382
|
return imageTypes.includes(fileType);
|
|
375
383
|
}
|
|
384
|
+
export function isVideo(path) {
|
|
385
|
+
const videoTypes = ['mp4', 'avi', 'mkv', 'mov', 'wmv', 'flv', 'webm'];
|
|
386
|
+
const fileType = getFileType(path);
|
|
387
|
+
return videoTypes.includes(fileType);
|
|
388
|
+
}
|
|
376
389
|
export function sanitizeFilename(filename) {
|
|
377
|
-
return filename.replace(/[<>:"\/\\|?*\x00-\x1F]/g, '_'); // 替换非法字符为下划线
|
|
390
|
+
return (filename || '').replace(/[<>:"\/\\|?*\x00-\x1F]/g, '_'); // 替换非法字符为下划线
|
|
378
391
|
}
|
|
379
392
|
export function getSafeFilename(filename) {
|
|
380
393
|
let safeName = sanitizeFilename(filename); // 移除非安全字符
|
|
@@ -413,12 +426,3 @@ export function getFileSize(filePath) {
|
|
|
413
426
|
return stat.size;
|
|
414
427
|
});
|
|
415
428
|
}
|
|
416
|
-
export function sliceFile(filePath, start, end) {
|
|
417
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
418
|
-
// const destPath = `${userPath}/cache/${uuidv4()}.tmp`;
|
|
419
|
-
// 分片读取文件写入缓存文件
|
|
420
|
-
const base64 = yield RNFS.read(toAbsolutePath(filePath), end - start, start, 'base64');
|
|
421
|
-
// await RNFS.writeFile(destPath, base64, 'base64');
|
|
422
|
-
return base64;
|
|
423
|
-
});
|
|
424
|
-
}
|
package/dist/utils/request.js
CHANGED
|
@@ -35,7 +35,6 @@ export const createRequest = (base, _storage) => {
|
|
|
35
35
|
instance.interceptors.request.use((config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
if (!config.headers.Cookie) {
|
|
37
37
|
config.headers.Cookie = yield storage.getItem('cookies');
|
|
38
|
-
console.log('get cookie: ', config.headers.Cookie);
|
|
39
38
|
}
|
|
40
39
|
return config;
|
|
41
40
|
}), error => {
|
package/dist/utils/summary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Text } from "react-native";
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import { CaihText } from "@smart-link/rn-ui";
|
|
3
3
|
export function getSummary(text, searchKey, summaryLength = 15, color = 'red') {
|
|
4
4
|
if (!text) {
|
|
5
5
|
return;
|
|
@@ -29,7 +29,7 @@ export function getSummary(text, searchKey, summaryLength = 15, color = 'red') {
|
|
|
29
29
|
else {
|
|
30
30
|
result.push(text.substring(0, index));
|
|
31
31
|
}
|
|
32
|
-
result.push(<
|
|
32
|
+
result.push(<CaihText key={result.length} style={{ color }}>{text.substr(index, searchLength)}</CaihText>);
|
|
33
33
|
result.push(text.substring(index + searchLength, textLength));
|
|
34
34
|
return result;
|
|
35
35
|
}
|
package/dist/utils/upload.js
CHANGED
|
@@ -10,14 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import request, { getBaseURL, getStorage } from './request';
|
|
11
11
|
import { toAbsolutePath, toFullPath } from './file';
|
|
12
12
|
import { uploadFile as chunkUpload } from '@smart-link/chunk-upload';
|
|
13
|
-
|
|
13
|
+
import to from "await-to-js";
|
|
14
|
+
const CHUNK_SIZE = 1024 * 1024 * 6;
|
|
14
15
|
const uploadFile = (filePath, type, onProgress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
16
|
const uploadUrl = `/api-file/file/uploadFile`;
|
|
16
|
-
|
|
17
|
+
console.log('uploadFile: ', filePath, type);
|
|
18
|
+
const [err, local] = yield to(fetch(toAbsolutePath(filePath)));
|
|
19
|
+
if (err) {
|
|
20
|
+
console.log('fetch file size error: ', err);
|
|
21
|
+
return Promise.reject(err);
|
|
22
|
+
}
|
|
17
23
|
const file = yield local.blob();
|
|
18
24
|
const fileName = filePath.split('/').pop();
|
|
19
25
|
// 大文件20M以上, chunk上传
|
|
20
|
-
if (file.size > CHUNK_SIZE
|
|
26
|
+
if (file.size > CHUNK_SIZE) {
|
|
27
|
+
console.log('uploadBigFile: ', filePath, type);
|
|
21
28
|
return uploadBigFile(toFullPath(filePath), fileName, onProgress);
|
|
22
29
|
}
|
|
23
30
|
const formData = new FormData();
|
|
@@ -45,7 +52,6 @@ const uploadBigFile = (filePath, fileName, onProgress) => __awaiter(void 0, void
|
|
|
45
52
|
'Cookie': cookie,
|
|
46
53
|
},
|
|
47
54
|
onProgress: (o) => {
|
|
48
|
-
// console.log('uploadBigFile: ', o)
|
|
49
55
|
onProgress && onProgress({
|
|
50
56
|
loaded: o.loaded,
|
|
51
57
|
total: o.total,
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-link/rn-im",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./src/index.ts",
|
|
8
7
|
"dependencies": {
|
|
9
8
|
"color": "^5.0.0",
|
|
10
9
|
"lodash-es": "^4.17.21",
|
|
@@ -65,8 +64,8 @@
|
|
|
65
64
|
"react-redux": "^8.1.3",
|
|
66
65
|
"redux": "^4.2.1",
|
|
67
66
|
"redux-thunk": "^2.4.2",
|
|
68
|
-
"@smart-link/rn-ui": "^1.1.
|
|
69
|
-
"@smart-link/im-base": "^1.1.
|
|
67
|
+
"@smart-link/rn-ui": "^1.1.6",
|
|
68
|
+
"@smart-link/im-base": "^1.1.6"
|
|
70
69
|
},
|
|
71
70
|
"files": [
|
|
72
71
|
"dist/**",
|