Skip to content

Commit c6cad25

Browse files
committed
refactor: 更改 page 到 next
1 parent 1f5bc86 commit c6cad25

File tree

68 files changed

+2532
-1660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2532
-1660
lines changed

babel.config.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-commonjs */
21
const apis = require('@tarojs/taro-h5/dist/taroApis')
32

43
module.exports = {
@@ -9,20 +8,30 @@ module.exports = {
98
spec: true,
109
useBuiltIns: false
1110
}
12-
]
11+
],
12+
'@babel/typescript'
1313
],
1414
plugins: [
1515
'@babel/plugin-proposal-class-properties',
1616
[
1717
'@babel/plugin-transform-react-jsx',
1818
{
19-
pragma: 'Nerv.createElement'
19+
pragma: 'React.createElement'
20+
}
21+
],
22+
[
23+
'@babel/plugin-proposal-decorators',
24+
{
25+
legacy: true
2026
}
2127
],
2228
['@babel/plugin-proposal-object-rest-spread'],
23-
['babel-plugin-transform-taroapi', {
24-
apis,
25-
packageName: '@tarojs/taro-h5'
26-
}]
29+
[
30+
'babel-plugin-transform-taroapi',
31+
{
32+
apis,
33+
packageName: '@tarojs/taro-h5'
34+
}
35+
]
2736
]
2837
}

config/index.js

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* eslint-disable import/no-commonjs */
21
const path = require('path')
32
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
3+
const webpack = require('webpack')
44

55
const isBuildComponent = process.env.TARO_BUILD_TYPE === 'component'
66

@@ -12,28 +12,44 @@ const config = {
1212
plugins: {},
1313
babel: {
1414
sourceMap: true,
15-
presets: [
16-
'env'
17-
],
15+
presets: ['env'],
1816
plugins: [
1917
'transform-class-properties',
2018
'transform-decorators-legacy',
2119
'transform-object-rest-spread'
2220
]
2321
},
24-
defineConstants: {},
22+
framework: 'react',
23+
mini: {
24+
webpackChain(chain) {
25+
chain.merge({
26+
devtool: 'source-map',
27+
plugins: [
28+
new webpack.ProvidePlugin({
29+
window: ['@tarojs/runtime', 'window'],
30+
document: ['@tarojs/runtime', 'document']
31+
})
32+
],
33+
resolve: {
34+
alias: {
35+
nervjs: 'react',
36+
'react-dom': '@tarojs/react'
37+
}
38+
}
39+
})
40+
}
41+
},
2542
alias: {
26-
'taro-ui': path.resolve(__dirname, '../src/ui.ts'),
43+
'taro-ui': path.resolve(__dirname, '../src/ui.ts')
2744
},
28-
mini: {},
2945
h5: {
3046
staticDirectory: 'static',
3147
postcss: {
3248
autoprefixer: {
3349
enable: true
3450
}
3551
}
36-
},
52+
}
3753
}
3854

3955
if (isBuildComponent) {
@@ -57,22 +73,24 @@ if (isBuildComponent) {
5773
classnames: 'commonjs2 classnames',
5874
'@tarojs/components': 'commonjs2 @tarojs/components',
5975
'@tarojs/taro-h5': 'commonjs2 @tarojs/taro-h5',
60-
'weui': 'commonjs2 weui'
76+
weui: 'commonjs2 weui'
6177
},
6278
plugin: {
6379
extractCSS: {
6480
plugin: MiniCssExtractPlugin,
65-
args: [{
66-
filename: 'css/index.css',
67-
chunkFilename: 'css/[id].css'
68-
}]
81+
args: [
82+
{
83+
filename: 'css/index.css',
84+
chunkFilename: 'css/[id].css'
85+
}
86+
]
6987
}
7088
}
7189
})
7290
}
7391
}
7492

