Skip to content

Commit 0f3fb6d

Browse files
committed
增加 AV._config 挂载通用配置信息。
1 parent 1a8dda1 commit 0f3fb6d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/utils.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ var _ = require('underscore');
77
require: false */
88
module.exports = function(AV) {
99

10-
var config = {
10+
// 挂载一些配置
11+
AV._config = AV._config || {};
12+
_.extend(AV._config, {
1113
cnApiUrl: 'https://api.leancloud.cn',
1214
usApiUrl: 'https://us-api.leancloud.cn'
13-
};
15+
});
1416

1517
/**
1618
* Contains all AV API classes and functions.
@@ -150,21 +152,21 @@ module.exports = function(AV) {
150152
};
151153
}
152154

153-
/**
154-
*Use china avoscloud API service:https://cn.avoscloud.com
155-
*/
155+
/**
156+
*Use china avoscloud API service
157+
*/
156158
AV.useAVCloudCN = function(){
157-
AV.serverURL = config.cnApiUrl;
159+
AV.serverURL = AV._config.cnApiUrl;
158160
};
159161

160162
/**
161-
*Use USA avoscloud API service:https://us.avoscloud.com
163+
*Use USA avoscloud API service
162164
*/
163165
AV.useAVCloudUS = function(){
164-
AV.serverURL = config.usApiUrl;
166+
AV.serverURL = AV._config.usApiUrl;
165167
};
166168

167-
169+
// 默认使用国内节点
168170
AV.useAVCloudCN();
169171

170172
/**

0 commit comments

Comments
 (0)