Skip to content

Commit

Permalink
h5 ready taro v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hugetiny committed Dec 23, 2018
1 parent 0426651 commit ea3f7a2
Show file tree
Hide file tree
Showing 55 changed files with 4,922 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(\w*)(?:\((.*)\))?:[ ]?(.*)$/,
headerCorrespondence: ['type', 'scope', 'subject']
}
},
rules: {
'type-empty': [2, 'never'],
'type-case': [2, 'always', 'lower-case'],
'subject-empty': [2, 'never'],
'type-enum': [2, 'always', [
'feat',
'fix',
'docs',
'style',
'refactor',
'test',
'chore',
]]
}
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules/
dist/
coverage/
.vscode/
.nyc_output/
git_stats/
yarn-offline/
docs/
jest.config.js
__mock__/
20 changes: 20 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": ["o2team", "taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }],
"class-methods-use-this": "off",
"prefer-rest-params": "off",
"arrow-body-style": "warn",
"taro/custom-component-children": "off"
},
"parser": "babel-eslint"
}
//{
// "extends": ["taro"],
// "rules": {
// "no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
// "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
// },
// "parser": "babel-eslint"
//}
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
dist/
node_modules/

yarn.lock
yarn-error.log
package-lock.json
project.config.json

.idea/
.temp/
.rn_temp/
.DS_Store
.vscode
.eslintcache
.babelrc


site/
docs/h5/
14 changes: 14 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "stylelint-config-standard",
"plugins": ["stylelint-scss"],
"rules": {
"at-rule-no-unknown": null,
"color-hex-case": null,
"block-closing-brace-newline-after": null,
"at-rule-empty-line-before":null,
"number-no-trailing-zeros": null,
"no-empty-source": null,
"unit-case": null,
"scss/at-rule-no-unknown": true
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 koppt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
weapp: {
module: {
postcss: {
// 小程序端样式引用本地资源内联
url: {
enable: true,
limit: 102400000000
}
}
}
},
env: {
NODE_ENV: '"development"'
},
defineConstants: {},
h5: {
devServer: {
disableHostCheck: true,
host: 'localhost',
// host: '0.0.0.0', // 如需局域网(如手机)访问,请更换为0.0.0.0
port: 9527,
https: false
}
}
}


91 changes: 91 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const config = {
projectName: 'quit-smoking',
date: '2018-12-28',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: {
babel: {
sourceMap: true,
presets: [
'env'
],
plugins: [
'transform-class-properties',
'transform-decorators-legacy',
'transform-object-rest-spread'
]
},
typescript: {
compilerOptions: {
allowSyntheticDefaultImports: true,
baseUrl: '.',
declaration: false,
experimentalDecorators: true,
jsx: 'preserve',
jsxFactory: 'Nerv.createElement',
module: 'commonjs',
moduleResolution: 'node',
noImplicitAny: false,
noUnusedLocals: true,
outDir: './dist/',
preserveConstEnums: true,
removeComments: false,
rootDir: '.',
sourceMap: true,
strictNullChecks: true,
target: 'es6'
},
include: [
'src/**/*'
],
exclude: [
'node_modules'
],
compileOnSave: false
}
},
defineConstants: {
},
copy: {
patterns: [],
options: {}
},
weapp: {
module: {
postcss: {
autoprefixer: {
enable: true
},
url: {
enable: true,
limit: 10240
}
}
}
},
h5: {
publicPath: '/',
staticDirectory: 'static',
esnextModules: ['taro-ui'],
module: {
postcss: {
autoprefixer: {
enable: true
}
}
}
}
}

module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
return merge({}, config, require('./prod'))
}
9 changes: 9 additions & 0 deletions config/prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
},
weapp: {},
h5: {}
}
67 changes: 67 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "quit-smoking",
"version": "0.0.1",
"private": true,
"description": "戒烟",
"main": "index.js",
"scripts": {
"dev:weapp": "npm run build:weapp -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"build:weapp": "taro build --type weapp",
"build:alipay": "taro build --type alipay",
"build:swan": "taro build --type swan",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"tep": "node template"
},
"author": "hugetiny <[email protected]>",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.2.1",
"@tarojs/components": "1.2.1",
"@tarojs/redux": "1.2.1",
"@tarojs/redux-h5": "1.2.1",
"@tarojs/rn-runner": "1.2.1",
"@tarojs/router": "1.2.1",
"@tarojs/taro": "1.2.1",
"@tarojs/taro-alipay": "1.2.1",
"@tarojs/taro-h5": "1.2.1",
"@tarojs/taro-swan": "1.2.1",
"@tarojs/taro-weapp": "1.2.1",
"dva-core": "^1.4.0",
"dva-loading": "^2.0.5",
"nervjs": "^1.3.0",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"taro-ui": "^1.5.2"
},
"devDependencies": {
"@tarojs/cli": "1.2.1",
"@tarojs/plugin-babel": "1.2.1",
"@tarojs/plugin-csso": "1.2.1",
"@tarojs/plugin-sass": "1.2.1",
"@tarojs/plugin-uglifyjs": "1.2.1",
"@tarojs/webpack-runner": "1.2.1",
"@types/react": "16.4.6",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.19.1",
"eslint-config-o2team": "^0.1.6",
"eslint-config-taro": "1.2.1",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.2.1",
"stylelint": "^9.5.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-scss": "^3.3.0"
}
}
72 changes: 72 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import '@tarojs/async-await'
import Taro, { Component } from '@tarojs/taro'
import { Provider } from '@tarojs/redux'
import Start from './pages/quitSmoking/start'
import dva from './utils/dva'
import models from './models'


// import './app.scss'
if (process.env.TARO_ENV === 'weapp') {
require('taro-ui/dist/weapp/css/index.css')
} else if (process.env.TARO_ENV === 'h5') {
require('taro-ui/dist/h5/css/index.css')
}

const dvaApp = dva.createApp({
initialState: {},
models: models,
})
const store = dvaApp.getStore()


class App extends Component {
config = {
pages: [
'pages/quitSmoking/start',
'pages/quitSmoking/info',
'pages/quitSmoking/doing'
// 'pages/quitSmoking/share'
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'quitSmoking',
navigationBarTextStyle: 'black'
},
// tabBar: {
// list: [{
// pagePath: 'pages/quitSmoking/index',
// text: '戒烟',
// iconPath: 'assets/font/smoking-ban.svg'
// // selectedIconPath: './images/tab/cart-active.png'
// }, {
// pagePath: 'pages/quitSmoking/share',
// text: '其他',
// iconPath: 'assets/font/smoking-ban.svg'
// // selectedIconPath: './images/tab/cart-active.png'
// }],
// color: '#333',
// selectedColor: '#333',
// backgroundColor: 'rgba(255,255,255,0.9)',
// borderStyle: '#ccc'
// }
}

componentDidMount () {
}

// componentDidShow () {
// }
//
// componentDidHide () {
// }

render () {
return (<Provider store={store}>
<Start />
</Provider>)
}
}

Taro.render(<App />, document.getElementById('app'))
Loading

0 comments on commit ea3f7a2

Please sign in to comment.