@smart-link/rn-im 1.0.23 → 1.0.24
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.js +6 -17
- package/dist/api/backup.js +8 -20
- package/dist/api/file.js +6 -35
- package/dist/api/user.js +6 -16
- package/dist/components/CachedImage.js +14 -42
- package/dist/components/Camera/Camera.js +26 -54
- package/dist/components/Camera/CameraCapture.js +99 -128
- package/dist/components/Camera/CameraResult.js +33 -61
- package/dist/components/ChatAvatar/ChatAvatar.d.ts +1 -1
- package/dist/components/ChatAvatar/ChatAvatar.js +34 -62
- package/dist/components/ChatAvatar/ChatAvatarId.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarId.js +26 -51
- package/dist/components/ChatAvatar/ChatAvatarLocal.d.ts +2 -2
- package/dist/components/ChatAvatar/ChatAvatarLocal.js +23 -25
- package/dist/components/ChatAvatar/index.js +2 -23
- package/dist/components/Favicon.js +6 -34
- package/dist/components/FormatTimeText.js +5 -10
- package/dist/components/Highlighter.js +9 -34
- package/dist/components/IndicatorText.js +14 -39
- package/dist/components/LocalImage.js +7 -32
- package/dist/components/NetworkUnconnected.js +14 -42
- package/dist/components/PopoverWrapper.js +22 -47
- package/dist/components/VideoPlayer.js +111 -138
- package/dist/components/styles.js +10 -13
- package/dist/default-assets.d.ts +1 -0
- package/dist/default-assets.js +8 -10
- package/dist/hooks/useDownloadSource.js +7 -12
- package/dist/hooks/useFormatMsgTime.js +5 -13
- package/dist/hooks/useImReady.js +7 -10
- package/dist/hooks/useImSelector.js +34 -48
- package/dist/hooks/useTranslation.js +5 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -28
- package/dist/init.js +30 -40
- package/dist/interface.js +1 -2
- package/dist/locales/en/addressList.js +1 -3
- package/dist/locales/index.js +4 -27
- package/dist/locales/lao/addressList.js +1 -3
- package/dist/locales/zh/addressList.js +1 -3
- package/dist/pages/address-list/AddressList.js +33 -61
- package/dist/pages/address-list/CardInfo.js +10 -18
- package/dist/pages/address-list/ChooseContact.js +50 -78
- package/dist/pages/address-list/Icons.js +7 -14
- package/dist/pages/address-list/Organization.js +59 -89
- package/dist/pages/address-list/UserDetail.js +55 -83
- package/dist/pages/address-list/UserJobs.js +31 -33
- package/dist/pages/address-list/UserSearch.js +29 -54
- package/dist/pages/address-list/addressList.routes.js +11 -16
- package/dist/pages/collection/Collection.js +53 -81
- package/dist/pages/collection/ContentFactory.js +53 -82
- package/dist/pages/collection/collection.routes.js +3 -9
- package/dist/pages/conversation/ForwardToConversation.js +63 -91
- package/dist/pages/conversation/List.js +74 -102
- package/dist/pages/conversation/components/ConversationCard.js +46 -74
- package/dist/pages/conversation/components/ConversationOption.js +27 -55
- package/dist/pages/conversation/conversation.routes.js +17 -23
- package/dist/pages/conversation/setting/GroupTransfer.js +32 -60
- package/dist/pages/conversation/setting/OptionAvatars.js +62 -90
- package/dist/pages/conversation/setting/OptionCancelGroup.js +14 -42
- package/dist/pages/conversation/setting/OptionConversation.js +20 -48
- package/dist/pages/conversation/setting/OptionGroup.js +20 -48
- package/dist/pages/conversation/setting/OptionGroupManage.js +21 -49
- package/dist/pages/conversation/setting/OptionGroupMoreMember.js +48 -53
- package/dist/pages/conversation/setting/OptionGroupNameOrNoticeEdit.js +49 -77
- package/dist/pages/conversation/setting/Setting.js +49 -54
- package/dist/pages/conversation/setting/SettingChatBg.js +26 -54
- package/dist/pages/index.js +7 -27
- package/dist/pages/message/ChooseMember.js +56 -84
- package/dist/pages/message/MessageBackup/Bar.js +18 -43
- package/dist/pages/message/MessageBackup/MessageBackup.js +42 -72
- package/dist/pages/message/MessageBackup/RestoreBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/StartBackupPage.js +48 -76
- package/dist/pages/message/MessageBackup/index.js +3 -12
- package/dist/pages/message/MessageBackup/utils.js +14 -22
- package/dist/pages/message/MessageList.js +141 -135
- package/dist/pages/message/MessageRecord.js +49 -73
- package/dist/pages/message/components/BusiNotifyCard.js +60 -85
- package/dist/pages/message/components/ChatBg.js +11 -36
- package/dist/pages/message/components/MessageItem.js +82 -110
- package/dist/pages/message/components/MessageItemQuote.js +30 -58
- package/dist/pages/message/components/MessageItemTips.js +27 -55
- package/dist/pages/message/components/MessageOption.js +96 -120
- package/dist/pages/message/components/MessagePayload.js +36 -64
- package/dist/pages/message/components/MessagePictureAlbum.js +32 -60
- package/dist/pages/message/components/MessageReceiptStatus.js +18 -43
- package/dist/pages/message/components/MessageUndo.js +18 -48
- package/dist/pages/message/components/MultipleBar/index.js +48 -76
- package/dist/pages/message/components/Payload/PayloadContact.js +30 -58
- package/dist/pages/message/components/Payload/PayloadFile.js +41 -65
- package/dist/pages/message/components/Payload/PayloadMultiple.js +38 -66
- package/dist/pages/message/components/Payload/PayloadNotify.js +28 -56
- package/dist/pages/message/components/Payload/PayloadPicture.js +21 -49
- package/dist/pages/message/components/Payload/PayloadShare.js +39 -67
- package/dist/pages/message/components/Payload/PayloadText.js +39 -67
- package/dist/pages/message/components/Payload/PayloadVideo.js +28 -56
- package/dist/pages/message/components/Payload/PayloadVoice.js +80 -93
- package/dist/pages/message/components/Payload/PayloadWrapper.js +18 -43
- package/dist/pages/message/components/Payload/type.js +1 -2
- package/dist/pages/message/components/ReceiptBack.js +31 -61
- package/dist/pages/message/components/TextMixMessage.js +13 -38
- package/dist/pages/message/components/TextMixQuote.js +129 -158
- package/dist/pages/message/components/TextMixQuoteMessage.js +16 -44
- package/dist/pages/message/components/UploadProgress.js +12 -37
- package/dist/pages/message/components/messageBar/EmojiPanel.js +25 -50
- package/dist/pages/message/components/messageBar/Icons.js +56 -74
- package/dist/pages/message/components/messageBar/MessageBar.js +84 -115
- package/dist/pages/message/components/messageBar/MessageInput.js +30 -55
- package/dist/pages/message/components/messageBar/OptionPanel.js +54 -82
- package/dist/pages/message/components/messageBar/VoiceBar.js +122 -100
- package/dist/pages/message/components/messageBar/index.js +2 -23
- package/dist/pages/message/message.routes.js +11 -40
- package/dist/pages/search/Search.js +38 -66
- package/dist/pages/search/SearchChatRecords.js +64 -92
- package/dist/pages/search/SearchFile.js +68 -96
- package/dist/pages/search/SearchManager.js +60 -65
- package/dist/pages/search/SearchPicturePage.js +16 -44
- package/dist/pages/search/components/ChatRecords.js +46 -74
- package/dist/pages/search/components/MyGroupChat.js +41 -69
- package/dist/pages/search/components/PictureMulipleBar.js +35 -63
- package/dist/pages/search/components/SearchFileList.js +59 -64
- package/dist/pages/search/components/SearchPictures.js +68 -98
- package/dist/pages/search/components/SearchShareLinkList.js +50 -55
- package/dist/pages/search/components/SearchUser.js +25 -53
- package/dist/pages/search/components/useSearchMessage.js +12 -16
- package/dist/pages/search/search.routes.js +11 -17
- package/dist/pages/search/utils.js +4 -12
- package/dist/pages/types.js +1 -2
- package/dist/slice/contact/contact.action.js +1 -2
- package/dist/slice/contact/contact.slice.js +4 -8
- package/dist/slice/index.js +7 -13
- package/dist/slice/panel/panel.slice.d.ts +2 -1
- package/dist/slice/panel/panel.slice.js +8 -7
- package/dist/slice/video/video.action.d.ts +1 -0
- package/dist/slice/video/video.action.js +56 -38
- package/dist/slice/video/video.slice.d.ts +1 -1
- package/dist/slice/video/video.slice.js +7 -8
- package/dist/utils/audio.d.ts +3 -0
- package/dist/utils/audio.js +10 -0
- package/dist/utils/color.js +2 -9
- package/dist/utils/common-action-sheet.js +9 -14
- package/dist/utils/cookie.js +6 -14
- package/dist/utils/emoji.js +9 -12
- package/dist/utils/file-icon.js +33 -60
- package/dist/utils/file-operate.js +1 -2
- package/dist/utils/file.d.ts +1 -1
- package/dist/utils/file.js +74 -87
- package/dist/utils/golden-rectangle.js +3 -7
- package/dist/utils/phone.js +13 -22
- package/dist/utils/request.js +7 -15
- package/dist/utils/scroll.js +5 -9
- package/dist/utils/summary.js +4 -11
- package/dist/utils/take-camera.js +12 -19
- package/dist/utils/text-mix.js +4 -11
- package/dist/utils/upload.js +20 -41
- package/package.json +6 -7
package/dist/utils/file-icon.js
CHANGED
@@ -1,80 +1,53 @@
|
|
1
|
-
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.findSvgIcon = void 0;
|
27
|
-
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
1
|
+
import Svg, { Path } from "react-native-svg";
|
28
2
|
const fileTypeIcons = [
|
29
3
|
{
|
30
4
|
suffixes: ['zip', 'rar', 'tar'],
|
31
|
-
svg: ({ style }) => (<
|
32
|
-
<
|
33
|
-
<
|
34
|
-
<
|
35
|
-
</
|
5
|
+
svg: ({ style }) => (<Svg viewBox={'0 0 1024 1024'} width="48" height="48" style={style}>
|
6
|
+
<Path d="M748 183.5V0H96v1024h836V183.5z" fill="#DBB375"/>
|
7
|
+
<Path d="M932 184H748V0" fill="#FFD597"/>
|
8
|
+
<Path d="M223 0h96v96h-96zM319 96h96v96h-96zM223 192h96v96h-96zM319 288h96v96h-96zM223 384h96v96h-96zM319 480h96v96h-96z" fill="#FFFFFF"/>
|
9
|
+
</Svg>),
|
36
10
|
},
|
37
11
|
{
|
38
12
|
suffixes: ['doc', 'docx', 'wps'],
|
39
|
-
svg: ({ style }) => (<
|
40
|
-
<
|
41
|
-
<
|
42
|
-
<
|
43
|
-
</
|
13
|
+
svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
|
14
|
+
<Path d="M745 186V3H93v1021h836V186z" fill="#6CA2FF"/>
|
15
|
+
<Path d="M929 186H745V3" fill="#A2CBFC"/>
|
16
|
+
<Path d="M490.4 344.2H542l65.2 227.3L651 344.2h66.1L638.5 685H578l-60.5-238.1L454.3 685h-60.5l-78.5-340.8h66.1l43.8 227.3 65.2-227.3z" fill="#FCFCFC"/>
|
17
|
+
</Svg>),
|
44
18
|
},
|
45
19
|
{
|
46
20
|
suffixes: ['xls', 'xlsx', 'csv'],
|
47
|
-
svg: ({ style }) => (<
|
48
|
-
<
|
49
|
-
<
|
50
|
-
<
|
51
|
-
</
|
21
|
+
svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
|
22
|
+
<Path d="M745 184.3V1H93v1022.5h836V184.3z" fill="#72DCA2"/>
|
23
|
+
<Path d="M928.8 184h-184V0.8" fill="#A9FFCE"/>
|
24
|
+
<Path d="M500.8 476.2l76.6-131h67.7L532.5 537.9 445.7 686H378l122.8-209.8z m-0.7 70.3l-6.6-11-112.7-190.3h67.7L525 474.4l8.9 15.2L650.3 686h-67.7l-82.5-139.5z" fill="#FCFCFC"/>
|
25
|
+
</Svg>),
|
52
26
|
},
|
53
27
|
{
|
54
28
|
suffixes: ['ppt', 'pptx'],
|
55
|
-
svg: ({ style }) => (<
|
56
|
-
<
|
57
|
-
<
|
58
|
-
<
|
59
|
-
</
|
29
|
+
svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
|
30
|
+
<Path d="M745 186V3H93v1021h836V186z" fill="#FF8278"/>
|
31
|
+
<Path d="M929 186H745V2.7" fill="#FFB7B3"/>
|
32
|
+
<Path d="M390.5 341.2h64.2V682h-64.2V341.2z m29.3 146.7h109c7.7 0 14.4-1.8 20.3-5.3s10.4-8.5 13.7-14.9 4.9-13.7 4.9-22c0-8.4-1.6-15.9-4.8-22.4s-7.7-11.5-13.6-15-12.7-5.3-20.5-5.3h-109v-61.9h107.3c21.2 0 40 4.3 56.1 13s28.7 20.9 37.6 36.7c8.9 15.8 13.4 34.1 13.4 54.8 0 20.8-4.5 39-13.4 54.7s-21.4 27.9-37.6 36.4c-16.2 8.6-34.9 12.9-56.1 12.9H419.8v-61.7z" fill="#FFFFFF"/>
|
33
|
+
</Svg>),
|
60
34
|
},
|
61
35
|
{
|
62
36
|
suffixes: ['pdf'],
|
63
|
-
svg: ({ style }) => (<
|
64
|
-
<
|
65
|
-
<
|
66
|
-
<
|
67
|
-
</
|
37
|
+
svg: ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
|
38
|
+
<Path d="M748 183.5V0H96v1024h836V183.5z" fill="#FF5562"/>
|
39
|
+
<Path d="M932 184H748V0" fill="#FF9292"/>
|
40
|
+
<Path d="M657.9 606.1c-29.4-1.9-57.4-12.9-79.9-31.3-44.2 9.4-86.3 22.9-128.4 39.6-33.5 57.4-64.8 86.6-91.8 86.6-5.4 0-11.9-1-16.2-4.2-11.3-5.1-18.5-16.1-18.3-28.2 0-9.4 2.1-35.5 104.7-78.2 23.3-41.3 42.4-84.6 57.2-129.4-12.9-25-41-86.6-21.6-117.9 6.5-11.5 19.4-17.7 33.5-16.7 11 0.1 21.4 5.1 28.1 13.6 14 18.8 12.9 58.4-5.4 116.8 17.3 31.3 39.9 59.5 66.9 83.5 22.7-4.2 45.3-7.3 68-7.3 50.7 1 58.3 24 57.2 37.5 0 35.6-35.7 35.6-54 35.6z m-302.2 64.6l3.2-1c15.1-5.2 27-15.6 35.6-29.2-16.2 6.3-29.1 16.6-38.8 30.2z m143.5-312.9H496c-1.1 0-3.3 0-4.3 1-4.3 17.7-1.1 36.5 6.5 53.2 6.2-17.5 6.6-36.5 1-54.2z m7.6 151.2l-1.1 2.1-1.1-1.1c-9.7 24-20.5 48-32.4 70.9l2.1-1v2.1c24-8.4 48.5-15.3 73.4-20.9l-1-1h3.3c-16.2-15.5-30.7-32.6-43.2-51.1z m146.8 55.3c-9.7 0-18.3 0-28 2.1 10.8 5.2 21.6 7.3 32.4 8.3 7.6 1 15.1 0 21.6-2.1-0.1-3-4.4-8.3-26-8.3z" fill="#FFFFFF"/>
|
41
|
+
</Svg>),
|
68
42
|
},
|
69
43
|
];
|
70
|
-
const unknownSvgIcon = ({ style }) => (<
|
71
|
-
<
|
72
|
-
<
|
73
|
-
<
|
74
|
-
<
|
75
|
-
</
|
76
|
-
const findSvgIcon = (suffix) => {
|
44
|
+
const unknownSvgIcon = ({ style }) => (<Svg viewBox="0 0 1024 1024" width="48" height="48" style={style}>
|
45
|
+
<Path d="m945.85,927.48a54.07,48.76 0 0 1 -54.07,48.76l-757.05,0a54.07,48.76 0 0 1 -54.07,-48.76l0,-877.72a54.07,48.76 0 0 1 54.07,-48.76l463.96,0a54.07,48.76 0 0 1 38.39,14.14l293.08,263.8a54.07,48.76 0 0 1 15.68,34.62l0,613.92z" fill="#EBECF0" id="svg_1"/>
|
46
|
+
<Path d="m936.85,912.48l0,48.76a53.26,48.76 0 0 1 -53.26,48.76l-745.67,0a53.26,48.76 0 0 1 -53.26,-48.76l0,-48.76a53.26,48.76 0 0 0 53.26,48.76l745.67,0a53.26,48.76 0 0 0 53.26,-48.76z" fill="#ebecf0" id="svg_2"/>
|
47
|
+
<Path d="m476.65,659.75l71.68,0l0,71.68l-71.68,0l0,-71.68zm35.11,-367.18a142.87,142.87 0 0 0 -142.88,142.87l71.68,0a71.68,71.68 0 0 1 142.88,0c0,71.68 -106.79,62.91 -106.79,178.96l71.19,0c0,-80.46 106.79,-89.23 106.79,-178.96a142.87,142.87 0 0 0 -142.87,-142.87z" data-spm-anchor-id="a313x.search_index.0.i12.79b93a81n6ELU2" fill="#5E6C84" id="svg_3"/>
|
48
|
+
<Path d="m944.85,312.65l0,6.74l-274.77,0a50.79,48.15 0 0 1 -50.79,-48.15l0,-267.24a50.79,48.15 0 0 1 36.06,13.96l275.28,260.5a50.79,48.15 0 0 1 14.22,34.19z" fill="#C1C7D0" id="svg_4" transform="matrix(1 0 0 1 0 0)"/>
|
49
|
+
</Svg>);
|
50
|
+
export const findSvgIcon = (suffix) => {
|
77
51
|
const icon = fileTypeIcons.find(item => item.suffixes.includes(suffix));
|
78
52
|
return (icon === null || icon === void 0 ? void 0 : icon.svg) || unknownSvgIcon;
|
79
53
|
};
|
80
|
-
exports.findSvgIcon = findSvgIcon;
|
package/dist/utils/file.d.ts
CHANGED
@@ -16,7 +16,7 @@ export declare const numberToFileSize: (number: number) => string;
|
|
16
16
|
export declare const moveFile: (filePath: string, filename: string, resourceType: ResourceDir) => Promise<string>;
|
17
17
|
export declare const copyFile: (localPath: string, filename: string, resourceType?: ResourceDir) => Promise<string>;
|
18
18
|
export declare const getSuffix: (filename: string) => string;
|
19
|
-
export declare const download: ({ fileId, fileSize, resourceType, filename, onProgress }: IDownloadOptions) => Promise<string>;
|
19
|
+
export declare const download: ({ fileId, fileSize, resourceType, filename, onProgress, onStart }: IDownloadOptions) => Promise<string>;
|
20
20
|
export declare function saveToAlbum(imManager: ImManager, localPath: string, showTips?: boolean): Promise<boolean>;
|
21
21
|
export declare function requestSaveFilePermissionIfAndroid(imManager: ImManager): Promise<boolean>;
|
22
22
|
export declare function getExtensionFromMime(mime: string): string;
|
package/dist/utils/file.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,18 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
8
|
});
|
10
9
|
};
|
11
|
-
|
12
|
-
|
13
|
-
};
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const
|
19
|
-
const file_1 = require("../api/file");
|
20
|
-
const react_native_compressor_1 = require("react-native-compressor");
|
21
|
-
const react_native_1 = require("react-native");
|
22
|
-
const documentPath = react_native_fs_1.default.DocumentDirectoryPath;
|
10
|
+
import RNFS from 'react-native-fs';
|
11
|
+
import { CameraRoll } from '@react-native-camera-roll/camera-roll';
|
12
|
+
import { getCookieString } from './cookie';
|
13
|
+
import { getDownloadUrl } from '../api/file';
|
14
|
+
import { uuidv4 } from 'react-native-compressor';
|
15
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
16
|
+
import { throttle } from "lodash-es";
|
17
|
+
const documentPath = RNFS.DocumentDirectoryPath;
|
23
18
|
const resourceDirBase = {
|
24
19
|
avatars: '/avatars',
|
25
20
|
voice: '/voice',
|
@@ -30,24 +25,22 @@ const resourceDirBase = {
|
|
30
25
|
};
|
31
26
|
const resourceDir = {};
|
32
27
|
let userPath = '';
|
33
|
-
function initDir(user) {
|
28
|
+
export function initDir(user) {
|
34
29
|
return __awaiter(this, void 0, void 0, function* () {
|
35
30
|
userPath = documentPath + '/' + user.userId;
|
36
31
|
const tasks = Object.keys(resourceDirBase).reduce((task, currentValue) => {
|
37
32
|
resourceDir[currentValue] = '/' + user.userId + resourceDirBase[currentValue];
|
38
|
-
task.push(
|
33
|
+
task.push(RNFS.mkdir(documentPath + resourceDir[currentValue]));
|
39
34
|
return task;
|
40
35
|
}, []);
|
41
36
|
yield Promise.all(tasks);
|
42
37
|
console.log('initDir success');
|
43
38
|
});
|
44
39
|
}
|
45
|
-
|
46
|
-
|
47
|
-
return `${userPath}/${resourceDirBase[resourceType]}/${fileName}`;
|
40
|
+
export const getResourcePath = (fileName, resourceType) => {
|
41
|
+
return `${userPath}${resourceDirBase[resourceType]}/${fileName}`;
|
48
42
|
};
|
49
|
-
|
50
|
-
function toAbsolutePath(filePath) {
|
43
|
+
export function toAbsolutePath(filePath) {
|
51
44
|
if (filePath.startsWith('Documents')) {
|
52
45
|
return filePath;
|
53
46
|
}
|
@@ -56,15 +49,13 @@ function toAbsolutePath(filePath) {
|
|
56
49
|
}
|
57
50
|
return 'file://' + filePath;
|
58
51
|
}
|
59
|
-
|
60
|
-
function toRelativePath(filePath) {
|
52
|
+
export function toRelativePath(filePath) {
|
61
53
|
if (filePath.startsWith(documentPath)) {
|
62
54
|
return filePath.slice(documentPath.length);
|
63
55
|
}
|
64
56
|
return filePath;
|
65
57
|
}
|
66
|
-
|
67
|
-
const numberToFileSize = (number) => {
|
58
|
+
export const numberToFileSize = (number) => {
|
68
59
|
let size = Number(number);
|
69
60
|
const unit = ['B', 'KB', 'MB', 'GB', 'TB'];
|
70
61
|
let count = 0;
|
@@ -74,78 +65,77 @@ const numberToFileSize = (number) => {
|
|
74
65
|
}
|
75
66
|
return size.toFixed(2) + unit[count];
|
76
67
|
};
|
77
|
-
|
78
|
-
const moveFile = (filePath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
|
68
|
+
export const moveFile = (filePath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
|
79
69
|
const relativePath = resourceDir[resourceType] + "/" + filename;
|
80
70
|
const destPath = documentPath + relativePath;
|
81
|
-
if (yield
|
71
|
+
if (yield RNFS.exists(destPath)) {
|
82
72
|
return destPath;
|
83
73
|
}
|
84
|
-
yield
|
74
|
+
yield RNFS.moveFile(filePath, destPath);
|
85
75
|
return destPath;
|
86
76
|
});
|
87
|
-
|
88
|
-
|
89
|
-
let destPath = documentPath + '/' + (0, react_native_compressor_1.uuidv4)() + (0, exports.getSuffix)(filename);
|
77
|
+
export const copyFile = (localPath, filename, resourceType) => __awaiter(void 0, void 0, void 0, function* () {
|
78
|
+
let destPath = documentPath + '/' + uuidv4() + getSuffix(filename);
|
90
79
|
if (resourceType) {
|
91
80
|
destPath = documentPath + resourceDir[resourceType] + "/" + filename;
|
92
81
|
}
|
93
|
-
yield
|
82
|
+
yield RNFS.copyFile(localPath, destPath);
|
94
83
|
return destPath;
|
95
84
|
});
|
96
|
-
|
97
|
-
const getSuffix = (filename) => {
|
85
|
+
export const getSuffix = (filename) => {
|
98
86
|
const index = filename.lastIndexOf('.');
|
99
87
|
return filename.substring(index);
|
100
88
|
};
|
101
|
-
|
102
|
-
const
|
103
|
-
const
|
104
|
-
const fileUrl = (0, file_1.getDownloadUrl)(fileId);
|
89
|
+
export const download = ({ fileId, fileSize, resourceType, filename, onProgress, onStart }) => __awaiter(void 0, void 0, void 0, function* () {
|
90
|
+
const cookie = yield getCookieString();
|
91
|
+
const fileUrl = getDownloadUrl(fileId);
|
105
92
|
console.log('download url: ', fileUrl);
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
try {
|
122
|
-
yield promise;
|
123
|
-
console.log('下载完成');
|
124
|
-
return destPath;
|
125
|
-
}
|
126
|
-
catch (error) {
|
127
|
-
console.error('下载失败:', error);
|
128
|
-
throw error;
|
93
|
+
const throttledFn = throttle((o) => {
|
94
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(o);
|
95
|
+
}, 500);
|
96
|
+
// if (Platform.OS === 'android') {
|
97
|
+
const destPath = RNFS.DocumentDirectoryPath + resourceDir[resourceType] + '/' + fileId + getSuffix(filename);
|
98
|
+
const { jobId, promise } = RNFS.downloadFile({
|
99
|
+
fromUrl: fileUrl,
|
100
|
+
toFile: destPath,
|
101
|
+
headers: {
|
102
|
+
'Cookie': cookie,
|
103
|
+
},
|
104
|
+
background: true,
|
105
|
+
progress: (e) => {
|
106
|
+
// console.log('download progress: ', e);
|
107
|
+
throttledFn({ loaded: e.bytesWritten, total: e.contentLength });
|
129
108
|
}
|
109
|
+
});
|
110
|
+
onStart === null || onStart === void 0 ? void 0 : onStart(() => {
|
111
|
+
RNFS.stopDownload(jobId);
|
112
|
+
});
|
113
|
+
try {
|
114
|
+
yield promise;
|
115
|
+
console.log('下载完成');
|
116
|
+
return destPath;
|
130
117
|
}
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
});
|
135
|
-
if (resp.status !== 200) {
|
136
|
-
console.error('下载失败:', resp.status);
|
137
|
-
throw new Error('下载失败');
|
138
|
-
}
|
139
|
-
const contentLength = resp.headers.get('Content-Length') || fileSize;
|
140
|
-
const result = yield (0, react_native_compressor_1.download)(fileUrl, (progress) => {
|
141
|
-
// console.log('download progress: ', progress);
|
142
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress({ loaded: progress * Number(contentLength), total: Number(contentLength) });
|
143
|
-
});
|
144
|
-
return yield (0, exports.moveFile)(result, filename, resourceType);
|
118
|
+
catch (error) {
|
119
|
+
console.error('下载失败:', error);
|
120
|
+
throw error;
|
145
121
|
}
|
122
|
+
// } else {
|
123
|
+
// const resp = await fetch(fileUrl, {
|
124
|
+
// method: 'HEAD',
|
125
|
+
// })
|
126
|
+
// if (resp.status !== 200) {
|
127
|
+
// console.error('下载失败:', resp.status);
|
128
|
+
// throw new Error('下载失败');
|
129
|
+
// }
|
130
|
+
// const contentLength = resp.headers.get('Content-Length') || fileSize;
|
131
|
+
// const result = await CompressDownload(fileUrl, (progress) => {
|
132
|
+
// // console.log('download progress: ', progress);
|
133
|
+
// throttledFn({loaded: progress * Number(contentLength), total: Number(contentLength)});
|
134
|
+
// })
|
135
|
+
// return await moveFile(result, filename, resourceType)
|
136
|
+
// }
|
146
137
|
});
|
147
|
-
|
148
|
-
function saveToAlbum(imManager, localPath, showTips = true) {
|
138
|
+
export function saveToAlbum(imManager, localPath, showTips = true) {
|
149
139
|
var _a, _b;
|
150
140
|
return __awaiter(this, void 0, void 0, function* () {
|
151
141
|
const absolutePath = toAbsolutePath(localPath);
|
@@ -154,7 +144,7 @@ function saveToAlbum(imManager, localPath, showTips = true) {
|
|
154
144
|
if (!success) {
|
155
145
|
return false;
|
156
146
|
}
|
157
|
-
yield
|
147
|
+
yield CameraRoll.saveToCameraRoll(absolutePath);
|
158
148
|
showTips && ((_a = imManager.toast) === null || _a === void 0 ? void 0 : _a.call(imManager, imManager.t('saved'), 'success'));
|
159
149
|
}
|
160
150
|
catch (e) {
|
@@ -165,12 +155,11 @@ function saveToAlbum(imManager, localPath, showTips = true) {
|
|
165
155
|
return true;
|
166
156
|
});
|
167
157
|
}
|
168
|
-
|
169
|
-
function requestSaveFilePermissionIfAndroid(imManager) {
|
158
|
+
export function requestSaveFilePermissionIfAndroid(imManager) {
|
170
159
|
var _a;
|
171
160
|
return __awaiter(this, void 0, void 0, function* () {
|
172
|
-
if (
|
173
|
-
let granted = yield
|
161
|
+
if (Platform.OS === 'android') {
|
162
|
+
let granted = yield PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
|
174
163
|
if (!granted) {
|
175
164
|
let granted = yield requestSaveFilePermission();
|
176
165
|
console.log('requestSaveFilePermissionIfAndroid: ', granted);
|
@@ -183,12 +172,11 @@ function requestSaveFilePermissionIfAndroid(imManager) {
|
|
183
172
|
return true;
|
184
173
|
});
|
185
174
|
}
|
186
|
-
exports.requestSaveFilePermissionIfAndroid = requestSaveFilePermissionIfAndroid;
|
187
175
|
function requestSaveFilePermission() {
|
188
|
-
return
|
176
|
+
return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
|
189
177
|
}
|
190
178
|
function requestReadFilePermission() {
|
191
|
-
return
|
179
|
+
return PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
|
192
180
|
}
|
193
181
|
// 获取主流的文件扩展名
|
194
182
|
const extensions = {
|
@@ -254,7 +242,6 @@ const extensions = {
|
|
254
242
|
'application/vnd.android.package-archive': '.apk',
|
255
243
|
'application/x-apk': '.apk',
|
256
244
|
};
|
257
|
-
function getExtensionFromMime(mime) {
|
245
|
+
export function getExtensionFromMime(mime) {
|
258
246
|
return extensions[mime] || '';
|
259
247
|
}
|
260
|
-
exports.getExtensionFromMime = getExtensionFromMime;
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.calculate = void 0;
|
4
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
5
|
-
const imageMaxSizeDefault = (0, rn_ui_1.dp)(200);
|
1
|
+
import { dp } from '@smart-link/rn-ui';
|
2
|
+
const imageMaxSizeDefault = dp(200);
|
6
3
|
const goldRate = 0.618;
|
7
|
-
function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
|
4
|
+
export function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
|
8
5
|
let sizeStyle;
|
9
6
|
if (height > width) {
|
10
7
|
let rate = goldRate;
|
@@ -31,4 +28,3 @@ function calculate(height, width, imageMaxSize = imageMaxSizeDefault) {
|
|
31
28
|
}
|
32
29
|
return sizeStyle;
|
33
30
|
}
|
34
|
-
exports.calculate = calculate;
|
package/dist/utils/phone.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,42 +7,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
8
|
});
|
10
9
|
};
|
11
|
-
|
12
|
-
|
10
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
11
|
+
import { Linking, PermissionsAndroid, Platform } from 'react-native';
|
12
|
+
import Contacts from 'react-native-contacts';
|
13
|
+
export const copyPhone = (phoneNum) => {
|
14
|
+
Clipboard.setString(phoneNum);
|
13
15
|
};
|
14
|
-
|
15
|
-
exports.addContacts = exports.callPhone = exports.copyPhone = void 0;
|
16
|
-
const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard"));
|
17
|
-
const react_native_1 = require("react-native");
|
18
|
-
const react_native_contacts_1 = __importDefault(require("react-native-contacts"));
|
19
|
-
const copyPhone = (phoneNum) => {
|
20
|
-
clipboard_1.default.setString(phoneNum);
|
21
|
-
};
|
22
|
-
exports.copyPhone = copyPhone;
|
23
|
-
const callPhone = (phoneNum) => {
|
16
|
+
export const callPhone = (phoneNum) => {
|
24
17
|
let tel = `tel:${phoneNum}`; //目标电话:'tel:1008611'
|
25
|
-
|
18
|
+
Linking.canOpenURL(tel).then((supported) => {
|
26
19
|
if (!supported) {
|
27
20
|
console.log('Can not handle tel:' + tel);
|
28
21
|
}
|
29
22
|
else {
|
30
|
-
return
|
23
|
+
return Linking.openURL(tel);
|
31
24
|
}
|
32
25
|
}).catch(error => console.log('tel error', error));
|
33
26
|
};
|
34
|
-
|
35
|
-
const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* () {
|
27
|
+
export const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* () {
|
36
28
|
const add = () => {
|
37
|
-
|
29
|
+
Contacts.openContactForm({
|
38
30
|
phoneNumbers: [{
|
39
31
|
label: 'mobile',
|
40
32
|
number: phoneNum
|
41
33
|
}]
|
42
34
|
});
|
43
35
|
};
|
44
|
-
if (
|
45
|
-
const granted = yield
|
46
|
-
if (granted ===
|
36
|
+
if (Platform.OS === 'android') {
|
37
|
+
const granted = yield PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS);
|
38
|
+
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
47
39
|
console.log('You can use the contacts');
|
48
40
|
add();
|
49
41
|
}
|
@@ -55,4 +47,3 @@ const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* ()
|
|
55
47
|
add();
|
56
48
|
}
|
57
49
|
});
|
58
|
-
exports.addContacts = addContacts;
|
package/dist/utils/request.js
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.createRequest = exports.getBaseURL = exports.Headers = void 0;
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
8
|
-
exports.Headers = {
|
1
|
+
import axios from 'axios';
|
2
|
+
export const Headers = {
|
9
3
|
json: {
|
10
4
|
'Content-Type': 'application/json;utf-8',
|
11
5
|
},
|
@@ -18,11 +12,10 @@ exports.Headers = {
|
|
18
12
|
};
|
19
13
|
let instance = null;
|
20
14
|
let baseURL = '';
|
21
|
-
const getBaseURL = () => baseURL;
|
22
|
-
|
23
|
-
const createRequest = (base) => {
|
15
|
+
export const getBaseURL = () => baseURL;
|
16
|
+
export const createRequest = (base) => {
|
24
17
|
baseURL = base;
|
25
|
-
instance =
|
18
|
+
instance = axios.create({
|
26
19
|
baseURL: base,
|
27
20
|
timeout: 10000,
|
28
21
|
headers: {
|
@@ -50,9 +43,8 @@ const createRequest = (base) => {
|
|
50
43
|
});
|
51
44
|
return instance;
|
52
45
|
};
|
53
|
-
exports.createRequest = createRequest;
|
54
46
|
const request = (url, data, method = 'post', contentType = 'json', config) => {
|
55
|
-
return instance.request(Object.assign(Object.assign({ url, data: contentType !== 'form' ? data : null, method, params: contentType === 'form' ? data : null }, config), { headers: Object.assign(Object.assign({},
|
47
|
+
return instance.request(Object.assign(Object.assign({ url, data: contentType !== 'form' ? data : null, method, params: contentType === 'form' ? data : null }, config), { headers: Object.assign(Object.assign({}, Headers[contentType]), config === null || config === void 0 ? void 0 : config.headers) }));
|
56
48
|
};
|
57
49
|
request.get = (url, data, config) => request(url, data, 'get', 'form', config);
|
58
50
|
request.post = (url, data, config) => {
|
@@ -64,4 +56,4 @@ request.postForm = (url, data, config) => {
|
|
64
56
|
request.postFile = (url, data, config) => {
|
65
57
|
return request(url, data, 'post', 'multipart', config);
|
66
58
|
};
|
67
|
-
|
59
|
+
export default request;
|
package/dist/utils/scroll.js
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const react_native_1 = require("react-native");
|
6
|
-
const scrollToBottom = (animated = true) => {
|
7
|
-
react_native_1.InteractionManager.runAfterInteractions(() => {
|
1
|
+
import { getImManager } from '../init';
|
2
|
+
import { InteractionManager } from 'react-native';
|
3
|
+
export const scrollToBottom = (animated = true) => {
|
4
|
+
InteractionManager.runAfterInteractions(() => {
|
8
5
|
var _a, _b, _c;
|
9
|
-
(_c = (_b = (_a =
|
6
|
+
(_c = (_b = (_a = getImManager()) === null || _a === void 0 ? void 0 : _a.flatListRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.scrollToOffset({ animated, offset: 0 });
|
10
7
|
});
|
11
8
|
};
|
12
|
-
exports.scrollToBottom = scrollToBottom;
|
package/dist/utils/summary.js
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getSummary = void 0;
|
7
|
-
const react_native_1 = require("react-native");
|
8
|
-
const react_1 = __importDefault(require("react"));
|
9
|
-
function getSummary(text, searchKey, summaryLength = 15, color = 'red') {
|
1
|
+
import { Text } from "react-native";
|
2
|
+
import React from 'react';
|
3
|
+
export function getSummary(text, searchKey, summaryLength = 15, color = 'red') {
|
10
4
|
if (!text) {
|
11
5
|
return;
|
12
6
|
}
|
@@ -35,8 +29,7 @@ function getSummary(text, searchKey, summaryLength = 15, color = 'red') {
|
|
35
29
|
else {
|
36
30
|
result.push(text.substring(0, index));
|
37
31
|
}
|
38
|
-
result.push(<
|
32
|
+
result.push(<Text key={result.length} style={{ color }}>{text.substr(index, searchLength)}</Text>);
|
39
33
|
result.push(text.substring(index + searchLength, textLength));
|
40
34
|
return result;
|
41
35
|
}
|
42
|
-
exports.getSummary = getSummary;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -8,29 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
8
|
});
|
10
9
|
};
|
11
|
-
|
12
|
-
|
13
|
-
};
|
14
|
-
|
15
|
-
exports.takeCamera = void 0;
|
16
|
-
const react_1 = __importDefault(require("react"));
|
17
|
-
const Camera_1 = __importDefault(require("../components/Camera/Camera"));
|
18
|
-
const rn_ui_1 = require("@smart-link/rn-ui");
|
19
|
-
const init_1 = require("../init");
|
10
|
+
import React from 'react';
|
11
|
+
import Camera from '../components/Camera/Camera';
|
12
|
+
import { TopViewGetInstance } from '@smart-link/rn-ui';
|
13
|
+
import { getImManager } from "../init";
|
20
14
|
let topKey = 0;
|
21
|
-
const takeCamera = (conversation) => __awaiter(void 0, void 0, void 0, function* () {
|
15
|
+
export const takeCamera = (conversation) => __awaiter(void 0, void 0, void 0, function* () {
|
22
16
|
return new Promise((resolve, reject) => {
|
23
|
-
|
24
|
-
.add(<
|
25
|
-
|
26
|
-
|
17
|
+
TopViewGetInstance()
|
18
|
+
.add(<Camera horizontal={false} finishTakePicture={(picData) => {
|
19
|
+
getImManager().sendPictureMessage(Object.assign({}, conversation), picData);
|
20
|
+
TopViewGetInstance().remove(topKey);
|
27
21
|
resolve();
|
28
22
|
}} finishTakeRecord={(videoData) => {
|
29
|
-
|
30
|
-
|
23
|
+
getImManager().sendVideoMessage(Object.assign({}, conversation), videoData);
|
24
|
+
TopViewGetInstance().remove(topKey);
|
31
25
|
resolve();
|
32
26
|
}} cancelCamera={() => {
|
33
|
-
|
27
|
+
TopViewGetInstance().remove(topKey);
|
34
28
|
reject('cancel');
|
35
29
|
}}/>)
|
36
30
|
.then(id => {
|
@@ -38,4 +32,3 @@ const takeCamera = (conversation) => __awaiter(void 0, void 0, void 0, function*
|
|
38
32
|
});
|
39
33
|
});
|
40
34
|
});
|
41
|
-
exports.takeCamera = takeCamera;
|