Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro v #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.zip
*.rar
*.via
*.tmp
*.err
*.idea
*.vscode
12 changes: 12 additions & 0 deletions myApp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

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

[*.md]
trim_trailing_whitespace = false
8 changes: 8 additions & 0 deletions myApp/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
},
"parser": "babel-eslint"
}
4 changes: 4 additions & 0 deletions myApp/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
registry=https://r.cnpmjs.org
disturl=https://r.cnpmjs.org/node
sass_binary_site=https://r.cnpmjs.org/node-sass/
fse_binary_host_mirror=https://r.cnpmjs.org/fsevents
9 changes: 9 additions & 0 deletions myApp/config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
},
weapp: {},
h5: {}
}
103 changes: 103 additions & 0 deletions myApp/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const config = {
projectName: 'menory',
date: '2019-2-1',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: {
babel: {
sourceMap: true,
presets: [
['env', {
modules: false
}]
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread'
]
}
},
defineConstants: {
},
copy: {
patterns: [
{ from: 'src/assets/image/icon/', to: 'dist/assets/image/icon/', ignore: '*.js' }, // 指定需要 copy 的目录
],
options: {
}
},
weapp: {
module: {
postcss: {
autoprefixer: {
enable: false,
config: {
browsers: [
'last 3 versions',
'Android >= 6',
'ios >= 10'
]
}
},
pxtransform: {
enable: true,
config: {

}
},
url: {
enable: true,
config: {
limit: 10240 // 设定转换尺寸上限
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
},
h5: {
publicPath: '/',
staticDirectory: 'static',
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
}
}

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 myApp/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: {}
}
61 changes: 61 additions & 0 deletions myApp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "myApp",
"version": "1.0.0",
"private": true,
"description": "test taro",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.2.12",
"@tarojs/components": "1.2.12",
"@tarojs/redux": "1.2.12",
"@tarojs/redux-h5": "1.2.12",
"@tarojs/router": "1.2.12",
"@tarojs/taro": "1.2.12",
"@tarojs/taro-alipay": "1.2.12",
"@tarojs/taro-h5": "1.2.12",
"@tarojs/taro-swan": "1.2.12",
"@tarojs/taro-tt": "1.2.12",
"@tarojs/taro-weapp": "1.2.12",
"nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"util.js": "^0.0.0"
},
"devDependencies": {
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"@tarojs/plugin-babel": "1.2.12",
"@tarojs/plugin-csso": "1.2.12",
"@tarojs/plugin-less": "1.2.12",
"@tarojs/plugin-uglifyjs": "1.2.12",
"@tarojs/webpack-runner": "1.2.12",
"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",
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-config-taro": "1.2.12",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-taro": "1.2.12"
}
}
18 changes: 18 additions & 0 deletions myApp/project.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"miniprogramRoot": "dist/",
"projectname": "memory-training",
"description": "taro version miniGame",
"appid": "wx03b1b47e8eb522cf",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"nodeModules": false,
"autoAudits": false
},
"compileType": "miniprogram",
"libVersion": "2.5.2",
"condition": {}
}
24 changes: 24 additions & 0 deletions myApp/src/actions/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
ADD,
MINUS
} from '../constants/counter'

export const add = () => {
return {
type: ADD
}
}
export const minus = () => {
return {
type: MINUS
}
}

// 异步的action
export function asyncAdd () {
return dispatch => {
setTimeout(() => {
dispatch(add())
}, 2000)
}
}
10 changes: 10 additions & 0 deletions myApp/src/actions/globalData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SETUSERINFO } from '../constants/globalData'

export const setUserInfo = (param) => {
return {
type: SETUSERINFO,
payload: {
...param
}
}
}
42 changes: 42 additions & 0 deletions myApp/src/actions/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { CHANGESTATE, BASELIST, REFRESH } from '../constants/icon'

export const changeState = (param) => {
return {
type: CHANGESTATE,
payload: {
...param
}
}
}

export function asyncChangeState (param) {
return (dispatch, getState) => {
dispatch({
type: CHANGESTATE,
payload: {
...param
}
})
const state = getState()
return Promise.resolve(state)
}
}

export function baseList(param) {
return (dispatch, getState) => {
dispatch({
type: BASELIST,
payload: {
...param
}
})
const state = getState()
return Promise.resolve(state)
}
}

export function refresh() {
return {
type: REFRESH
}
}
Loading