Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
addInsured-AIA-POC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liujianghai
addInsured-AIA-POC
Commits
daa95de6
Commit
daa95de6
authored
Feb 24, 2020
by
marsandheart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路由和全局变量整理
parent
6abf43ec
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
26 deletions
+109
-26
package.json
package.json
+1
-1
App.js
src/App.js
+7
-18
Main.js
src/Main.js
+1
-5
Router.js
src/Router.js
+20
-0
index.js
src/index.js
+2
-2
count.js
src/store/count.js
+30
-0
index.js
src/store/index.js
+10
-0
Count.js
src/views/Count.js
+38
-0
No files found.
package.json
View file @
daa95de6
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
"build"
:
"react-scripts build"
,
"build"
:
"react-scripts build"
,
"test"
:
"react-scripts test"
,
"test"
:
"react-scripts test"
,
"eject"
:
"react-scripts eject"
,
"eject"
:
"react-scripts eject"
,
"
pr
t"
:
"node prt.js"
"
lin
t"
:
"node prt.js"
},
},
"eslintConfig"
:
{
"eslintConfig"
:
{
"extends"
:
"react-app"
"extends"
:
"react-app"
...
...
src/App.js
View file @
daa95de6
import
React
from
'react'
;
import
React
from
'react'
;
import
logo
from
'./logo.svg'
;
import
{
Provider
}
from
'react-redux'
;
import
'./App.css'
;
import
store
from
'./store/index'
;
import
Router
from
'./Router'
;
function
App
()
{
function
App
()
{
return
(
return
(
<
div
className
=
"App"
>
<
Provider
store
=
{
store
}
>
<
header
className
=
"App-header"
>
<
Router
/>
<
img
src
=
{
logo
}
className
=
"App-logo"
alt
=
"logo"
/>
<
/Provider
>
<
p
>
Edit
<
code
>
src
/
App
.
js
<
/code> and save to reload
.
<
/p
>
<
a
className
=
"App-link"
href
=
"https://reactjs.org"
target
=
"_blank"
rel
=
"noopener noreferrer"
>
Learn
React
<
/a
>
<
/header
>
<
/div
>
);
);
}
}
...
...
src/Main.js
View file @
daa95de6
...
@@ -2,11 +2,7 @@ import React from 'react';
...
@@ -2,11 +2,7 @@ import React from 'react';
import
'./App.css'
;
import
'./App.css'
;
function
App
()
{
function
App
()
{
return
(
return
<
div
className
=
"App-header"
>
友邦加保项目
预览版
<
/div>
;
<
div
className
=
"App-header"
>
友邦加保项目
预览版
<
/div
>
);
}
}
export
default
App
;
export
default
App
;
src/Router.js
0 → 100644
View file @
daa95de6
import
React
from
'react'
;
import
{
BrowserRouter
as
Router
,
Switch
,
Route
}
from
'react-router-dom'
;
import
DoubleRecord
from
'./pages/DoubleRecord'
;
import
InsuredInfo
from
'./pages/InsuredInfo'
;
export
default
function
Routers
()
{
return
(
<
Router
>
<
Switch
>
<
Route
exact
path
=
"/"
>
<
InsuredInfo
/>
<
/Route
>
<
Route
path
=
"/doubleRecord"
>
<
DoubleRecord
/>
<
/Route
>
<
/Switch
>
<
/Router
>
);
}
src/index.js
View file @
daa95de6
import
React
from
'react'
;
import
React
from
'react'
;
import
ReactDOM
from
'react-dom'
;
import
ReactDOM
from
'react-dom'
;
import
'./index.css'
;
import
'./index.css'
;
import
Main
from
'./Main
'
;
import
App
from
'./App
'
;
import
*
as
serviceWorker
from
'./serviceWorker'
;
import
*
as
serviceWorker
from
'./serviceWorker'
;
ReactDOM
.
render
(
<
Main
/>
,
document
.
getElementById
(
'root'
));
ReactDOM
.
render
(
<
App
/>
,
document
.
getElementById
(
'root'
));
// If you want your app to work offline and load faster, you can change
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// unregister() to register() below. Note this comes with some pitfalls.
...
...
src/store/count.js
0 → 100644
View file @
daa95de6
// 这里可以看作 将原始redux中的action reducer都放入了同一个文件,
// reducers和effects都可作为方法给组件调用,区别在于effects中可以写较为复杂逻辑和异步方法,reducers中为纯函数
const
count
=
{
state
:
0
,
reducers
:
{
add
(
state
,
payload
)
{
return
state
+
payload
;
},
double
(
state
)
{
return
state
*
2
;
}
},
effects
:
{
async
addAsync
(
payload
,
rootState
)
{
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
1000
));
this
.
add
(
payload
);
},
async
doubleAsync
(
payload
,
rootState
)
{
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
1000
));
this
.
double
();
},
async
addThenDoubleAsync
(
payload
,
rootState
)
{
await
this
.
addAsync
(
payload
);
await
this
.
doubleAsync
();
}
}
};
export
default
count
;
src/store/index.js
0 → 100644
View file @
daa95de6
import
{
init
}
from
'@rematch/core'
;
import
count
from
'./count'
;
const
store
=
init
({
models
:
{
count
}
});
export
default
store
;
src/views/Count.js
0 → 100644
View file @
daa95de6
import
React
from
'react'
;
import
{
connect
}
from
'react-redux'
;
const
Count
=
(
props
)
=>
(
<
div
>
<
div
>
the
count
is
{
props
.
count
}
<
/div
>
<
div
>
<
div
>
<
button
onClick
=
{
props
.
add
}
>
add
<
/button>加
一
<
/div
>
<
div
>
<
button
onClick
=
{
props
.
double
}
>
double
<
/button>加
倍
<
/div
>
<
div
>
<
button
onClick
=
{
props
.
addAsync
}
>
addAsync
<
/button>一秒钟后加
一
<
/div
>
<
div
>
<
button
onClick
=
{
props
.
doubleAsync
}
>
doubleAsync
<
/button>一秒钟后加
倍
<
/div
>
<
div
>
<
button
onClick
=
{
props
.
addThenDoubleAsync
}
>
addThenDoubleAsync
<
/button>异步加一然后异步加
倍
各一秒钟
<
/div
>
<
/div
>
<
/div
>
);
const
mapState
=
(
state
)
=>
({
count
:
state
.
count
});
const
mapDispatch
=
({
count
:
{
add
,
double
,
addAsync
,
doubleAsync
,
addThenDoubleAsync
}
})
=>
({
add
:
()
=>
add
(
1
),
double
,
addAsync
:
()
=>
addAsync
(
1
),
doubleAsync
,
addThenDoubleAsync
:
()
=>
addThenDoubleAsync
(
1
)
});
export
default
connect
(
mapState
,
mapDispatch
)(
Count
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment