Skip to content

Commit 7098b3c

Browse files
committed
Put forward AV._request() & ajax() to request.js . (#283)
1 parent e690157 commit 7098b3c

File tree

10 files changed

+281
-270
lines changed

10 files changed

+281
-270
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module.exports = {
22
extends: 'airbnb',
33
rules: {
44
'no-param-reassign': 0,
5-
'no-underscore-dangle': 0
5+
'no-underscore-dangle': 0,
6+
'consistent-return': 0,
7+
'no-else-return': 0,
8+
'max-len': 0,
9+
'no-console': [ 2, { allow: ['warn'] } ],
10+
'no-restricted-syntax': [ 0, 'ForInStatement' ],
611
}
712
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ release.sh
66
coverage
77
*.swp
88
dist/js-sdk-api-docs
9+
npm-debug.log
10+
demo/test-es5.js

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html>
3-
<meta charset="UTF-8">
43
<head>
4+
<meta charset="UTF-8">
55
<title>LeanCloud JavaScript SDK</title>
66
<link rel="stylesheet" href="style.css">
77
</head>

demo/test-es5.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

demo/test-es6.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
/*
2+
请参考 README.md 中的开发方式,
3+
执行 gulp dev 该文件会被编译为 test-es5.js 并自动运行此文件
4+
*/
5+
6+
/* eslint no-console: ["error", { allow: ["log"] }] */
7+
/* eslint no-undef: ["error", { "AV": true }] */
8+
19
// 初始化
210
const appId = 'a5CDnmOX94uSth8foK9mjHfq-gzGzoHsz';
311
const appKey = 'Ue3h6la9zH0IxkUJmyhLjk9h';
12+
const AV = AV || {};
13+
414
AV.init({ appId, appKey });
515

616
// 基本存储
717
const TestClass = AV.Object.extend('TestClass');
818
const testObj = new TestClass();
919
testObj.set({
1020
name: 'hjiang',
11-
phone: '123123123'
21+
phone: '123123123',
1222
});
1323

1424
testObj.save().then(() => {
@@ -20,7 +30,7 @@ testObj.save().then(() => {
2030

2131
// 存储文件
2232
const base64 = 'd29ya2luZyBhdCBhdm9zY2xvdWQgaXMgZ3JlYXQh';
23-
var file = new AV.File('myfile.txt', { base64: base64 });
33+
const file = new AV.File('myfile.txt', { base64 });
2434
file.metaData('format', 'txt file');
2535
file.save().then((data) => {
2636
console.log(data);
@@ -34,4 +44,3 @@ query.equalTo('name', 'hjiang');
3444
query.find().then((list) => {
3545
console.log(list);
3646
});
37-

src/ajax.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/av.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
/*!
2-
* AVOSCloud JavaScript SDK
3-
* Built: Mon Jun 03 2013 13:45:00
2+
* LeanCloud JavaScript SDK
43
* https://leancloud.cn
54
*
6-
* Copyright 2015 LeanCloud.cn, Inc.
7-
* The AVOS Cloud JavaScript SDK is freely distributable under the MIT license.
5+
* Copyright 2016 LeanCloud.cn, Inc.
6+
* The LeanCloud JavaScript SDK is freely distributable under the MIT license.
87
*/
98

109
/**
1110
* 每位工程师都有保持代码优雅的义务
1211
* Each engineer has a duty to keep the code elegant
1312
**/
1413

15-
'use strict';
16-
17-
let AV = module.exports = {};
14+
const AV = module.exports = {};
1815
AV._ = require('underscore');
1916
AV.version = require('./version');
2017
AV.Promise = require('./promise');
2118
AV.localStorage = require('./localstorage');
2219
AV.Cache = require('./cache');
2320

24-
// 挂载所有内部配置项
21+
// All internal configuration items
2522
AV._config = AV._config || {};
2623

27-
// 以下模块为了兼容原有代码,使用这种加载方式。
2824
require('./utils').init(AV);
25+
require('./request').init(AV);
26+
2927
require('./error')(AV);
3028
require('./event')(AV);
3129
require('./geopoint')(AV);
@@ -42,6 +40,3 @@ require('./push')(AV);
4240
require('./status')(AV);
4341
require('./search')(AV);
4442
require('./insight')(AV);
45-
46-
// Backward compatibility
47-
AV.AV = AV;

0 commit comments

Comments
 (0)