Skip to content

Commit 2567494

Browse files
committed
update : uni-app 和 taro 更新到最新版
1 parent ac5a461 commit 2567494

27 files changed

+10350
-7143
lines changed

taro/config/dev.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module.exports = {
22
env: {
33
NODE_ENV: '"development"'
44
},
5-
defineConstants: {
6-
},
7-
weapp: {},
5+
defineConstants: {},
6+
mini: {},
87
h5: {}
98
}

taro/config/index.js

Lines changed: 59 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const config = {
2-
projectName: 'taro',
3-
date: '2019-3-19',
2+
projectName: 'taro-test',
3+
date: '2020-3-26',
44
designWidth: 750,
55
deviceRatio: {
66
'640': 2.34 / 2,
@@ -9,87 +9,74 @@ const config = {
99
},
1010
sourceRoot: 'src',
1111
outputRoot: 'dist',
12-
plugins: {
13-
babel: {
14-
sourceMap: true,
15-
presets: [
16-
['env', {
17-
modules: false
18-
}]
19-
],
20-
plugins: [
21-
'transform-decorators-legacy',
22-
'transform-class-properties',
23-
'transform-object-rest-spread'
24-
]
25-
}
12+
babel: {
13+
sourceMap: true,
14+
presets: [
15+
['env', {
16+
modules: false
17+
}]
18+
],
19+
plugins: [
20+
'transform-decorators-legacy',
21+
'transform-class-properties',
22+
'transform-object-rest-spread',
23+
['transform-runtime', {
24+
'helpers': false,
25+
'polyfill': false,
26+
'regenerator': true,
27+
'moduleName': 'babel-runtime'
28+
}]
29+
]
2630
},
31+
plugins: [],
2732
defineConstants: {
2833
},
29-
copy: {
30-
patterns: [
31-
],
32-
options: {
33-
}
34-
},
35-
weapp: {
36-
module: {
37-
postcss: {
38-
autoprefixer: {
39-
enable: true,
40-
config: {
41-
browsers: [
42-
'last 3 versions',
43-
'Android >= 4.1',
44-
'ios >= 8'
45-
]
46-
}
47-
},
48-
pxtransform: {
49-
enable: true,
50-
config: {
51-
52-
}
53-
},
54-
url: {
55-
enable: true,
56-
config: {
57-
limit: 10240 // 设定转换尺寸上限
58-
}
59-
},
60-
cssModules: {
61-
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
62-
config: {
63-
namingPattern: 'module', // 转换模式,取值为 global/module
64-
generateScopedName: '[name]__[local]___[hash:base64:5]'
65-
}
34+
mini: {
35+
postcss: {
36+
pxtransform: {
37+
enable: true,
38+
config: {}
39+
},
40+
url: {
41+
enable: true,
42+
config: {
43+
limit: 10240 // 设定转换尺寸上限
44+
}
45+
},
46+
cssModules: {
47+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
48+
config: {
49+
namingPattern: 'module', // 转换模式,取值为 global/module
50+
generateScopedName: '[name]__[local]___[hash:base64:5]'
6651
}
6752
}
6853
}
6954
},
7055
h5: {
71-
publicPath: '/',
56+
publicPath: process.env.NODE_ENV==='development'?'/':'./',
7257
staticDirectory: 'static',
73-
module: {
74-
postcss: {
75-
autoprefixer: {
76-
enable: true,
77-
config: {
78-
browsers: [
79-
'last 3 versions',
80-
'Android >= 4.1',
81-
'ios >= 8'
82-
]
83-
}
84-
},
85-
cssModules: {
86-
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
87-
config: {
88-
namingPattern: 'module', // 转换模式,取值为 global/module
89-
generateScopedName: '[name]__[local]___[hash:base64:5]'
90-
}
58+
postcss: {
59+
autoprefixer: {
60+
enable: true,
61+
config: {
62+
browsers: [
63+
'last 3 versions',
64+
'Android >= 4.1',
65+
'ios >= 8'
66+
]
67+
}
68+
},
69+
cssModules: {
70+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
71+
config: {
72+
namingPattern: 'module', // 转换模式,取值为 global/module
73+
generateScopedName: '[name]__[local]___[hash:base64:5]'
9174
}
9275
}
76+
},
77+
router: {
78+
mode: 'hash', // 或者是 'browser'
79+
basename: '/testProject/taro/'
9380
}
9481
}
9582
}

taro/config/prod.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ module.exports = {
22
env: {
33
NODE_ENV: '"production"'
44
},
5-
defineConstants: {
6-
},
7-
weapp: {},
8-
h5: {}
5+
defineConstants: {},
6+
mini: {},
7+
h5: {
8+
/**
9+
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
10+
* 参考代码如下:
11+
* webpackChain (chain) {
12+
* chain.plugin('analyzer')
13+
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
14+
* }
15+
*/
16+
}
917
}

taro/package.json

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,71 @@
11
{
2-
"name": "taro",
3-
"version": "1.0.0",
4-
"private": true,
5-
"description": "",
6-
"scripts": {
7-
"build:weapp": "taro build --type weapp",
8-
"build:swan": "taro build --type swan",
9-
"build:alipay": "taro build --type alipay",
10-
"build:tt": "taro build --type tt",
11-
"build:h5": "taro build --type h5",
12-
"build:rn": "taro build --type rn",
13-
"dev:weapp": "npm run build:weapp -- --watch",
14-
"dev:swan": "npm run build:swan -- --watch",
15-
"dev:alipay": "npm run build:alipay -- --watch",
16-
"dev:tt": "npm run build:tt -- --watch",
17-
"dev:h5": "npm run build:h5 -- --watch",
18-
"dev:rn": "npm run build:rn -- --watch"
19-
},
20-
"author": "",
21-
"license": "MIT",
22-
"dependencies": {
23-
"@tarojs/components": "1.3.0-beta.3",
24-
"@tarojs/rn-runner": "1.3.0-beta.3",
25-
"@tarojs/router": "1.3.0-beta.3",
26-
"@tarojs/taro": "1.3.0-beta.3",
27-
"@tarojs/taro-alipay": "1.3.0-beta.3",
28-
"@tarojs/taro-h5": "1.3.0-beta.3",
29-
"@tarojs/taro-swan": "1.3.0-beta.3",
30-
"@tarojs/taro-tt": "1.2.20",
31-
"@tarojs/taro-weapp": "1.3.0-beta.3",
32-
"nerv-devtools": "^1.3.9",
33-
"nervjs": "^1.3.9",
34-
"postcss": "^7.0.14",
35-
"stylelint": "^9.10.1",
36-
"stylelint-config-taro-rn": "^1.2.22",
37-
"stylelint-taro-rn": "^1.2.22"
38-
},
39-
"devDependencies": {
40-
"@tarojs/plugin-babel": "1.3.0-beta.3",
41-
"@tarojs/plugin-csso": "1.3.0-beta.3",
42-
"@tarojs/plugin-sass": "1.3.0-beta.3",
43-
"@tarojs/plugin-uglifyjs": "1.3.0-beta.3",
44-
"@tarojs/webpack-runner": "1.3.0-beta.3",
45-
"@types/react": "^16.4.6",
46-
"@types/webpack-env": "^1.13.6",
47-
"babel-eslint": "^8.2.3",
48-
"babel-plugin-transform-class-properties": "^6.24.1",
49-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
50-
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
51-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
52-
"babel-preset-env": "^1.6.1",
53-
"eslint": "^4.19.1",
54-
"eslint-config-taro": "1.3.0-beta.3",
55-
"eslint-plugin-import": "^2.12.0",
56-
"eslint-plugin-react": "^7.8.2",
57-
"eslint-plugin-taro": "1.3.0-beta.3"
58-
}
2+
"name": "taro-test",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "taro 性能测试",
6+
"templateInfo": {
7+
"name": "default",
8+
"typescript": false,
9+
"css": "none"
10+
},
11+
"scripts": {
12+
"build:weapp": "taro build --type weapp",
13+
"build:swan": "taro build --type swan",
14+
"build:alipay": "taro build --type alipay",
15+
"build:tt": "taro build --type tt",
16+
"build:h5": "taro build --type h5",
17+
"build:rn": "taro build --type rn",
18+
"build:qq": "taro build --type qq",
19+
"build:quickapp": "taro build --type quickapp",
20+
"dev:weapp": "npm run build:weapp -- --watch",
21+
"dev:swan": "npm run build:swan -- --watch",
22+
"dev:alipay": "npm run build:alipay -- --watch",
23+
"dev:tt": "npm run build:tt -- --watch",
24+
"dev:h5": "npm run build:h5 -- --watch",
25+
"dev:rn": "npm run build:rn -- --watch",
26+
"dev:qq": "npm run build:qq -- --watch",
27+
"dev:quickapp": "npm run build:quickapp -- --watch"
28+
},
29+
"author": "",
30+
"license": "MIT",
31+
"dependencies": {
32+
"@tarojs/components": "2.0.7",
33+
"@tarojs/components-qa": "2.0.7",
34+
"@tarojs/router": "2.0.7",
35+
"@tarojs/taro": "2.0.7",
36+
"@tarojs/taro-alipay": "2.0.7",
37+
"@tarojs/taro-h5": "2.0.7",
38+
"@tarojs/taro-qq": "2.0.7",
39+
"@tarojs/taro-quickapp": "2.0.7",
40+
"@tarojs/taro-swan": "2.0.7",
41+
"@tarojs/taro-tt": "2.0.7",
42+
"@tarojs/taro-weapp": "2.0.7",
43+
"@tarojs/taro-rn": "2.0.7",
44+
"babel-runtime": "^6.26.0",
45+
"regenerator-runtime": "0.11.1",
46+
"nervjs": "^1.5.5",
47+
"nerv-devtools": "^1.5.5"
48+
},
49+
"devDependencies": {
50+
"@types/react": "^16.4.6",
51+
"@types/webpack-env": "^1.13.6",
52+
"@tarojs/mini-runner": "2.0.7",
53+
"@tarojs/webpack-runner": "2.0.7",
54+
"babel-plugin-transform-class-properties": "^6.24.1",
55+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
56+
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
57+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
58+
"babel-plugin-transform-runtime": "^6.23.0",
59+
"babel-preset-env": "^1.6.1",
60+
"babel-eslint": "^8.2.3",
61+
"eslint": "^5.16.0",
62+
"eslint-config-taro": "2.0.7",
63+
"eslint-plugin-react": "^7.8.2",
64+
"eslint-plugin-react-hooks": "^1.6.1",
65+
"eslint-plugin-import": "^2.12.0",
66+
"stylelint": "9.3.0",
67+
"stylelint-config-taro-rn": "2.0.7",
68+
"stylelint-taro-rn": "2.0.7",
69+
"eslint-plugin-taro": "2.0.7"
70+
}
5971
}

taro/project.config.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
2-
"miniprogramRoot": "dist/",
3-
"projectname": "taro",
4-
"description": "",
5-
"appid": "touristappid",
6-
"setting": {
7-
"urlCheck": true,
8-
"es6": false,
9-
"postcss": false,
10-
"minified": false,
11-
"newFeature": true
12-
},
13-
"compileType": "miniprogram",
14-
"condition": {}
15-
}
2+
"miniprogramRoot": "./dist",
3+
"projectname": "taro-test",
4+
"description": "taro 性能测试",
5+
"appid": "touristappid",
6+
"setting": {
7+
"urlCheck": true,
8+
"es6": false,
9+
"postcss": false,
10+
"minified": false
11+
},
12+
"compileType": "miniprogram"
13+
}

taro/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta name="format-detection" content="telephone=no,address=no">
99
<meta name="apple-mobile-web-app-status-bar-style" content="white">
1010
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11-
<title>Taro</title>
11+
<title></title>
1212
<script>
1313
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
1414
</script>

taro/src/utils/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const PERF_MAX = 20
2-
export const PERF_LIKE_MAX = 10
1+
export const PERF_MAX = 50
2+
export const PERF_LIKE_MAX = 20
33
export const PERF_AUTO = true
44
export const PERF_USING_COMPONENTS = true

taro/src/utils/interface.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import Taro from '@tarojs/taro'
1+
import Taro from '@tarojs/taro'
2+
3+
const {
4+
PERF_LIKE_MAX,
5+
} = require('./config')
26
/**
37
* 是否开始测算页面性能
48
*/
@@ -9,12 +13,13 @@ export function shouldMeasurePage(data) {
913
* 是否开始测试组件性能
1014
*/
1115
export function shouldMeasureComponent(data) {
12-
return this.$perf.count > 0 && Object.keys(data).length > 1
16+
return this.$perf.count > 0 && Object.keys(data).length > 0
1317
}
1418
/**
1519
* 获取组件 trigger 方法
1620
*/
1721
export function getComponentTriggerFn() {
22+
console.log(`当前点击第${this.$perf.count}次,共${PERF_LIKE_MAX}次`)
1823
return function componentTrigger() {
1924
return this.$component.trigger()
2025
}

0 commit comments

Comments
 (0)