Skip to content

Commit

Permalink
fix: demo 示例调整微信版本 ES+ 转换结果 (#1103)
Browse files Browse the repository at this point in the history
* demo: remove async

* demo: updated

* Revert "demo: remove async"

This reverts commit 0a25101.

* Revert "demo: updated"

This reverts commit c82e215.

* fix: use different tsconfig
  • Loading branch information
imsenyu authored Feb 18, 2024
1 parent 89582a7 commit b06dcc6
Show file tree
Hide file tree
Showing 88 changed files with 615 additions and 1,478 deletions.
28 changes: 13 additions & 15 deletions compiled/wechat/demo/pages/ActionSheet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,23 @@ Page({
},
],
},
handleOpenBasic: function (e) {
var _a;
var index = e.currentTarget.dataset.index;
this.setData((_a = {},
_a["visible".concat(index)] = true,
_a));
handleOpenBasic(e) {
const { index } = e.currentTarget.dataset;
this.setData({
[`visible${index}`]: true,
});
},
handleCloseBasic: function (e) {
var _a;
var index = e.currentTarget.dataset.index;
this.setData((_a = {},
_a["visible".concat(index)] = false,
_a));
handleCloseBasic(e) {
const { index } = e.currentTarget.dataset;
this.setData({
[`visible${index}`]: false,
});
},
handleAction: function (item, index, e) {
var _a = item.detail, clickItem = _a[0], clickIndex = _a[1];
handleAction(item, index, e) {
const [clickItem, clickIndex] = item.detail;
//@ts-ignore
wx.showToast({
title: "\u4F60\u70B9\u51FB\u4E86".concat(clickItem.key, "(").concat(clickIndex, ")"),
title: `你点击了${clickItem.key}(${clickIndex})`,
});
},
});
2 changes: 1 addition & 1 deletion compiled/wechat/demo/pages/Button/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Page({
handleTap: function (e) {
handleTap(e) {
//@ts-ignore
wx.showToast({
title: '点击按钮',
Expand Down
2 changes: 1 addition & 1 deletion compiled/wechat/demo/pages/ButtonCustom/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Page({
handleTap: function (e) {
handleTap(e) {
console.log(e);
},
});
2 changes: 1 addition & 1 deletion compiled/wechat/demo/pages/ButtonInline/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Page({
handleTap: function (e) {
handleTap(e) {
console.log(e);
my.alert({
title: '点击按钮'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dayjs from 'dayjs';
import Converter from './js-calendar-converter';
import { mountComponent } from '../../../../../src/_util/component';
var CollapseContainer = function (props) {
const CollapseContainer = (props) => {
var _a, _b, _c;
var time = dayjs((_a = props.cell) === null || _a === void 0 ? void 0 : _a.time);
var vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date'));
const time = dayjs((_a = props.cell) === null || _a === void 0 ? void 0 : _a.time);
const vs = Converter.solar2lunar(time.get('year'), time.get('month') + 1, time.get('date'));
if (vs === -1) {
return {
cnday: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useEvent, useState } from 'functional-mini/component';
import { mountComponent } from '../../../../src/_util/component';
var CollapseContainer = function (props) {
const CollapseContainer = (props) => {
var _a;
var _b = useState((_a = props.defaultCollapse) !== null && _a !== void 0 ? _a : true), collapse = _b[0], setCollapse = _b[1];
useEvent('handleToggle', function () {
setCollapse(function (v) { return !v; });
const [collapse, setCollapse] = useState((_a = props.defaultCollapse) !== null && _a !== void 0 ? _a : true);
useEvent('handleToggle', () => {
setCollapse((v) => !v);
});
return {
collapse: collapse,
collapse,
internalHide: props.hide,
containerTitle: props.title,
};
Expand Down
40 changes: 20 additions & 20 deletions compiled/wechat/demo/pages/Calendar/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from 'dayjs';
var localeText = {
const localeText = {
weekdayNames: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
title: 'YYYY/MM',
today: 'Today',
Expand All @@ -8,10 +8,10 @@ var localeText = {
startAndEnd: 'Start/End',
};
function demo8Formatter(cell) {
var isOdd = dayjs(cell.time).date() % 2 === 1;
var isNotBeginEnd = !cell.isSelectedBegin && !cell.isSelectedEnd;
var isWeekend = dayjs(cell.time).day() > 4;
var topClassName;
const isOdd = dayjs(cell.time).date() % 2 === 1;
const isNotBeginEnd = !cell.isSelectedBegin && !cell.isSelectedEnd;
const isWeekend = dayjs(cell.time).day() > 4;
let topClassName;
if (isNotBeginEnd) {
topClassName = isOdd ? 'odd' : 'even';
}
Expand All @@ -27,7 +27,7 @@ function demo8Formatter(cell) {
}
function demoFormatter(cell, value) {
if (Array.isArray(value) && value.length == 1) {
var current = value[0];
const current = value[0];
return {
disabled: dayjs(cell.time).diff(dayjs(current), 'days') > 3,
bottom: dayjs(cell.time).diff(dayjs(current), 'days') > 3
Expand Down Expand Up @@ -65,51 +65,51 @@ Page({
visible: true,
},
demo7: {
localeText: localeText,
localeText,
visible: true,
monthRange: [new Date().getTime(), new Date().getTime()],
},
demo8: {
visible: true,
monthRange: [new Date().getTime(), new Date().getTime()],
},
demoFormatter: demoFormatter,
demo8Formatter: demo8Formatter,
demoFormatter,
demo8Formatter,
demo9: {
visible: true,
value: Date.now(),
monthRange: [new Date().getTime(), new Date().getTime()],
},
},
demo3NextMonth: function () {
var current = this.data.demo3.monthRange[0];
var newMonth = dayjs(current).add(1, 'month').toDate().getTime();
demo3NextMonth() {
const current = this.data.demo3.monthRange[0];
const newMonth = dayjs(current).add(1, 'month').toDate().getTime();
this.setData({
'demo3.title': dayjs(newMonth).format('YYYY年MM月'),
'demo3.monthRange': [newMonth, newMonth],
});
},
demo3PreviousMonth: function () {
var current = this.data.demo3.monthRange[0];
var newMonth = dayjs(current).add(-1, 'month').toDate().getTime();
demo3PreviousMonth() {
const current = this.data.demo3.monthRange[0];
const newMonth = dayjs(current).add(-1, 'month').toDate().getTime();
this.setData({
'demo3.title': dayjs(newMonth).format('YYYY年MM月'),
'demo3.monthRange': [newMonth, newMonth],
});
},
demoFormatter: demoFormatter,
demo8Formatter: demo8Formatter,
demo9HandleChange: function (value) {
demoFormatter,
demo8Formatter,
demo9HandleChange(value) {
this.setData({
'demo9.value': value.detail,
});
},
demo9HandlePreviousDay: function () {
demo9HandlePreviousDay() {
this.setData({
'demo9.value': this.data.demo9.value - 1000 * 24 * 3600,
});
},
demo9HandleNextDay: function () {
demo9HandleNextDay() {
this.setData({
'demo9.value': this.data.demo9.value + 1000 * 24 * 3600,
});
Expand Down
14 changes: 7 additions & 7 deletions compiled/wechat/demo/pages/CascaderPicker/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import cityList from './city';
Page({
data: {
cityList: cityList,
cityList,
value: ['34', '330'],
},
handleCityPickerChange: function (value, selectedOption, e) {
handleCityPickerChange(value, selectedOption, e) {
console.log('cityChange', value, selectedOption, e);
},
handleCityOnOk: function (value, selectedOption, e) {
handleCityOnOk(value, selectedOption, e) {
console.log('cityOk', value, selectedOption, e);
},
handleOk: function (value, selectedOption, e) {
handleOk(value, selectedOption, e) {
this.setData({ value: value.detail[0] });
console.log('cityOk', value, selectedOption, e);
},
handleChangeControlled: function () {
handleChangeControlled() {
this.setData({ value: ['31', '310'] });
},
handleClearControlled: function () {
handleClearControlled() {
this.setData({ value: [] });
},
handleDismiss: function (e) {
handleDismiss(e) {
console.log('handleDismiss', e);
},
});
6 changes: 3 additions & 3 deletions compiled/wechat/demo/pages/Checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Page({
data: {
checked: false,
},
onChange: function (value, e) {
onChange(value, e) {
console.log(value, e);
},
handleChange: function (checked) {
handleChange(checked) {
this.setData({
checked: checked.detail,
});
},
toggleChange: function () {
toggleChange() {
this.setData({
checked: !this.data.checked,
});
Expand Down
10 changes: 5 additions & 5 deletions compiled/wechat/demo/pages/CheckboxCustomGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ Page({
],
value: [],
},
onChange: function (checked, e) {
var value = this.data.value;
var event = checked;
onChange(checked, e) {
let value = this.data.value;
const event = checked;
if (event.detail) {
value = value.concat(event.target.dataset.value);
}
else {
value = value.filter(function (v) { return v !== event.target.dataset.value; });
value = value.filter((v) => v !== event.target.dataset.value);
}
this.setData({ value: value });
this.setData({ value });
console.log(value);
},
});
4 changes: 2 additions & 2 deletions compiled/wechat/demo/pages/CheckboxGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Page({
{ value: 'banana', label: '香蕉' },
],
},
onChange: function (value, e) {
onChange(value, e) {
console.log(value, e);
},
handleChange: function (value) {
handleChange(value) {
this.setData({
value: value.detail,
});
Expand Down
4 changes: 2 additions & 2 deletions compiled/wechat/demo/pages/Checklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ Page({
},
],
},
onChange: function (v, items, e) {
onChange(v, items, e) {
console.log('当前选中的值为:', v, items, e);
},
onChangeControlled: function (value) {
onChangeControlled(value) {
this.setData({ value: value.detail[0] });
},
});
2 changes: 1 addition & 1 deletion compiled/wechat/demo/pages/Collapse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Page({
}
]
},
onChange: function (current) {
onChange(current) {
console.log(current);
}
});
2 changes: 1 addition & 1 deletion compiled/wechat/demo/pages/CollapseAccordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Page({
},
]
},
onChange: function (current) {
onChange(current) {
console.log(current);
}
});
37 changes: 14 additions & 23 deletions compiled/wechat/demo/pages/CollapseControl/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Page({
data: {
current: [0],
Expand All @@ -25,38 +16,38 @@ Page({
},
],
},
onChange: function (current) {
onChange(current) {
current = current.detail;
this.setData({
current: current,
current,
});
},
changeContent: function () {
var items = __spreadArray([], this.data.items, true);
changeContent() {
const items = [...this.data.items];
items[0].content = Math.random() + ' ' + items[0].content;
this.setData({
items: items,
items,
});
},
addItems: function () {
var items = __spreadArray(__spreadArray([], this.data.items, true), [
addItems() {
const items = [
...this.data.items,
{
title: this.data.items.length,
content: 'Pariatur dolore commodo commodo elit adipisicing sunt adipisicing ex duis labore nisi sunt. Magna ut minim deserunt. Sunt velit occaecat incididunt aliqua. Dolore officia voluptate aute reprehenderit anim excepteur elit.',
},
], false);
];
this.setData({
items: items,
items,
current: [this.data.items.length],
});
},
toggle: function () {
var _this = this;
toggle() {
this.setData({
current: this.data.items
.map(function (item, index) { return index; })
.filter(function (item) {
return _this.data.current.indexOf(item) < 0;
.map((item, index) => index)
.filter((item) => {
return this.data.current.indexOf(item) < 0;
}),
});
},
Expand Down
Loading

0 comments on commit b06dcc6

Please sign in to comment.