75-
module.exports = function (merge) {
93+
module.exports = function(merge) {
7694
if (process.env.NODE_ENV === 'development') {
7795
return merge({}, config, require('./dev'))
7896
}

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@
108108
"jest": true
109109
},
110110
"rules": {
111-
"@typescript-eslint/no-explicit-any": ["off"],
112-
"@typescript-eslint/member-delimiter-style": ["off"],
111+
"@typescript-eslint/no-explicit-any": [
112+
"off"
113+
],
114+
"@typescript-eslint/member-delimiter-style": [
115+
"off"
116+
],
113117
"class-methods-use-this": "off",
114118
"prefer-rest-params": "off",
115119
"arrow-body-style": "warn",
@@ -227,9 +231,11 @@
227231
"devDependencies": {
228232
"@babel/core": "^7.0.0-rc.1",
229233
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.55",
234+
"@babel/plugin-proposal-decorators": "^7.8.3",
230235
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
231236
"@babel/plugin-transform-react-jsx": "^7.0.0-beta.55",
232237
"@babel/preset-env": "^7.0.0-beta.55",
238+
"@babel/preset-typescript": "^7.9.0",
233239
"@commitlint/cli": "^8.2.0",
234240
"@commitlint/config-conventional": "^8.2.0",
235241
"@mapbox/jsxtreme-markdown-loader": "^0.8.3",

src/app.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
export default {
2+
pages: [
3+
'pages/index/index',
4+
'pages/panel/index',
5+
'pages/basic/icon/index',
6+
'pages/basic/button/index',
7+
'pages/basic/color/index',
8+
'pages/basic/typo/index',
9+
'pages/view/noticebar/index',
10+
'pages/view/badge/index',
11+
'pages/view/tag/index',
12+
'pages/view/avatar/index',
13+
'pages/view/article/index',
14+
'pages/view/timeline/index',
15+
'pages/view/swiper/index',
16+
'pages/view/load-more/index',
17+
'pages/view/divider/index',
18+
'pages/view/countdown/index',
19+
'pages/view/steps/index',
20+
'pages/view/curtain/index',
21+
'pages/action/toast/index',
22+
'pages/action/modal/index',
23+
'pages/action/progress/index',
24+
'pages/action/action-sheet/index',
25+
'pages/action/swipe-action/index',
26+
'pages/action/activity-indicator/index',
27+
'pages/action/message/index',
28+
'pages/navigation/drawer/index',
29+
'pages/navigation/pagination/index',
30+
'pages/navigation/tabs/index',
31+
'pages/navigation/tabbar/index',
32+
'pages/navigation/segmented-control/index',
33+
'pages/navigation/navbar/index',
34+
'pages/navigation/indexes/index',
35+
'pages/layout/flex/index',
36+
'pages/layout/grid/index',
37+
'pages/layout/float-layout/index',
38+
'pages/layout/card/index',
39+
'pages/layout/list/index',
40+
'pages/layout/accordion/index',
41+
'pages/form/form/index',
42+
'pages/form/checkbox/index',
43+
'pages/form/input/index',
44+
'pages/form/input-number/index',
45+
'pages/form/radio/index',
46+
'pages/form/textarea/index',
47+
'pages/form/switch/index',
48+
'pages/form/rate/index',
49+
'pages/form/picker/index',
50+
'pages/form/picker-view/index',
51+
'pages/form/slider/index',
52+
'pages/form/search-bar/index',
53+
'pages/form/image-picker/index',
54+
'pages/form/range/index',
55+
'pages/advanced/calendar/index',
56+
'pages/theme/index'
57+
],
58+
window: {
59+
backgroundTextStyle: 'light',
60+
navigationBarBackgroundColor: '#fff',
61+
navigationBarTitleText: 'WeChat',
62+
navigationBarTextStyle: 'black'
63+
}
64+
}

src/app.tsx

Lines changed: 11 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,17 @@
1-
import Taro, { Component } from '@tarojs/taro'
2-
import Index from './pages/index/index'
1+
import PropTypes, { InferProps } from 'prop-types'
2+
import React from 'react'
33
import './app.scss'
44

5-
class App extends Component {
6-
config: Taro.Config = {
7-
pages: [
8-
'pages/index/index',
9-
'pages/panel/index',
10-
'pages/basic/icon/index',
11-
'pages/basic/button/index',
12-
'pages/basic/color/index',
13-
'pages/basic/typo/index',
14-
'pages/view/noticebar/index',
15-
'pages/view/badge/index',
16-
'pages/view/tag/index',
17-
'pages/view/avatar/index',
18-
'pages/view/article/index',
19-
'pages/view/timeline/index',
20-
'pages/view/swiper/index',
21-
'pages/view/load-more/index',
22-
'pages/view/divider/index',
23-
'pages/view/countdown/index',
24-
'pages/view/steps/index',
25-
'pages/view/curtain/index',
26-
'pages/action/toast/index',
27-
'pages/action/modal/index',
28-
'pages/action/progress/index',
29-
'pages/action/action-sheet/index',
30-
'pages/action/swipe-action/index',
31-
'pages/action/activity-indicator/index',
32-
'pages/action/message/index',
33-
'pages/navigation/drawer/index',
34-
'pages/navigation/pagination/index',
35-
'pages/navigation/tabs/index',
36-
'pages/navigation/tabbar/index',
37-
'pages/navigation/segmented-control/index',
38-
'pages/navigation/navbar/index',
39-
'pages/navigation/indexes/index',
40-
'pages/layout/flex/index',
41-
'pages/layout/grid/index',
42-
'pages/layout/float-layout/index',
43-
'pages/layout/card/index',
44-
'pages/layout/list/index',
45-
'pages/layout/accordion/index',
46-
'pages/form/form/index',
47-
'pages/form/checkbox/index',
48-
'pages/form/input/index',
49-
'pages/form/input-number/index',
50-
'pages/form/radio/index',
51-
'pages/form/textarea/index',
52-
'pages/form/switch/index',
53-
'pages/form/rate/index',
54-
'pages/form/picker/index',
55-
'pages/form/picker-view/index',
56-
'pages/form/slider/index',
57-
'pages/form/search-bar/index',
58-
'pages/form/image-picker/index',
59-
'pages/form/range/index',
60-
'pages/advanced/calendar/index',
61-
'pages/theme/index'
62-
],
63-
window: {
64-
backgroundTextStyle: 'light',
65-
navigationBarBackgroundColor: '#fff',
66-
navigationBarTitleText: 'WeChat',
67-
navigationBarTextStyle: 'black'
68-
}
69-
}
70-
71-
componentDidMount () {}
72-
73-
componentDidShow () {}
74-
75-
componentDidHide () {}
5+
class App extends React.Component {
6+
public static propTypes: InferProps<{}>
767

77-
componentCatchError () {}
78-
79-
render () {
80-
return <Index />
8+
public render(): React.ReactNode {
9+
return this.props.children
8110
}
8211
}
8312

84-
Taro.render(<App />, document.getElementById('app'))
13+
App.propTypes = {
14+
children: PropTypes.node
15+
}
16+
17+
export default App

src/common/utils.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ import { SelectorQuery } from '@tarojs/taro/types/index'
33

44
const ENV = Taro.getEnv()
55

6-
function delay(delayTime = 500): Promise<null> {
6+
function delay(delayTime = 25): Promise<null> {
77
return new Promise(resolve => {
8-
if ([Taro.ENV_TYPE.WEB, Taro.ENV_TYPE.SWAN].includes(ENV)) {
9-
setTimeout(() => {
10-
resolve()
11-
}, delayTime)
12-
return
13-
}
14-
resolve()
8+
setTimeout(() => {
9+
resolve()
10+
}, delayTime)
1511
})
1612
}
1713

@@ -20,9 +16,8 @@ function delayQuerySelector(
2016
selectorStr: string,
2117
delayTime = 500
2218
): Promise<any[]> {
23-
const selector: SelectorQuery = Taro.createSelectorQuery()
24-
2519
return new Promise(resolve => {
20+
const selector: SelectorQuery = Taro.createSelectorQuery()
2621
delay(delayTime).then(() => {
2722
selector
2823
.select(selectorStr)

src/components/calendar/body/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
Calendar
99
} from 'types/calendar'
1010
import { Swiper, SwiperItem, View } from '@tarojs/components'
11-
import { BaseEvent, ITouch, ITouchEvent } from '@tarojs/components/types/common'
11+
import {
12+
BaseEventOrig,
13+
ITouch,
14+
ITouchEvent
15+
} from '@tarojs/components/types/common'
1216
import { delayQuerySelector } from '../../../common/utils'
1317
import generateCalendarGroup from '../common/helper'
1418
import AtCalendarDateList from '../ui/date-list/index'
@@ -213,7 +217,7 @@ export default class AtCalendarBody extends Taro.Component<
213217
this.animateMoveSlide(0)
214218
}
215219

216-
private handleChange = (e: BaseEvent): void => {
220+
private handleChange = (e: BaseEventOrig<any>): void => {
217221
const { current, source } = e.detail
218222

219223
if (source === 'touch') {

src/components/calendar/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Calendar
1111
} from 'types/calendar'
1212
import { View } from '@tarojs/components'
13-
import { BaseEvent } from '@tarojs/components/types/common'
13+
import { BaseEventOrig } from '@tarojs/components/types/common'
1414
import AtCalendarBody from './body/index'
1515
import AtCalendarController from './controller/index'
1616

@@ -213,9 +213,7 @@ export default class AtCalendar extends Taro.Component<
213213
}
214214

215215
// picker 选择时间改变时触发
216-
private handleSelectDate = (
217-
e: BaseEvent & { detail: { value: string } }
218-
): void => {
216+
private handleSelectDate = (e: BaseEventOrig<{ value: string }>): void => {
219217
const { value } = e.detail
220218

221219
const _generateDate: Dayjs = dayjs(value)

0 commit comments

Comments
 (0)