@norcy/react-native-toolkit 0.1.112 → 0.1.113
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/.DS_Store +0 -0
- package/README.md +1 -26
- package/cocoa_plugins/.DS_Store +0 -0
- package/cocoa_plugins/cocoapods-rn-toolkit/.DS_Store +0 -0
- package/{ios → cocoa_plugins/cocoapods-rn-toolkit/lib}/.DS_Store +0 -0
- package/{src → cocoa_plugins/cocoapods-rn-toolkit/lib/cocoapods-rn-toolkit}/.DS_Store +0 -0
- package/lib/commonjs/ConfigDataModel.js +19 -5
- package/lib/commonjs/ConfigDataModel.js.map +1 -1
- package/lib/commonjs/Tool.js +3 -1
- package/lib/commonjs/Tool.js.map +1 -1
- package/lib/module/ConfigDataModel.js +19 -5
- package/lib/module/ConfigDataModel.js.map +1 -1
- package/lib/module/Tool.js +3 -1
- package/lib/module/Tool.js.map +1 -1
- package/lib/typescript/ConfigDataModel.d.ts +1 -0
- package/lib/typescript/Tool.d.ts +1 -1
- package/package.json +1 -1
- package/src/ConfigDataModel.ts +19 -6
- package/src/Tool.ts +5 -3
- package/.vscode/settings.json +0 -9
- package/ios/ReactNativeToolkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/yarn-error.log +0 -11644
package/src/ConfigDataModel.ts
CHANGED
@@ -2,7 +2,7 @@ import { Object } from 'leancloud-storage';
|
|
2
2
|
import { Platform } from 'react-native';
|
3
3
|
import { getReadableVersion } from 'react-native-device-info';
|
4
4
|
import { DevConfig } from './DevConfig';
|
5
|
-
import { LoginResultDataType } from './LoginManager';
|
5
|
+
import { LoginManager, LoginResultDataType } from './LoginManager';
|
6
6
|
import { Notification } from './Notification';
|
7
7
|
import { BuildInPrefs } from './PrefData';
|
8
8
|
import { VipAndroidManager } from './VipAndroidManager';
|
@@ -85,9 +85,8 @@ const handleVersionInfo = () => {
|
|
85
85
|
|
86
86
|
let isDataReady = false;
|
87
87
|
let isNetwordDataReady = false;
|
88
|
-
let OnlineItems: Object[] = [];
|
89
88
|
|
90
|
-
const _handleResponse = () => {
|
89
|
+
const _handleResponse = (OnlineItems: Object[]) => {
|
91
90
|
if (!isNetwordDataReady) {
|
92
91
|
return;
|
93
92
|
}
|
@@ -103,6 +102,7 @@ const _handleResponse = () => {
|
|
103
102
|
ConfigDataModel.emitChange();
|
104
103
|
};
|
105
104
|
|
105
|
+
// ConfigDataModel 的 Config 是支持后台配置多条同一个 Key 的,按版本区分
|
106
106
|
const ConfigDataModel = {
|
107
107
|
init: (defaultValues: ConfigsType) => {
|
108
108
|
MyItems = defaultValues;
|
@@ -113,7 +113,6 @@ const ConfigDataModel = {
|
|
113
113
|
if (!isAuto && user && !error) {
|
114
114
|
isDataReady = false;
|
115
115
|
isNetwordDataReady = false;
|
116
|
-
OnlineItems = [];
|
117
116
|
ConfigDataModel.fetch();
|
118
117
|
}
|
119
118
|
}
|
@@ -135,8 +134,7 @@ const ConfigDataModel = {
|
|
135
134
|
.then((items: Object[]) => {
|
136
135
|
console.log('Config 抓取完毕');
|
137
136
|
isNetwordDataReady = true;
|
138
|
-
|
139
|
-
_handleResponse();
|
137
|
+
_handleResponse(items);
|
140
138
|
})
|
141
139
|
.catch((e: any) => {
|
142
140
|
console.error(e);
|
@@ -170,6 +168,21 @@ const ConfigDataModel = {
|
|
170
168
|
}
|
171
169
|
eventEmitter.on('change', callback);
|
172
170
|
},
|
171
|
+
|
172
|
+
shouldEnableByRate: (enable?: boolean, rate?: number) => {
|
173
|
+
if (!enable) {
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
// rate 不传,默认为全量
|
177
|
+
const r = rate ?? 1;
|
178
|
+
if (r <= 0) {
|
179
|
+
return false;
|
180
|
+
}
|
181
|
+
// ID 最后一位是 16 进制(0-f),未登录默认为全量
|
182
|
+
const lastChar =
|
183
|
+
LoginManager.currentUser()?.AVUser?.get('objectId')?.slice(-1) ?? '0';
|
184
|
+
return '0123456789abcdef'.indexOf(lastChar.toLowerCase()) < r * 16;
|
185
|
+
},
|
173
186
|
};
|
174
187
|
|
175
188
|
export { ConfigDataModel };
|
package/src/Tool.ts
CHANGED
@@ -73,7 +73,7 @@ const _jsonify = (target: any): any => {
|
|
73
73
|
return target;
|
74
74
|
};
|
75
75
|
|
76
|
-
const _getAlertDataFromConfig = (config
|
76
|
+
const _getAlertDataFromConfig = (config?: AlertConfig) => {
|
77
77
|
if (!config) {
|
78
78
|
return undefined;
|
79
79
|
}
|
@@ -220,10 +220,12 @@ export const Tool = {
|
|
220
220
|
},
|
221
221
|
|
222
222
|
showToast: (toast: string) => {
|
223
|
-
|
223
|
+
if (toast) {
|
224
|
+
Toast.showWithGravity(toast, Toast.SHORT, Toast.CENTER);
|
225
|
+
}
|
224
226
|
},
|
225
227
|
|
226
|
-
alertWithConfig: (config
|
228
|
+
alertWithConfig: (config?: AlertConfig) => {
|
227
229
|
const alertData = _getAlertDataFromConfig(config);
|
228
230
|
if (alertData) {
|
229
231
|
Alert.alert(alertData.title, alertData.message, alertData.buttons);
|
package/.vscode/settings.json
DELETED