Skip to content

Commit

Permalink
fix(core): fixed eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dlhandsome committed May 31, 2020
1 parent f7478b3 commit 66942ea
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 116 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/component/rule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Component({
const disabled = state.disabled;

nameState = isFunc(name) ? name() : name;

checkedState = isFunc(checked) ? checked() : checked;

disabledState = isFunc(disabled) ? disabled() : disabled;
Expand Down
141 changes: 67 additions & 74 deletions packages/core/src/component/ui-check/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import Debug from '../../libs/index';
import { prefix, _closeBadge } from './plugin'
import { prefix, _closeBadge } from './plugin';

let _timer
let _pixelTimer
let _y = 0
let _timer;
let _pixelTimer;
let _y = 0;
// 屏幕安全区域
const safeArea = wx.getSystemInfoSync().safeArea
const safeArea = wx.getSystemInfoSync().safeArea;
// 滑块容器的头尾预留高度
const reservedDistance = 150
const reservedDistance = 150;

Component({
properties: {
myProperty:{
type:String,
value:'',
observer: function(){}
},

},
properties: {},
data: {
safeArea,
url: '',
Expand Down Expand Up @@ -48,111 +41,111 @@ Component({
}
},
methods: {
otherBadgesHandler ({ show = false } = {}) {
const badges = Debug.getBadge()
otherBadgesHandler({ show = false } = {}) {
const badges = Debug.getBadge();
badges.forEach(badge => {
badge.emit({
show
})
})
});
});
},
imgLoad (e) {
const { width, height } = e.detail
const safeAreaWidth = this.data.safeArea.width
const ratio = safeAreaWidth / width
const moveViewHeight = height * ratio
imgLoad(e) {
const { width, height } = e.detail;
const safeAreaWidth = this.data.safeArea.width;
const ratio = safeAreaWidth / width;
const moveViewHeight = height * ratio;

this.setData({
'moveView.width': safeAreaWidth,
'moveView.height': moveViewHeight
})
});
},
slideChanging (e) {
const opacity = e.detail.value
slideChanging(e) {
const opacity = e.detail.value;
this.setData({
'moveView.opacity': opacity / 100
})
this.toggleOperationBar({ immediate: false })
});
this.toggleOperationBar({ immediate: false });
},
showOperationBar () {
showOperationBar() {
this.setData({
'operationBar.visible': true
})
});
},
hideOperationBar () {
hideOperationBar() {
this.setData({
'operationBar.visible': false
})
});
},
moveViewChange (e) {
moveViewChange(e) {
// 更新偏移量
_y = e.detail.y
_y = e.detail.y;
},
toggleOperationBar ({ immediate = true } = {}) {
toggleOperationBar({ immediate = true } = {}) {
if (!this.data.operationBar.visible) {
this.showOperationBar()
this.showOperationBar();
} else {
immediate && this.hideOperationBar()
immediate && this.hideOperationBar();
}
clearTimeout(_timer)
clearTimeout(_timer);
_timer = setTimeout(() => {
this.hideOperationBar()
}, 5000)
this.hideOperationBar();
}, 5000);
},
moveViewRising () {
clearTimeout(_pixelTimer)
moveViewRising() {
clearTimeout(_pixelTimer);
this.setData({
'moveView.y': --_y
})
this.toggleOperationBar({ immediate: false })
});
this.toggleOperationBar({ immediate: false });
// 60fps
_pixelTimer = setTimeout(() => {
this.moveViewRising()
}, 16)
this.moveViewRising();
}, 16);
},
moveViewFalling () {
clearTimeout(_pixelTimer)
moveViewFalling() {
clearTimeout(_pixelTimer);
this.setData({
'moveView.y': ++_y
})
this.toggleOperationBar({ immediate: false })
});
this.toggleOperationBar({ immediate: false });
// 60fps
_pixelTimer = setTimeout(() => {
this.moveViewFalling()
}, 16)
this.moveViewFalling();
}, 16);
},
increaseTouchstart () {
this.moveViewRising()
increaseTouchstart() {
this.moveViewRising();
},
increaseTouchend () {
clearTimeout(_pixelTimer)
increaseTouchend() {
clearTimeout(_pixelTimer);
},
decreaseTouchstart () {
this.moveViewFalling()
decreaseTouchstart() {
this.moveViewFalling();
},
decreaseTouchend () {
clearTimeout(_pixelTimer)
decreaseTouchend() {
clearTimeout(_pixelTimer);
}
},
ready (){
const event = Debug.store.event
event.on(prefix + 'upload:done', (url) => {
ready() {
const event = Debug.store.event;
event.on(prefix + 'upload:done', url => {
this.setData({
url
})
event.emit('debug:mask:hide-modal')
this.otherBadgesHandler({ show: false })
});
event.emit('debug:mask:hide-modal');
this.otherBadgesHandler({ show: false });

_closeBadge.emit({
show: true,
handler: {
bindTap: () => {
this.setData({ url: '' })
this.otherBadgesHandler({ show: true })
_closeBadge.emit({ show: false })
this.setData({ url: '' });
this.otherBadgesHandler({ show: true });
_closeBadge.emit({ show: false });
}
}
})
})
},
});
});
});
}
});
83 changes: 42 additions & 41 deletions packages/core/src/component/ui-check/plugin.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
const uiCheckPlugin = {}
const uiCheckPlugin = {};

export const prefix = 'debug:ui-check:'
export const prefix = 'debug:ui-check:';

export let _Debug
export let _Debug;

export let _closeBadge
export let _closeBadge;

uiCheckPlugin.install = function (weDebug, options = {}) {
if (uiCheckPlugin.installed) return;
_Debug = weDebug

const event = weDebug.store.event

const rule = weDebug.createFormRule(Object.assign(
{},
{
title: 'UI对比',
desc: '点击按钮上传视觉稿',
type: 'button',
state: {
name: '上传'
},
handler: {
bindTap(state) {
if (!state.disabled) {
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths

event.emit(prefix + 'upload:done', tempFilePaths[0])
}
})
_Debug = weDebug;

const event = weDebug.store.event;

const rule = weDebug.createFormRule(
Object.assign(
{},
{
title: 'UI对比',
desc: '点击按钮上传视觉稿',
type: 'button',
state: {
name: '上传'
},
handler: {
bindTap(state) {
if (!state.disabled) {
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths;

event.emit(prefix + 'upload:done', tempFilePaths[0]);
}
});
}
}
}
}
},
options
))
},
options
)
);
_closeBadge = weDebug.createBadge({
key: 'close',
show: false,
Expand All @@ -49,12 +51,11 @@ uiCheckPlugin.install = function (weDebug, options = {}) {
right: 10,
top: 10
}
})

weDebug.addBadge([ _closeBadge ])
});

weDebug.addBadge([_closeBadge]);

weDebug.addFormRule([ rule ])
}
weDebug.addFormRule([rule]);
};

export default uiCheckPlugin
export default uiCheckPlugin;

0 comments on commit 66942ea

Please sign in to comment.