Skip to content

Commit

Permalink
feat: 兼容到 Taro3.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
huangli47 committed Apr 14, 2022
1 parent 3364a36 commit 66a990d
Show file tree
Hide file tree
Showing 11 changed files with 3,459 additions and 4,449 deletions.
2 changes: 1 addition & 1 deletion packages/taro-ui-demo/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const config = {
}
}

module.exports = function(merge) {
module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
Expand Down
31 changes: 25 additions & 6 deletions packages/taro-ui-demo/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@ module.exports = {
weapp: {},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
* WebpackChain 插件配置
* @docs https://github.com/neutrinojs/webpack-chain
*/
// webpackChain (chain) {
// /**
// * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
// * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
// */
// chain.plugin('analyzer')
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])

// /**
// * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
// * @docs https://github.com/chrisvfritz/prerender-spa-plugin
// */
// const path = require('path')
// const Prerender = require('prerender-spa-plugin')
// const staticDir = path.join(__dirname, '..', 'dist')
// chain
// .plugin('prerender')
// .use(new Prerender({
// staticDir,
// routes: [ '/pages/index/index' ],
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
// }))
// }
}
}
35 changes: 21 additions & 14 deletions packages/taro-ui-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,30 @@
],
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "~3.0.2",
"@tarojs/react": "~3.0.2",
"@tarojs/runtime": "~3.0.2",
"@tarojs/taro": "~3.0.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"@tarojs/components": "3.4.3",
"@tarojs/runtime": "3.4.3",
"@tarojs/taro": "3.4.3",
"@tarojs/plugin-framework-react": "3.4.3",
"@tarojs/react": "3.4.3",
"react-dom": "^17.0.0",
"react": "^17.0.0",
"taro-ui": "file:../taro-ui"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/cli": "~3.0.2",
"@tarojs/mini-runner": "~3.0.2",
"@tarojs/webpack-runner": "~3.0.2",
"@types/react": "^16.0.0",
"@types/webpack-env": "^1.13.6",
"babel-preset-taro": "~3.0.2",
"eslint-config-taro": "~3.0.2",
"typescript": "^3.8.3"
"@types/react": "^17.0.2",
"@tarojs/mini-runner": "3.4.3",
"@babel/core": "^7.8.0",
"@tarojs/webpack-runner": "3.4.3",
"babel-preset-taro": "3.4.3",
"eslint-config-taro": "3.4.3",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react-hooks": "^4.2.0",
"stylelint": "^14.4.0",
"@typescript-eslint/parser": "^4.15.1",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"typescript": "^4.1.0"
}
}
8 changes: 4 additions & 4 deletions packages/taro-ui-demo/src/pages/action/swipe-action/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default class SwipeActionPage extends React.Component<
{},
SwipeActionPageState
> {
public config: Taro.PageConfig = {
navigationBarTitleText: 'Taro UI'
}

public constructor(props: any) {
super(props)
this.state = {
Expand Down Expand Up @@ -80,6 +76,10 @@ export default class SwipeActionPage extends React.Component<
}
}

public config: Taro.PageConfig = {
navigationBarTitleText: 'Taro UI'
}

private handleClick = (item: SwipeActionOption, key: number): void => {
this.showToast(`点击了${item.text}按钮,Key: ${key}`)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-ui-demo/src/pages/basic/button/index.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: 'Taro UI Button'
})
14 changes: 5 additions & 9 deletions packages/taro-ui-demo/src/pages/basic/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import { AtButton, AtFab, AtForm } from 'taro-ui'
import { Component } from 'react'
import Taro, { ShareAppMessageReturn } from '@tarojs/taro'
import { Form, Text, View } from '@tarojs/components'
import { CommonEvent } from '@tarojs/components/types/common'
import Taro, { ShareAppMessageReturn } from '@tarojs/taro'
import { AtButton, AtFab, AtForm } from 'taro-ui'
import DocsHeader from '../../components/doc-header'
import './index.scss'

Expand All @@ -11,11 +11,7 @@ interface ButtonPageState {
isALIPAY: boolean
}

export default class ButtonPage extends React.Component<{}, ButtonPageState> {
public config: Taro.PageConfig = {
navigationBarTitleText: 'Taro UI'
}

export default class Index extends Component<{}, ButtonPageState> {
public constructor(props: any) {
super(props)
this.state = {
Expand Down Expand Up @@ -80,7 +76,7 @@ export default class ButtonPage extends React.Component<{}, ButtonPageState> {
})
}

public render(): JSX.Element {
render(): JSX.Element {
const { isWEAPP, isALIPAY } = this.state

return (
Expand Down
27 changes: 18 additions & 9 deletions packages/taro-ui-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"target": "es2017",
"module": "commonjs",
"outDir": "lib",
"removeComments": false,
"resolveJsonModule": true,
"preserveConstEnums": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"outDir": "lib",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"sourceMap": true,
"baseUrl": ".",
"rootDir": ".",
"skipLibCheck": false,
"target": "es2017",
"jsx": "react-jsx",
"allowJs": true,
"resolveJsonModule": true,
"typeRoots": [
"node_modules/@types",
"global.d.ts"
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"dist"
]
],
"compileOnSave": false
}
6 changes: 3 additions & 3 deletions packages/taro-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@tarojs/components": "~3.0.2",
"@tarojs/react": "~3.0.2",
"@tarojs/taro": "~3.0.2",
"@tarojs/components": "~3.4.3",
"@tarojs/react": "~3.4.3",
"@tarojs/taro": "~3.4.3",
"@types/classnames": "^2.2.9",
"@types/node": "^13.11.1",
"@types/react": "^16.9.23",
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-ui/src/components/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import { Button, Form, View } from '@tarojs/components'
import { ButtonProps } from '@tarojs/components/types/Button'
import { BaseEventOrig, CommonEvent } from '@tarojs/components/types/common'
import Taro from '@tarojs/taro'
import Taro, { getCurrentInstance } from '@tarojs/taro'
import { AtButtonProps, AtButtonState } from '../../../types/button'
import AtLoading from '../loading/index'

Expand Down Expand Up @@ -67,7 +67,7 @@ export default class AtButton extends React.Component<
// TODO: 3.0 this.$scope
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
this.$scope.triggerEvent('submit', event.detail, {
getCurrentInstance().page.triggerEvent('submit', event.detail, {
bubbles: true,
composed: true
})
Expand All @@ -79,7 +79,7 @@ export default class AtButton extends React.Component<
// TODO: 3.0 this.$scope
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
this.$scope.triggerEvent('reset', event.detail, {
getCurrentInstance().page.triggerEvent('reset', event.detail, {
bubbles: true,
composed: true
})
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-ui/src/components/input-number/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default class AtInputNumber extends React.Component<AtInputNumberProps> {
}

AtInputNumber.defaultProps = {
customStyle: '',
customStyle: {},
className: '',
disabled: false,
disabledInput: false,
Expand Down
Loading

0 comments on commit 66a990d

Please sign in to comment.