Skip to content

Commit 7c239a7

Browse files
authored
fix(init): remove disableCurrentUser assignment (#457)
1 parent 6e65f57 commit 7c239a7

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

src/init.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,24 @@ const masterKeyWarn = () => {
2929
*/
3030

3131
AV.init = (...args) => {
32-
switch (args.length) {
33-
case 1:
34-
const options = args[0];
35-
if (typeof options === 'object') {
36-
if (process.env.CLIENT_PLATFORM && options.masterKey) {
37-
masterKeyWarn();
38-
}
39-
initialize(options.appId, options.appKey, options.masterKey, options.hookKey);
40-
request.setServerUrlByRegion(options.region);
41-
AV._config.disableCurrentUser = options.disableCurrentUser;
42-
} else {
43-
throw new Error('AV.init(): Parameter is not correct.');
44-
}
45-
break;
46-
// 兼容旧版本的初始化方法
47-
case 2:
48-
case 3:
49-
console.warn('Please use AV.init() to replace AV.initialize(), ' +
50-
'AV.init() need an Object param, like { appId: \'YOUR_APP_ID\', appKey: \'YOUR_APP_KEY\' } . ' +
51-
'Docs: https://leancloud.cn/docs/sdk_setup-js.html');
52-
if (process.env.CLIENT_PLATFORM && args.length === 3) {
32+
if (args.length === 1) {
33+
const options = args[0];
34+
if (typeof options === 'object') {
35+
if (process.env.CLIENT_PLATFORM && options.masterKey) {
5336
masterKeyWarn();
5437
}
55-
initialize(...args);
56-
request.setServerUrlByRegion('cn');
57-
break;
38+
initialize(options.appId, options.appKey, options.masterKey, options.hookKey);
39+
request.setServerUrlByRegion(options.region);
40+
} else {
41+
throw new Error('AV.init(): Parameter is not correct.');
42+
}
43+
} else {
44+
// 兼容旧版本的初始化方法
45+
if (process.env.CLIENT_PLATFORM && args[3]) {
46+
masterKeyWarn();
47+
}
48+
initialize(...args);
49+
request.setServerUrlByRegion('cn');
5850
}
5951
};
6052

0 commit comments

Comments
 (0)