Skip to content

Commit 935f259

Browse files
committed
Merge pull request #219 from wangxiao/master
JS SDK 2.0 基本构建和新的初始化方法。
2 parents 3f96d5d + 468aa9e commit 935f259

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+20922
-9121
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
]
5+
}

.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"node": true
2+
"node": true,
3+
"esnext": true
34
}

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ package/
44
tests/
55
tools/
66
demo/
7-
lib/cloud.js
7+
src/cloud.js
88
*.sh

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ JavaScript SDK for [LeanCloud](http://leancloud.cn/).
1212
## 贡献
1313

1414
* fork 这个项目
15-
* 在本地进行调试,`npm install` 安装相关依赖
16-
* 执行 `gulp browserify` 会生成浏览器 SDK
17-
* 执行 `gulp release` 会生成全部版本的 SDK
15+
* `npm install` 安装相关依赖
1816
* 服务环境通过 mocha 调试单个文件,如调试 file.js `mocha test file`
19-
* 浏览器环境打开 test/test.html
20-
* 确保测试全部通过 `gulp test`
17+
* 浏览器环境执行 `gulp dev`,会自动启动 demo 目录,可在 test-es6.js 中修改和测试,test-es5.js 为自动生成的代码
18+
* 确保测试全部通过 `gulp test`,浏览器环境打开 test/test.html
2119
* 提交并发起 Pull Request
20+
* 执行 `gulp release` 会生成全部版本的 SDK
2221

2322
项目的目录结构说明如下:
2423

@@ -27,12 +26,17 @@ JavaScript SDK for [LeanCloud](http://leancloud.cn/).
2726
├── bower.json
2827
├── changelog.md
2928
├── dist // 编译之后生成的文件将会在此目录下
29+
│ ├── av-es6.js // 合并后的完整源码(ES6 版本)
30+
│ ├── av-es5.js // 合并并编译后的完整源码(ES5 版本)
31+
│ ├── av-mini.js // 合并、压缩并编译后的源码(ES5 版本)
32+
│ ├── node // 目录中为生成的 nodejs 版本代码
33+
│ └── ...
3034
├── gulpfile.js
31-
├── lib
35+
├── src
3236
│ ├── av-browser.js // 浏览器环境入口文件,将会被 browserify 编译
3337
│ ├── av-browser-core.js // 浏览器环境入口文件,只包含核心依赖,将会被 browserify 编译
3438
│ ├── av.js // node.js 环境入口文件
35-
│ ├── browserify-wrapper // 针对 node.js 与浏览器环境之间差异的不同实现
39+
│ ├── browserify-wrapper // 目录中为针对 node.js 与浏览器环境之间差异的不同实现
3640
│ └── ...
3741
├── package.json
3842
├── readme.txt
@@ -44,7 +48,7 @@ JavaScript SDK for [LeanCloud](http://leancloud.cn/).
4448
## 官方新版本发布流程
4549

4650
* 修改版本号
47-
* lib/version.js
51+
* src/version.js
4852
* package.json
4953
* bower.json
5054
* 修改 Changelog

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"main": "dist/av.js",
1010
"ignore": [
1111
"demo",
12-
"lib",
12+
"src",
1313
"test",
1414
"tools",
1515
"README.md",

demo/Todo.zip

-252 KB
Binary file not shown.

demo/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>LeanCloud JavaScript SDK</title>
5+
<link rel="stylesheet" href="style.css">
6+
</head>
7+
<body>
8+
<h1>LeanCloud JavaScript SDK</h1>
9+
<p>打开控制台调试</p>
10+
<script src="../dist/av-es6.js"></script>
11+
<script src="../test-es5.js"></script>
12+
</body>
13+
</html>

demo/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
body {
2+
text-align: center;
3+
}
4+
5+
h1 {
6+
margin-top: 30%;
7+
font-size: 20px;
8+
}
9+

demo/test-es5.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
// 初始化
4+
var appId = 'a5CDnmOX94uSth8foK9mjHfq-gzGzoHsz';
5+
var appKey = 'Ue3h6la9zH0IxkUJmyhLjk9h';
6+
AV.init({
7+
appId: appId,
8+
appKey: appKey
9+
});
10+
// AV.initialize(appId, appKey);
11+
12+
var TestClass = AV.Object.extend('TestClass');
13+
var testObj = new TestClass();
14+
testObj.set({
15+
name: 'hjiang',
16+
phone: '123123123'
17+
});
18+
testObj.save().then(function () {
19+
console.log('success');
20+
}).catch(function (err) {
21+
console.log('failed');
22+
console.log(err);
23+
});

demo/test-es6.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// 初始化
2+
const appId = 'a5CDnmOX94uSth8foK9mjHfq-gzGzoHsz';
3+
const appKey = 'Ue3h6la9zH0IxkUJmyhLjk9h';
4+
AV.init({
5+
appId: appId,
6+
appKey: appKey
7+
});
8+
// AV.initialize(appId, appKey);
9+
10+
const TestClass = AV.Object.extend('TestClass');
11+
const testObj = new TestClass();
12+
testObj.set({
13+
name: 'hjiang',
14+
phone: '123123123'
15+
});
16+
testObj.save().then(() => {
17+
console.log('success');
18+
}).catch((err) => {
19+
console.log('failed');
20+
console.log(err);
21+
});

0 commit comments

Comments
 (0)