@@ -3,79 +3,87 @@ import { NativeModules,Platform, NetInfo } from 'react-native';
33
44const { RNNeteaseIm, PinYin } = NativeModules ;
55
6- class Utils {
6+ class Utils {
77 /**
88 * 清除数据缓存
99 */
10- cleanCache ( ) {
10+ cleanCache ( ) {
1111 return RNNeteaseIm . cleanCache ( ) ;
1212 }
1313
1414 /**
1515 * 获取缓存大小
1616 */
17- getCacheSize ( ) {
17+ getCacheSize ( ) {
1818 return RNNeteaseIm . getCacheSize ( ) ;
1919 }
2020
2121 /**
2222 * 获取网络状态
2323 */
24- networkIsConnected ( ) { //0:无网络,1:有网络
25- if ( Platform . OS === 'ios' ) {
26- if ( RNNeteaseIm . getNetWorkStatus ( ) === '1' ) {
27- return true ;
28- }
29- return false ;
30- } else {
24+ networkIsConnected ( ) { //0:无网络,1:有网络
25+ if ( Platform . OS === 'ios' ) {
26+ if ( RNNeteaseIm . getNetWorkStatus ( ) === '1' ) {
27+ return true ;
28+ }
29+ return false ;
30+ } else {
3131 return NetInfo . isConnected . fetch ( ) . done ( ) ;
3232 }
3333 }
34+
3435 /** ******************************播放 ****************************************** **/
3536
3637 /**
3738 * 播放录音
3839 * @returns {* }
3940 */
40- play ( filepath ) {
41+ play ( filepath ) {
4142 return RNNeteaseIm . play ( filepath ) ;
4243 }
44+
4345 /**
4446 * 播放本地资源音乐
4547 * name:iOS:文件名字,Android:文件路径
4648 * type:音乐类型,如:'mp3'
4749 * @returns {* }
4850 */
49- playLocacl ( name , type ) {
50- if ( Platform . OS === 'ios' ) {
51- return RNNeteaseIm . playLocal ( name , type ) ;
51+ playLocacl ( name , type ) {
52+ if ( Platform . OS === 'ios' ) {
53+ return RNNeteaseIm . playLocal ( name , type ) ;
5254 }
53- return RNNeteaseIm . playLocal ( 'assets:///' + name + '.' + type , type ) ;
55+ return RNNeteaseIm . playLocal ( 'assets:///' + name + '.' + type , type ) ;
5456 }
57+
5558 /**
5659 * 停止播放录音
5760 * @returns {* }
5861 */
59- stopPlay ( ) {
62+ stopPlay ( ) {
6063 return RNNeteaseIm . stopPlay ( ) ;
6164 }
62- sortPinYin ( o , key ) {
63- return PinYin . sortPinYin ( o , key ) ;
65+
66+ sortPinYin ( o , key ) {
67+ return PinYin . sortPinYin ( o , key ) ;
6468 }
6569
6670
67- fetchNetInfo ( ) {
71+ /**
72+ * 仅限Android
73+ * @returns {* }
74+ */
75+ fetchNetInfo ( ) {
6876 return RNNeteaseIm . fetchNetInfo ( ) ;
6977 }
70-
78+
7179 /**
80+ * 仅限IOS
7281 * 设置webview UA
7382 * @returns {* }
7483 */
75- setupWebViewUserAgent ( ) {
76- if ( Platform . OS === 'ios' ) {
77- RNNeteaseIm . setupWebViewUserAgent ( ) ;
78- }
84+ setupWebViewUserAgent ( ) {
85+ RNNeteaseIm . setupWebViewUserAgent ( ) ;
7986 }
87+ }
8088module . exports = new Utils ( ) ;
8189
0 commit comments