Skip to content

Commit b8805f7

Browse files
author
dongguoyang
committed
first commit
0 parents  commit b8805f7

File tree

141 files changed

+5615
-0
lines changed

Some content is hidden

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

141 files changed

+5615
-0
lines changed

.babelrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react",
5+
"stage-0",
6+
"flow"
7+
],
8+
"env": {
9+
"development": {
10+
"presets": [
11+
"react-hmre"
12+
]
13+
}
14+
},
15+
"plugins": [
16+
"transform-decorators-legacy",
17+
"transform-class-properties",
18+
"syntax-dynamic-import", [
19+
"import",
20+
{
21+
"libraryName": "antd",
22+
"libraryDirectory": "es",
23+
"style": true
24+
}
25+
]
26+
]
27+
}

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
# editorconfig-tools is unable to ignore longs strings or urls
20+
max_line_length = null

.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node-modules/**/*
2+
dev/**/*
3+
dist/**/*
4+
config/*
5+
config/**/*
6+
mockService/**/*
7+
tempSTATIC/**/*
8+
src/assets/**/*

.eslintrc.js

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
module.exports = {
2+
plugins: ['react', 'jsdoc', 'css-modules', 'prettier'],
3+
parser: 'babel-eslint',
4+
extends: [
5+
'airbnb',
6+
// 'plugin:flowtype/recommended',
7+
'plugin:css-modules/recommended',
8+
'prettier',
9+
// 'prettier/flowtype',
10+
'prettier/react'
11+
],
12+
parserOptions: {
13+
sourceType: 'module',
14+
allowImportExportEverywhere: true,
15+
ecmaVersion: 6,
16+
ecmaFeatures: {
17+
legacyDecorators: true,
18+
jsx: true,
19+
experimentalObjectRestSpread: true
20+
}
21+
},
22+
env: {
23+
browser: true,
24+
node: true,
25+
es6: true
26+
},
27+
rules: {
28+
// Common js rules
29+
'brace-style': [
30+
2,
31+
'1tbs',
32+
{
33+
allowSingleLine: true
34+
}
35+
],
36+
camelcase: 0,
37+
curly: 2,
38+
eqeqeq: 2,
39+
'no-extend-native': 2,
40+
'no-proto': 2,
41+
'no-caller': 2,
42+
'no-unused-vars': [
43+
2,
44+
{
45+
vars: 'all',
46+
args: 'none'
47+
}
48+
],
49+
'new-cap': 0,
50+
quotes: [2, 'single'],
51+
'max-depth': [2, 3],
52+
'max-statements': [2, 45],
53+
'max-len': [2, 200],
54+
'no-eq-null': 2,
55+
'operator-linebreak': 2,
56+
'no-multiple-empty-lines': [
57+
2,
58+
{
59+
max: 2
60+
}
61+
],
62+
'no-mixed-spaces-and-tabs': 0,
63+
'space-unary-ops': 2,
64+
'no-multi-spaces': 2,
65+
'space-before-blocks': 0,
66+
'keyword-spacing': 0,
67+
'space-infix-ops': 0,
68+
'comma-spacing': [
69+
0,
70+
{
71+
before: false,
72+
after: true
73+
}
74+
],
75+
'comma-dangle': 0,
76+
'wrap-iife': 2,
77+
'no-extra-semi': 2,
78+
'semi-spacing': 2,
79+
'spaced-comment': 2,
80+
'func-names': 0,
81+
'no-else-return': 0,
82+
83+
// NodeJs rules
84+
'block-scoped-var': 2,
85+
'global-require': 0,
86+
'no-mixed-requires': 2,
87+
'no-new-require': 2,
88+
89+
// ES6 rules
90+
'arrow-spacing': 2,
91+
'no-useless-constructor': 0,
92+
'no-const-assign': 2,
93+
'no-var': 2,
94+
'prefer-const': 0,
95+
'class-methods-use-this': 0,
96+
97+
// React
98+
'jsx-quotes': [2, 'prefer-double'],
99+
'react/jsx-uses-react': 1,
100+
'react/jsx-uses-vars': 1,
101+
'react/no-array-index-key': 0,
102+
'react/sort-comp': 0,
103+
104+
// Allow .js files to use JSX syntax
105+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
106+
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx'] }],
107+
// Prefer destructuring from arrays and objects
108+
// http://eslint.org/docs/rules/prefer-destructuring
109+
'prefer-destructuring': 'off',
110+
111+
// Recommend not to leave any console.log in your code
112+
// Use console.error, console.warn and console.info instead
113+
// https://eslint.org/docs/rules/no-console
114+
'no-console': [
115+
'error',
116+
{
117+
allow: ['warn', 'error', 'info']
118+
}
119+
],
120+
// Functional and class components are equivalent from React’s point of view
121+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
122+
'react/prefer-stateless-function': 'off',
123+
'react/destructuring-assignment': 'off',
124+
// Forbid the use of extraneous packages
125+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
126+
'import/no-extraneous-dependencies': ['error', { packageDir: '.' }],
127+
'import/no-unresolved': 'off',
128+
'react/prop-types': 'off',
129+
'jsx-a11y/alt-text': 'off',
130+
'jsx-a11y/label-has-associated-control': 'off',
131+
'jsx-a11y/anchor-is-valid': 'off',
132+
'jsx-a11y/label-has-for': 'off',
133+
'no-script-url': 'off',
134+
'react/jsx-no-target-blank': 'off',
135+
'jsx-a11y/mouse-events-have-key-events': 'off',
136+
'import/order': 'off',
137+
'react/jsx-no-bind': 'off',
138+
'no-nested-ternary': 'off',
139+
'no-underscore-dangle': 'off',
140+
'react/no-access-state-in-setstate': 'off',
141+
'consistent-return': 'off',
142+
'no-param-reassign': 'off',
143+
'react/forbid-prop-types': 'off',
144+
'no-useless-escape': 'off',
145+
'no-restricted-globals': 'off',
146+
'guard-for-in': 'off',
147+
'no-restricted-syntax': 'off',
148+
'react/no-this-in-sfc': 'off',
149+
'operator-linebreak': 'off',
150+
//'react/no-unused-state': 'off',
151+
'no-unused-expressions': 'off',
152+
'jsx-a11y/no-static-element-interactions': 'off',
153+
'jsx-a11y/aria-role': 'off',
154+
'jsx-a11y/click-events-have-key-events': 'off',
155+
'no-case-declarations': 'off',
156+
'array-callback-return': 'off',
157+
'import/prefer-default-export':'off',
158+
'import/no-extraneous-dependencies':'off'
159+
},
160+
settings: {
161+
// Allow absolute paths in imports, e.g. import Button from 'components/Button'
162+
// https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers
163+
'import/resolver': {}
164+
}
165+
};

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Automatically normalize line endings for all text-based files
2+
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
3+
* text=auto
4+
5+
# For the following file types, normalize line endings to LF on
6+
# checkin and prevent conversion to CRLF when they are checked out
7+
# (this is required in order to prevent newline related issues like,
8+
# for example, after the build script is run)
9+
.* text eol=lf
10+
*.html text eol=lf
11+
*.css text eol=lf
12+
*.less text eol=lf
13+
*.styl text eol=lf
14+
*.scss text eol=lf
15+
*.sass text eol=lf
16+
*.sss text eol=lf
17+
*.js text eol=lf
18+
*.jsx text eol=lf
19+
*.json text eol=lf
20+
*.md text eol=lf
21+
*.mjs text eol=lf
22+
*.sh text eol=lf
23+
*.svg text eol=lf
24+
*.txt text eol=lf
25+
*.xml text eol=lf

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
us
2+
.DS_Store
3+
.idea/
4+
*.lock
5+
*.log
6+
node_modules
7+
build
8+
dist
9+
temp
10+
tempHTML
11+
tempSTATIC
12+
.vscode
13+
.eslintrc
14+
.cache

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
## 介绍
2+
3+
技术栈:webpack v4 + react v16.3.2 + mc-intl + react-route v4 + antd v3 + redux
4+
功能模块:
5+
1. 单页面&支持开发热更新
6+
2. 提供本地mock服务
7+
3. 提供proxy代理服务
8+
4. 自动部署代码
9+
6. 上线版本控制,可以增量发布
10+
7. 引入antd,按需加载,支持本地化字体和主题定制
11+
8. 引入eslint,自动校验开发代码,错误代码无法提交commit
12+
13+
## 开发启动
14+
15+
```
16+
安装模块:cnpm i
17+
```
18+
```
19+
开发启动:npm run dev
20+
```
21+
22+
## 其他命令
23+
24+
代码检查:npm run precommit (需要先git add .)
25+
生成build代码:npm run build(本地打包使用,无使用场景)
26+
build代码包分析:npm run analyzer(代码分析)
27+
更新dll:npm run dll(更新完成后,需要手动更新index.html相关dll文件地址)
28+
29+
## 测试环境部署
30+
31+
build代码会自动部署到(test分支)代码仓库
32+
npm run deploy
33+
34+
## 生产上线部署
35+
36+
build代码会自动部署到(master分支)代码仓库,并且cdn地址替换成线上地址
37+
npm run publish
38+
39+
## 功能使用
40+
41+
### 目录介绍
42+
43+
COMPONENTS:通用UI组件
44+
SERVICES:api服务集合
45+
CONSTANTS:常量配置等
46+
MODULES:通用方法
47+
ASSETS:通用资源
48+
mockService:本地开发模拟服务器
49+
config:webpack打包&node服务配置
50+
dist:打包目录
51+
52+
53+
### 页面导航&菜单栏&部署
54+
55+
import Layout from 'COMPONENTS/Layout'
56+
57+
export default class App extends React.Component
58+
render() {
59+
const { children} = this.props
60+
var data ={
61+
userName:'',
62+
menuList:[],
63+
currentUrlId:'',
64+
hideNavList:['/pages/login','/pages/register']
65+
}
66+
return (
67+
<Layout data={data}>
68+
{children}
69+
</Layout>
70+
)
71+
}
72+
}
73+
74+
### 通用模块引入
75+
76+
// webpack已兼容处理,无需引入完整路径
77+
import Layout from 'COMPONENTS/Layout'
78+
import * as IndexService from 'SERVICES/index'
79+
import * as AppConst from 'CONSTANTS/AppConst'
80+
import * as Modules from 'MODULES/fetch'
81+
82+
### UI组件异步加载
83+
84+
import Loadable from 'react-loadable';
85+
import Loading from './my-loading-component';
86+
87+
const LoadableComponent = Loadable({
88+
loader: () => import('./my-component/index.js'),
89+
loading: Loading,
90+
});
91+
92+
export default class App extends React.Component {
93+
render() {
94+
return <LoadableComponent/>;
95+
}
96+
}
97+
98+
### 页面跳转
99+
100+
// 兼容单页面和多页面跳转
101+
import {locationHref} from 'MODULES/utils'
102+
103+
// 单页面
104+
locationHref('/page/home',{test:'002'},['otherParameterInCurrentPage'])
105+
106+
// 多页面
107+
locationHref('http://host/page/home',{test:'002'})

0 commit comments

Comments
 (0)