Skip to content

Commit ff3e4f5

Browse files
committed
style(EsLint): 格式化部分 js 代码
1 parent cc5303b commit ff3e4f5

File tree

4 files changed

+79
-81
lines changed

4 files changed

+79
-81
lines changed
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import navigationBarUtil from '../../../../../dist/navigation-bar/navigation-bar-util';
2-
31
Page({
42

53
/**
@@ -10,8 +8,8 @@ Page({
108
starCount: null
119
},
1210

13-
onLoad(query) {
14-
this.getStarCount()
11+
onLoad() {
12+
this.getStarCount();
1513
},
1614

1715
onShareAppMessage: function () {
@@ -22,56 +20,56 @@ Page({
2220
* 获取 Star 数量,有些网络无法访问,暂时不用
2321
*/
2422
getStarCount() {
25-
const that = this
23+
const that = this;
2624
wx.request({
2725
url: 'https://api.github.com/repos/TaleLin/lin-ui',
2826
success(res) {
29-
let starCount = res.data.stargazers_count
30-
starCount = (starCount / 1000).toFixed(1)
31-
that.setData({starCount})
27+
let starCount = res.data.stargazers_count;
28+
starCount = (starCount / 1000).toFixed(1);
29+
that.setData({starCount});
3230
}
33-
})
31+
});
3432
},
3533

3634
/**
3735
* 监听:长按左侧按钮
3836
*/
3937
onLongPressLeft() {
40-
wx.vibrateShort()
38+
wx.vibrateShort();
4139
wx.showModal({
4240
title: '提示',
4341
content: '长按左侧按钮事件被触发'
44-
})
42+
});
4543
},
4644

4745
/**
4846
* 监听:长按右侧按钮
4947
*/
5048
onLongPressRight() {
51-
wx.vibrateShort()
49+
wx.vibrateShort();
5250
wx.showModal({
5351
title: '提示',
5452
content: '长按右侧按钮事件被触发'
55-
})
53+
});
5654
},
5755

5856
/**
5957
* 监听:点击 Star 卡片
6058
*/
6159
onTapStarCard() {
62-
wx.vibrateShort()
60+
wx.vibrateShort();
6361
wx.setClipboardData({
6462
data: 'https://github.com/TaleLin/lin-ui'
65-
})
63+
});
6664
},
6765

6866
/**
6967
* 监听:点击公众号卡片
7068
*/
7169
onTapPublicCard() {
72-
wx.vibrateShort()
70+
wx.vibrateShort();
7371
wx.setClipboardData({
7472
data: '林间有风'
75-
})
73+
});
7674
}
77-
})
75+
});
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
const NaviConfigs = [{
2-
icon: "/images/component/tab.png",
3-
title: "Tabs",
4-
desc: "标签页",
5-
componentsPath: "/pages/components/nav/pages/tabs/index"
6-
},
7-
{
8-
icon: "/images/component/combined-tabs.png",
9-
title: "CombinedTabs",
10-
desc: "混合标签",
11-
componentsPath: "/pages/components/nav/pages/combined-tabs/index"
12-
},
13-
{
14-
icon: "/images/component/tabbar.png",
15-
title: "TabBar",
16-
desc: "自定义选项卡",
17-
componentsPath: "/pages/components/nav/pages/tabbar/index"
18-
},
19-
{
20-
icon: "/images/component/segment.png",
21-
title: "Segment",
22-
desc: "选项卡",
23-
componentsPath: "/pages/components/nav/pages/segment/index"
24-
},
25-
{
26-
icon: '/images/component/album.png',
27-
title: 'CapsuleBar',
28-
desc: '胶囊栏',
29-
componentsPath: '/pages/components/nav/pages/capsule-bar/index'
30-
}
31-
]
2+
icon: '/images/component/tab.png',
3+
title: 'Tabs',
4+
desc: '标签页',
5+
componentsPath: '/pages/components/nav/pages/tabs/index'
6+
},
7+
{
8+
icon: '/images/component/combined-tabs.png',
9+
title: 'CombinedTabs',
10+
desc: '混合标签',
11+
componentsPath: '/pages/components/nav/pages/combined-tabs/index'
12+
},
13+
{
14+
icon: '/images/component/tabbar.png',
15+
title: 'TabBar',
16+
desc: '自定义选项卡',
17+
componentsPath: '/pages/components/nav/pages/tabbar/index'
18+
},
19+
{
20+
icon: '/images/component/segment.png',
21+
title: 'Segment',
22+
desc: '选项卡',
23+
componentsPath: '/pages/components/nav/pages/segment/index'
24+
},
25+
{
26+
icon: '/images/component/album.png',
27+
title: 'CapsuleBar',
28+
desc: '胶囊栏',
29+
componentsPath: '/pages/components/nav/pages/capsule-bar/index'
30+
}
31+
];
3232
export default NaviConfigs;

src/capsule-bar/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import deviceUtil from '../utils/device-util'
2-
import validator from '../behaviors/validator'
3-
import eventUtil from '../core/utils/event-util'
1+
import deviceUtil from '../utils/device-util';
2+
import validator from '../behaviors/validator';
3+
import eventUtil from '../core/utils/event-util';
44

55
Component({
66
behaviors: [validator],
@@ -77,7 +77,7 @@ Component({
7777
ready:function () {
7878
this.setData({
7979
capsuleButtonInfo: this.getCapsuleButtonInfo()
80-
})
80+
});
8181
}
8282
},
8383

@@ -87,55 +87,55 @@ Component({
8787
* 获取左侧胶囊按钮信息
8888
*/
8989
getCapsuleButtonInfo() {
90-
const screenWidth = wx.getSystemInfoSync().screenWidth
91-
const capsuleButtonInfo = wx.getMenuButtonBoundingClientRect()
92-
capsuleButtonInfo.left = screenWidth - capsuleButtonInfo.right
93-
capsuleButtonInfo.right = capsuleButtonInfo.left + capsuleButtonInfo.width
94-
return capsuleButtonInfo
90+
const screenWidth = wx.getSystemInfoSync().screenWidth;
91+
const capsuleButtonInfo = wx.getMenuButtonBoundingClientRect();
92+
capsuleButtonInfo.left = screenWidth - capsuleButtonInfo.right;
93+
capsuleButtonInfo.right = capsuleButtonInfo.left + capsuleButtonInfo.width;
94+
return capsuleButtonInfo;
9595
},
9696

9797
/**
9898
* 监听:点击左侧按钮
9999
*/
100100
onTapLeftButton() {
101-
eventUtil.emit(this, 'linlefttap')
101+
eventUtil.emit(this, 'linlefttap');
102102

103103
if (!this.data.disableBack) {
104-
wx.navigateBack()
104+
wx.navigateBack();
105105
}
106106
},
107107

108108
/**
109109
* 监听:长按左侧按钮
110110
*/
111111
onLongPressLeftButton() {
112-
eventUtil.emit(this, 'linleftlongpress')
112+
eventUtil.emit(this, 'linleftlongpress');
113113
},
114114

115115
/**
116116
* 监听:点击右侧按钮
117117
*/
118118
async onTapRightButton() {
119-
eventUtil.emit(this, 'linrighttap')
119+
eventUtil.emit(this, 'linrighttap');
120120

121-
const homePage = this.data.homePage
121+
const homePage = this.data.homePage;
122122
if (!this.data.disableHome) {
123123
wx.switchTab({
124124
url: homePage,
125125
fail() {
126126
wx.navigateTo({
127127
url: homePage
128-
})
128+
});
129129
}
130-
})
130+
});
131131
}
132132
},
133133

134134
/**
135135
* 监听:长按右侧按钮
136136
*/
137137
onLongPressRightButton() {
138-
eventUtil.emit(this, 'linrightlongpress')
138+
eventUtil.emit(this, 'linrightlongpress');
139139
}
140140
}
141-
})
141+
});

src/utils/device-util.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,54 @@ class DeviceUtil {
99
* @param systemInfo 设备信息
1010
*/
1111
constructor(systemInfo) {
12-
this.systemInfo = systemInfo
12+
this.systemInfo = systemInfo;
1313
}
1414

1515
/**
1616
* px 转 rpx
1717
* @param px 像素值
1818
*/
1919
px2rpx(px) {
20-
const windowWidth = this.systemInfo.windowWidth
21-
return 750 / windowWidth * px
20+
const windowWidth = this.systemInfo.windowWidth;
21+
return 750 / windowWidth * px;
2222
}
2323

2424
/**
2525
* rpx 转 px
2626
* @param rpx
2727
*/
2828
rpx2px(rpx) {
29-
const windowWidth = this.systemInfo.windowWidth
30-
return windowWidth / 750 * rpx
29+
const windowWidth = this.systemInfo.windowWidth;
30+
return windowWidth / 750 * rpx;
3131
}
3232

3333
/**
3434
* 获取导航栏高度(单位rpx)
3535
*/
3636
getNavigationBarHeight() {
37-
const titleBarHeight = this.getTitleBarHeight()
38-
const statusBarHeight = this.getStatusBarHeight()
39-
return titleBarHeight + statusBarHeight
37+
const titleBarHeight = this.getTitleBarHeight();
38+
const statusBarHeight = this.getStatusBarHeight();
39+
return titleBarHeight + statusBarHeight;
4040
}
4141

4242
/**
4343
* 获取状态栏高度(单位rpx)
4444
*/
4545
getStatusBarHeight() {
46-
return this.px2rpx(this.systemInfo.statusBarHeight)
46+
return this.px2rpx(this.systemInfo.statusBarHeight);
4747
}
4848

4949
/**
5050
* 获取标题栏高度(单位rpx)
5151
*/
5252
getTitleBarHeight() {
53-
const statusBarHeight = this.systemInfo.statusBarHeight
54-
const capsuleButtonInfo = wx.getMenuButtonBoundingClientRect()
55-
const gap = capsuleButtonInfo.top - statusBarHeight
56-
return this.px2rpx(gap * 2 + capsuleButtonInfo.height)
53+
const statusBarHeight = this.systemInfo.statusBarHeight;
54+
const capsuleButtonInfo = wx.getMenuButtonBoundingClientRect();
55+
const gap = capsuleButtonInfo.top - statusBarHeight;
56+
return this.px2rpx(gap * 2 + capsuleButtonInfo.height);
5757
}
5858

5959
}
6060

61-
const deviceUtil = new DeviceUtil(wx.getSystemInfoSync())
62-
export default deviceUtil
61+
const deviceUtil = new DeviceUtil(wx.getSystemInfoSync());
62+
export default deviceUtil;

0 commit comments

Comments
 (0)