Skip to content

Commit

Permalink
chore: format event name to camelcase (#2487)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Aug 29, 2023
1 parent a69ed6c commit 6d393bb
Show file tree
Hide file tree
Showing 52 changed files with 151 additions and 160 deletions.
6 changes: 3 additions & 3 deletions src/packages/__VUE/address/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default create({
default: ''
}
},
emits: ['update:visible', 'update:modelValue', 'type', 'change', 'selected', 'close', 'close-mask', 'switch-module'],
emits: ['update:visible', 'update:modelValue', 'type', 'change', 'selected', 'close', 'closeMask', 'switchModule'],
setup(props, { emit }) {
const classes = computed(() => {
Expand Down Expand Up @@ -439,7 +439,7 @@ export default create({
if (closeWay.value == 'self') {
emit('close', callBackParams);
} else {
emit('close-mask', { closeWay: closeWay });
emit('closeMask', { closeWay: closeWay });
}
emit('update:visible', false);
Expand All @@ -450,7 +450,7 @@ export default create({
const type = privateType.value;
privateType.value = type == 'exist' ? 'custom' : 'exist';
initAddress();
emit('switch-module', { type: privateType.value });
emit('switchModule', { type: privateType.value });
};
const handleElevatorItem = (key: string, item: RegionData) => {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/__VUE/address/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default create({
default: ''
}
},
emits: ['update:visible', 'update:modelValue', 'type', 'change', 'selected', 'close', 'close-mask', 'switch-module'],
emits: ['update:visible', 'update:modelValue', 'type', 'change', 'selected', 'close', 'closeMask', 'switchModule'],
setup(props: any, { emit }) {
const regionLine = ref<null | HTMLElement>(null);
Expand Down Expand Up @@ -424,7 +424,7 @@ export default create({
if (closeWay.value == 'self') {
emit('close', callBackParams);
} else {
emit('close-mask', { closeWay: closeWay });
emit('closeMask', { closeWay: closeWay });
}
emit('update:visible', false);
Expand All @@ -435,7 +435,7 @@ export default create({
const type = privateType.value;
privateType.value = type == 'exist' ? 'custom' : 'exist';
initAddress();
emit('switch-module', { type: privateType.value });
emit('switchModule', { type: privateType.value });
};
const handleElevatorItem = (key: string, item: RegionData) => {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/__VUE/audio/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default create({
Service,
[Range.name]: Range as Component
},
emits: ['fastBack', 'play', 'forward', 'ended', 'changeProgress', 'mute', 'can-play'],
emits: ['fastBack', 'play', 'forward', 'ended', 'changeProgress', 'mute', 'canPlay'],
setup(props, { emit, slots }) {
const audioRef = ref(null);
Expand Down Expand Up @@ -165,7 +165,7 @@ export default create({
audioData.second = audioR.duration;
audioData.duration = formatSeconds(audioR.duration);
emit('can-play', e);
emit('canPlay', e);
};
//播放时间
Expand Down
4 changes: 2 additions & 2 deletions src/packages/__VUE/countdown/__tests__/countdown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ test('endTime props', async () => {
endTime: Date.now() + 1 * 50
}
});
expect(wrapper.emitted('on-end')).toBeFalsy();
expect(wrapper.emitted('onEnd')).toBeFalsy();
await sleep(51);
expect(wrapper.emitted('on-end')).toBeTruthy();
expect(wrapper.emitted('onEnd')).toBeTruthy();
});

test('format props', async () => {
Expand Down
10 changes: 5 additions & 5 deletions src/packages/__VUE/countdown/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default create({
default: 0
}
},
emits: ['input', 'on-end', 'on-restart', 'on-paused', 'update:modelValue'],
emits: ['input', 'onEnd', 'onRestart', 'onPaused', 'update:modelValue'],
setup(props: any, { emit, slots }) {
const state = reactive({
Expand Down Expand Up @@ -106,7 +106,7 @@ export default create({
if (!remainTime) {
state.counting = false;
pause();
emit('on-end');
emit('onEnd');
}
if (remainTime > 0) {
Expand Down Expand Up @@ -192,14 +192,14 @@ export default create({
state.counting = true;
state.handleEndTime = Date.now() + Number(state.restTime);
tick();
emit('on-restart', state.restTime);
emit('onRestart', state.restTime);
}
};
// 暂定
const pause = () => {
cancelAnimationFrame(state.timer as any);
state.counting = false;
emit('on-paused', state.restTime);
emit('onPaused', state.restTime);
};
//重置
Expand Down Expand Up @@ -240,7 +240,7 @@ export default create({
state.handleEndTime = Date.now() + Number(state.restTime);
tick();
}
emit('on-restart', state.restTime);
emit('onRestart', state.restTime);
}
}
);
Expand Down
10 changes: 5 additions & 5 deletions src/packages/__VUE/countdown/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default create({
default: 0
}
},
emits: ['input', 'on-end', 'on-restart', 'on-paused', 'update:modelValue'],
emits: ['input', 'onEnd', 'onRestart', 'onPaused', 'update:modelValue'],
setup(props: any, { emit, slots }) {
const state = reactive({
Expand Down Expand Up @@ -105,7 +105,7 @@ export default create({
if (!remainTime) {
state.counting = false;
pause();
emit('on-end');
emit('onEnd');
}
if (remainTime > 0) {
Expand Down Expand Up @@ -191,14 +191,14 @@ export default create({
state.counting = true;
state.handleEndTime = Date.now() + Number(state.restTime);
tick();
emit('on-restart', state.restTime);
emit('onRestart', state.restTime);
}
};
// 暂定
const pause = () => {
cancelAnimationFrame(state.timer as any);
state.counting = false;
emit('on-paused', state.restTime);
emit('onPaused', state.restTime);
};
//重置
Expand Down Expand Up @@ -239,7 +239,7 @@ export default create({
state.handleEndTime = Date.now() + Number(state.restTime);
tick();
}
emit('on-restart', state.restTime);
emit('onRestart', state.restTime);
}
}
);
Expand Down
14 changes: 7 additions & 7 deletions src/packages/__VUE/countup/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default create({
}
},
components: {},
emits: ['click', 'scroll-end'],
emits: ['click', 'scrollEnd'],
setup(props, { emit }) {
const data: IData = reactive({
valFlag: false,
Expand Down Expand Up @@ -347,7 +347,7 @@ export default create({
//数字减小,有可能导致current小于speed
data.current = Number(endNum.toFixed(toFixed));
clearInterval(countTimer);
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
} else {
data.current = Number((parseFloat(String(data.current)) - parseFloat(String(speed))).toFixed(toFixed));
Expand All @@ -357,7 +357,7 @@ export default create({
if (data.current >= endNum) {
data.current = Number(endNum.toFixed(toFixed));
clearInterval(countTimer);
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
} else {
data.current = Number((parseFloat(String(data.current)) + parseFloat(String(speed))).toFixed(toFixed));
Expand Down Expand Up @@ -475,7 +475,7 @@ export default create({
// that.totalCount--;
if (data.totalCount <= 0) {
clearIntervalTime();
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
}
}, props.during);
Expand Down Expand Up @@ -535,7 +535,7 @@ export default create({
// data.relNum = calculation(data.relNum, m * props.speed, '+');
// }, props.during);
f.addEventListener('webkitTransitionEnd', () => {
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
// setTimeout(() => {
// data.relNum = calculation(data.relNum, m * props.speed, '+');
Expand Down Expand Up @@ -611,10 +611,10 @@ export default create({
setTimeout(() => {
data.finshMachine = 0;
if (data.prizeLevelTrun < 0) {
emit('scroll-end', false);
emit('scrollEnd', false);
data.valFlag = false;
} else {
emit('scroll-end', true);
emit('scrollEnd', true);
data.valFlag = false;
}
}, 130);
Expand Down
14 changes: 7 additions & 7 deletions src/packages/__VUE/countup/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default create({
}
},
components: {},
emits: ['click', 'scroll-end'],
emits: ['click', 'scrollEnd'],
setup(props, { emit }) {
const runNumberImg = ref(null);
const numberItemRef = ref<any>([]);
Expand Down Expand Up @@ -354,7 +354,7 @@ export default create({
//数字减小,有可能导致current小于speed
data.current = endNum.toFixed(toFixed);
clearInterval(countTimer);
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
} else {
let num = parseFloat(String(data.current)) - parseFloat(String(speed));
Expand All @@ -365,7 +365,7 @@ export default create({
if (Number(data.current) >= endNum) {
data.current = endNum.toFixed(toFixed);
clearInterval(countTimer);
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
} else {
let num = parseFloat(String(data.current)) + parseFloat(String(speed));
Expand Down Expand Up @@ -484,7 +484,7 @@ export default create({
// that.totalCount--;
if (data.totalCount <= 0) {
clearIntervalTime();
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
}
}, props.during);
Expand Down Expand Up @@ -551,7 +551,7 @@ export default create({
// data.relNum = calculation(data.relNum, m * props.speed, '+');
// }, props.during);
(runNumberImg.value as any).addEventListener('webkitTransitionEnd', () => {
emit('scroll-end');
emit('scrollEnd');
data.valFlag = false;
// setTimeout(() => {
// data.relNum = calculation(data.relNum, m * props.speed, '+');
Expand Down Expand Up @@ -626,10 +626,10 @@ export default create({
setTimeout(() => {
data.finshMachine = 0;
if (data.prizeLevelTrun < 0) {
emit('scroll-end', false);
emit('scrollEnd', false);
data.valFlag = false;
} else {
emit('scroll-end', true);
emit('scrollEnd', true);
data.valFlag = false;
}
}, 130);
Expand Down
4 changes: 2 additions & 2 deletions src/packages/__VUE/elevator/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test('should list item highlight when clickItem trigger click', async () => {
'nut-elevator__list__item__name--highcolor'
);

expect((wrapper.emitted('click-item') as any)[0][0]).toBe('B');
expect((wrapper.emitted('clickItem') as any)[0][0]).toBe('B');
});

test('clickIndex trigger click', async () => {
Expand All @@ -97,7 +97,7 @@ test('clickIndex trigger click', async () => {
const listItem = wrapper.findAll('.nut-elevator__bars__inner__item')[2];
await listItem.trigger('click');

expect((wrapper.emitted('click-index') as any)[0][0]).toBe('G');
expect((wrapper.emitted('clickIndex') as any)[0][0]).toBe('G');
});

test('index is sticky', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/__VUE/elevator/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default create({
default: 35
}
},
emits: ['click-item', 'click-index', 'change'],
emits: ['clickItem', 'clickIndex', 'change'],
setup(props, context) {
const spaceHeight = 23;
const listview: Ref<HTMLElement> = ref() as Ref<HTMLElement>;
Expand Down Expand Up @@ -196,13 +196,13 @@ export default create({
};
const handleClickItem = (key: string, item: ElevatorData) => {
context.emit('click-item', key, item);
context.emit('clickItem', key, item);
state.currentData = item;
state.currentKey = key;
};
const handleClickIndex = (key: string) => {
context.emit('click-index', key);
context.emit('clickIndex', key);
};
const listViewScroll = (e: Event) => {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/__VUE/elevator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default create({
default: 35
}
},
emits: ['click-item', 'click-index', 'change'],
emits: ['clickItem', 'clickIndex', 'change'],
setup(props, context) {
const listview: Ref<any> = ref(null);
const state = reactive({
Expand Down Expand Up @@ -168,13 +168,13 @@ export default create({
};
const handleClickItem = (key: string, item: ElevatorData) => {
context.emit('click-item', key, item);
context.emit('clickItem', key, item);
state.currentData = item;
state.currentKey = key;
};
const handleClickIndex = (key: string) => {
context.emit('click-index', key);
context.emit('clickIndex', key);
};
const listViewScroll = (e: Event) => {
Expand Down
2 changes: 0 additions & 2 deletions src/packages/__VUE/formitem/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export default create({
components: {
[Cell.name]: Cell
},
emits: [''],
setup(props, { slots }) {
const parent = inject('formErrorTip') as any;
provide('form', {
Expand Down
2 changes: 0 additions & 2 deletions src/packages/__VUE/formitem/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export default create({
components: {
[Cell.name]: Cell
},
emits: [''],
setup(props, { slots }) {
const parent = inject('formErrorTip') as any;
provide('form', {
Expand Down
Loading

0 comments on commit 6d393bb

Please sign in to comment.