Skip to content

Commit

Permalink
upgrade to 1.5.1 && added eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcaufy committed Mar 31, 2017
1 parent 914b014 commit 6b31669
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 193 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/*
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.wpy files
plugins: [
'html'
],
settings: {
'html/html-extensions': ['.html', '.wpy']
},
'globals': {
'wx': true
},
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
"semi": [
"error",
"always"
],
'comma-dangle': ["error", "only-multiline"],
'padded-blocks': 0,
'one-var': 0,
'no-return-assign': 0,
'indent': ['error', 4],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'space-before-function-paren': 0
}
}
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@
"author": "",
"license": "ISC",
"dependencies": {
"babel-plugin-syntax-export-extensions": "^6.13.0",
"babel-plugin-transform-export-extensions": "^6.8.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-1": "^6.16.0",
"wepy": "^1.4.7",
"wepy": "^1.5.1",
"wepy-async-function": "^1.4.4",
"wepy-com-toast": "^1.0.1"
},
"devDependencies": {
"wepy-compiler-babel": "0.0.3",
"wepy-compiler-sass": "0.0.3"
"babel-eslint": "^7.2.1",
"babel-plugin-syntax-export-extensions": "^6.13.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-1": "^6.22.0",
"cross-env": "^3.2.4",
"eslint": "^3.18.0",
"eslint-config-standard": "^7.1.0",
"eslint-friendly-formatter": "^2.0.7",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-standard": "^2.0.1",
"wepy-compiler-babel": "^1.5.1",
"wepy-compiler-less": "^1.3.10",
"wepy-compiler-sass": "0.0.3",
"wepy-eslint": "^1.5.2"
}
}
102 changes: 51 additions & 51 deletions src/app.wpy
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
<style type="sass">
page, .body{
height: 100%;
font-family: "\5FAE\8F6F\96C5\9ED1", arial;
}
</style>
<script>
import wepy from 'wepy';
import "wepy-async-function";
export default class extends wepy.app {
config = {
"pages":[
"pages/index",
"pages/chat"
],
"window":{
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#3b3a40",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
}
};
constructor () {
super();
this.use('promisify');
this.use('requestfix');
}
globalData = {
userInfo: null
};
onLaunch() {
}
async getUserInfo() {
if (this.globalData.userInfo) {
return this.globalData.userInfo;
}
let x = await wx.login();
let res = await wx.getUserInfo();
this.globalData.userInfo = res.userInfo;
return res.userInfo;
}
}
</script>
<style type='sass'>
page, .body{
height: 100%;
font-family: '\5FAE\8F6F\96C5\9ED1', arial;
}
</style>

<script>

import wepy from 'wepy';
import 'wepy-async-function';

export default class extends wepy.app {

config = {
'pages': [
'pages/index',
'pages/chat'
],
'window': {
'backgroundTextStyle': 'light',
'navigationBarBackgroundColor': '#3b3a40',
'navigationBarTitleText': 'WeChat',
'navigationBarTextStyle': 'black'
}
};

constructor () {
super();
this.use('promisify');
this.use('requestfix');
}

globalData = {
userInfo: null
};

onLaunch() {
}

async getUserInfo() {
if (this.globalData.userInfo) {
return this.globalData.userInfo;
}
await wx.login();
let res = await wx.getUserInfo();
this.globalData.userInfo = res.userInfo;
return res.userInfo;
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/alpha.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
export default class Message extends wepy.component {

data = {
tags: table
tags: table,
};

methods = {
Expand Down
5 changes: 2 additions & 3 deletions src/components/chartboard.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
let userinfo, message;
try {
userinfo = await api.getUserInfo();
} catch(e) {
} catch (e) {
console.log(e);
userinfo = {
nickName: 'Gcaufy',
id: 'gcaufy',
avatarUrl: '../images/myheader.png',
}
};
}
this.current = userinfo;
try {
Expand All @@ -121,7 +121,6 @@

async sendMessage (msg) {
let id = this.to;
let contact = global.getContact(id);
let msgObj = await api.sendMsg(id, msg);

msgObj.name = this.current.nickName;
Expand Down
38 changes: 21 additions & 17 deletions src/components/contact.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,34 @@
export default class Message extends wepy.component {

components = {
alpha: Alpha,
alpha: Alpha
};

data = {
toplist: [{
header: '../images/new_friend.png',
name: '新的朋友',
},{
header: '../images/group_chat.png',
name: '群聊',
},{
header: '../images/tag.png',
name: '标签',
},{
header: '../images/public.png',
name: '公众号',
},],
toplist: [
{
header: '../images/new_friend.png',
name: '新的朋友',
},
{
header: '../images/group_chat.png',
name: '群聊',
},
{
header: '../images/tag.png',
name: '标签',
},
{
header: '../images/public.png',
name: '公众号',
},
],
contacts: {},
total: 0,
};
methods = {
select (id, evt) {
//console.log(`${id} is selected`);
wx.navigateTo({url: 'chat?id=' + id});
this.$root.$navigate({url: 'chat?id=' + id});
}
};

Expand All @@ -153,7 +157,7 @@
}

format (arr) {
let obj = {}, c;
let c, obj = {};
arr.forEach((item) => {
c = item.id[0].toUpperCase();
if (obj[c]) {
Expand Down
11 changes: 5 additions & 6 deletions src/components/discovery.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@
<script>
import wepy from 'wepy';

//import List from './list';
import Group from './group';

export default class Message extends wepy.component {

components = {
/*moment: List,
/* moment: List,
action: List,
drift: List,
shopping: List,*/
group: Group,
shopping: List, */
group: Group
};
data = {
dMoment: [{icon: '../images/moment.png', title: '朋友圈'}],
Expand All @@ -54,7 +53,7 @@
dMoment: [{icon: '../images/moment.png', title: '朋友圈'}],
dShopping: [{icon: '../images/shopping.png', title: '购物'}],
dDrift: [{icon: '../images/drift.png', title: '漂流瓶'}],
dAction: [{icon: '../images/scan.png', title: '扫一扫'}, {icon: '../images/shake.png', title: '摇一摇'}],
dAction: [{icon: '../images/scan.png', title: '扫一扫'}, {icon: '../images/shake.png', title: '摇一摇'}]
}
};
methods = {
Expand All @@ -63,4 +62,4 @@
onLoad () {
}
}
</script>
</script>
2 changes: 1 addition & 1 deletion src/components/group.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}

components = {
item: Item,
item: Item
};

}
Expand Down
2 changes: 1 addition & 1 deletion src/components/input.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
onLoad () {
}
}
</script>
</script>
6 changes: 3 additions & 3 deletions src/components/item.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

props = {
item: {},
index: {}
index: {},
}

methods = {
click (evt) {
console.log(`[clicked]GroupIndex:(${this.$parent.$index}) Index:(${this.$index}) Title:(${this.item.title})`);
if (this.item.action)
if (this.item.action) {
this.item.action.call(this.$parent);
else {
} else {
this.$root.showToast(this.item.title);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/list.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
methods = {
click (index, item, evt) {
console.log('index: ' + index + 'clicked: ' + item.title);
if (this.list[index].action)
if (this.list[index].action) {
this.list[index].action.call(this.$parent);
else {
} else {
this.$root.showToast(item.title);
}
}
Expand Down
Loading

0 comments on commit 6b31669

Please sign in to comment.