Skip to content

Commit fc0139c

Browse files
committed
utils 中提出 setRegion 方法
1 parent 2c81dd8 commit fc0139c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/utils.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ module.exports = function(AV) {
108108
AV._useMasterKey = false;
109109
};
110110

111+
const setRegion = (region) => {
112+
// 服务器地区选项,默认为中国大陆
113+
switch (region) {
114+
case 'cn':
115+
AVConfig.region = 'cn';
116+
break;
117+
case 'us':
118+
AVConfig.region = 'us';
119+
break;
120+
}
121+
};
122+
111123
/**
112124
* Call this method first to set up your authentication tokens for AV.
113125
* You can get your app keys from the LeanCloud dashboard on http://leancloud.cn .
@@ -127,13 +139,7 @@ module.exports = function(AV) {
127139
throw new Error('AV.init(): Master Key is only used in Node.js.');
128140
}
129141
initialize(options.appId, options.appKey, options.masterKey);
130-
131-
// 服务器地区选项,默认为中国大陆
132-
switch (options.region) {
133-
case 'us':
134-
AVConfig.region = 'us';
135-
break;
136-
}
142+
setRegion(options.region);
137143
} else {
138144
throw new Error('AV.init(): Parameter is not correct.');
139145
}

0 commit comments

Comments
 (0)