Skip to content

Commit 5ecd5f7

Browse files
committed
添加首页header和footer的Layout
1 parent 047983f commit 5ecd5f7

File tree

26 files changed

+153
-56
lines changed

26 files changed

+153
-56
lines changed

.eslintrc.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ module.exports = {
231231
*/
232232

233233
// 'typescript/no-constant-condition': 2,
234-
'typescript/quotemark': [true,"single","avoid-escape","jsx-double"],
234+
'typescript/quotemark': [true, 'single', 'avoid-escape', 'jsx-double'],
235235
'typescript/no-console': 0,
236236
'typescript/ordered-imports': 0,
237237
'typescript/no-namespace': 0,
@@ -259,8 +259,8 @@ module.exports = {
259259
// "public-instence-method"
260260
// ]
261261
// }],
262-
'typescript/object-literal-key-quotes': [true,"as-needed"],
263-
'typescript/no-trailing-whitespace': [false,"ignore-comments"],
262+
'typescript/object-literal-key-quotes': [true, 'as-needed'],
263+
'typescript/no-trailing-whitespace': [false, 'ignore-comments'],
264264
'typescript/class-name-casing': 2,
265265

266266
/**
@@ -274,6 +274,8 @@ module.exports = {
274274
'react/jsx-sort-prop-types': 0, // 是否排序 prop types
275275
'react/jsx-uses-react': 2, // 组件中中是否用了 react
276276
'react/jsx-uses-vars': 2, // 定义了 jsx component 没有使用
277+
'react/jsx-pascal-case': 1, // 使用jsx作为组件扩展名,采用pascal命名法 引用名采用驼峰命名
278+
'react/jsx-closing-bracket-location': 1, // 组件prop的的对齐风格
277279
'react/no-did-mount-set-state': 0, // 不要在 componentDidMount 里面设置 state
278280
'react/no-did-update-set-state': 0, // 同上
279281
'react/no-multi-comp': 0, // 一个文件里面禁止声明多个 component
@@ -282,6 +284,7 @@ module.exports = {
282284
'react/react-in-jsx-scope': 1, // 查看 jsx 是否引入 react
283285
'react/self-closing-comp': 2, // 检查是否有没有 children 的非子闭合标签
284286
'react/jsx-wrap-multilines': 1, // 不强制 return 的时候,结构的格式
287+
'react/prefer-es6-class': 1, // 使用组件类继承React.Component
285288
'react/sort-comp': [
286289
0,
287290
{
@@ -298,8 +301,6 @@ module.exports = {
298301
],
299302
'react/jsx-indent-props': 0,
300303

301-
302-
'no-var':0
304+
'no-var': 0,
303305
},
304-
305306
};

.umirc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import path from 'path';
44

5-
65
export default {
76
plugins: [
87
// ref: https://umijs.org/plugin/umi-plugin-react.html
@@ -57,6 +56,7 @@ export default {
5756
// })
5857
// );
5958
config.resolve.alias.set('src', path.resolve(__dirname, './src'));
59+
config.resolve.alias.set('component', path.resolve(__dirname, './src/component'));
6060
// config.module
6161
// .rule('save')
6262
// .test(/\.less$/)

src/assets/common/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@footer-border-color:#40aea8;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import url('../../../assets/common/index');
2+
3+
.cr-footer {
4+
width: 100%;
5+
height: 390px;
6+
border-top: 4px solid @footer-border-color;
7+
background: #fff;
8+
:global {
9+
.main {
10+
width: 1280px;
11+
margin: 0 auto;
12+
background: #ccc;
13+
}
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { Component } from 'react';
2+
import styles from './index.less';
3+
4+
export default class BasicHeader extends Component {
5+
render() {
6+
return (
7+
<footer className={styles['cr-footer']}>
8+
<div>
9+
<a href="www.baidu.com">footer</a>
10+
</div>
11+
</footer>
12+
);
13+
}
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.cr-header {
2+
width: 100%;
3+
height: 70px;
4+
:global {
5+
}
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { Component } from 'react';
2+
import styles from './index.less';
3+
4+
export default class BasicHeader extends Component {
5+
render() {
6+
return (
7+
<header className={styles['cr-header']}>
8+
<div>
9+
<a href="www.baidu.com">header</a>
10+
</div>
11+
</header>
12+
);
13+
}
14+
}

src/layouts/BasicLayout.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,17 @@
1212
color: white;
1313
margin: 0;
1414
}
15+
16+
.cr-base {
17+
width: 100%;
18+
background: #ccc;
19+
min-height: 100vh;
20+
:global {
21+
.cr-main {
22+
width: 1200px;
23+
margin: 0 auto;
24+
background: #ffffff;
25+
height: 100%;
26+
}
27+
}
28+
}

src/layouts/BasicLayout/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import styles from './index.less';
2+
import { ComProps } from 'src/type/common';
3+
import BasicHeader from 'component/common/BasicHeader/';
4+
import BasicFooter from 'component/common/BasicFooter/';
5+
6+
export default function Index(props: ComProps) {
7+
return (
8+
<section className={styles['cr-base']}>
9+
<div className={'cr-main'}>
10+
<BasicHeader />
11+
{props.children}
12+
<BasicFooter />
13+
</div>
14+
</section>
15+
);
16+
}

0 commit comments

Comments
 (0)