Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeekDIYHome
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
huanglu
GeekDIYHome
Commits
5ffbf57c
Commit
5ffbf57c
authored
Jul 27, 2020
by
huanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
parent
d876b5e9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
55 deletions
+66
-55
home.model.ts
src/models/home.model.ts
+1
-3
index.tsx
src/pages/home/index.tsx
+0
-4
index.tsx
src/router/index.tsx
+5
-6
routes.tsx
src/router/routes.tsx
+18
-0
dva.ts
src/utils/dva.ts
+42
-42
No files found.
src/models/home.model.ts
View file @
5ffbf57c
...
@@ -21,9 +21,7 @@ const HomeModel: DvaModel<HomeState> = {
...
@@ -21,9 +21,7 @@ const HomeModel: DvaModel<HomeState> = {
effects
:
{
effects
:
{
*
fetch
(
action
,
{
select
,
take
,
put
})
{
*
fetch
(
action
,
{
select
,
take
,
put
})
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
take
({
})
},
1000
);
},
1000
);
}
}
}
}
...
...
src/pages/home/index.tsx
View file @
5ffbf57c
...
@@ -16,14 +16,12 @@ import { useNavigation } from '@react-navigation/native';
...
@@ -16,14 +16,12 @@ import { useNavigation } from '@react-navigation/native';
const
Home
=
(
props
:
any
)
=>
{
const
Home
=
(
props
:
any
)
=>
{
useHeaderShow
(
true
)
useHeaderShow
(
true
)
const
insets
=
useSafeAreaInsets
()
const
[
list
,
setList
]
=
useState
([
1
,
2
,
3
])
const
[
list
,
setList
]
=
useState
([
1
,
2
,
3
])
const
[
refreshState
,
setRefreshState
]
=
useState
(
RefreshState
.
Idle
)
const
[
refreshState
,
setRefreshState
]
=
useState
(
RefreshState
.
Idle
)
const
navigation
=
useNavigation
()
const
navigation
=
useNavigation
()
useEffect
(()
=>
{
useEffect
(()
=>
{
const
handleFocus
=
()
=>
{
const
handleFocus
=
()
=>
{
console
.
log
(
'==== home ====='
)
}
}
navigation
.
addListener
(
'focus'
,
handleFocus
)
navigation
.
addListener
(
'focus'
,
handleFocus
)
return
()
=>
{
return
()
=>
{
...
@@ -50,7 +48,6 @@ const Home = (props: any) => {
...
@@ -50,7 +48,6 @@ const Home = (props: any) => {
}
}
const
onFooterRefresh
=
()
=>
{
const
onFooterRefresh
=
()
=>
{
console
.
log
(
'onFooterRefresh'
)
setRefreshState
(
RefreshState
.
FooterRefreshing
)
setRefreshState
(
RefreshState
.
FooterRefreshing
)
if
(
list
.
length
>=
5
)
{
if
(
list
.
length
>=
5
)
{
setRefreshState
(
RefreshState
.
NoMoreData
)
setRefreshState
(
RefreshState
.
NoMoreData
)
...
@@ -62,7 +59,6 @@ const Home = (props: any) => {
...
@@ -62,7 +59,6 @@ const Home = (props: any) => {
},
1000
);
},
1000
);
}
}
console
.
log
(
list
)
return
(
return
(
<
View
style=
{
{
flex
:
1
}
}
>
<
View
style=
{
{
flex
:
1
}
}
>
<
RefreshListView
<
RefreshListView
...
...
src/router/index.tsx
View file @
5ffbf57c
import
React
,
{
useEffect
}
from
'react'
import
React
from
'react'
import
{
createStackNavigator
}
from
'@react-navigation/stack'
import
{
createStackNavigator
}
from
'@react-navigation/stack'
import
{
createBottomTabNavigator
}
from
'@react-navigation/bottom-tabs'
import
{
createBottomTabNavigator
}
from
'@react-navigation/bottom-tabs'
import
{
NavigationContainer
,
getFocusedRouteNameFromRoute
}
from
'@react-navigation/native'
import
{
NavigationContainer
,
getFocusedRouteNameFromRoute
}
from
'@react-navigation/native'
import
{
TopStackNavigationRef
}
from
'@/utils/routeUtil'
import
{
TopStackNavigationRef
}
from
'@/utils/routeUtil'
import
routes
,
{
BaseRouteConfig
}
from
'./routes'
import
routes
,
{
BaseRouteConfig
}
from
'./routes'
import
Home
from
'@/pages/home'
const
Stack
=
createStackNavigator
()
const
Stack
=
createStackNavigator
()
const
Tab
=
createBottomTabNavigator
()
const
Tab
=
createBottomTabNavigator
()
...
@@ -21,8 +20,6 @@ const configtabChildren = (components: [BaseRouteConfig]) => {
...
@@ -21,8 +20,6 @@ const configtabChildren = (components: [BaseRouteConfig]) => {
return
stacks
return
stacks
}
}
const
tabRouterNames
=
routes
.
tabs
.
map
(
itm
=>
itm
.
name
)
const
tabs
=
(
routes
.
tabs
||
[]).
map
((
tab
,
index
)
=>
{
const
tabs
=
(
routes
.
tabs
||
[]).
map
((
tab
,
index
)
=>
{
const
Child
=
()
=>
{
const
Child
=
()
=>
{
return
<
Stack
.
Navigator
>
return
<
Stack
.
Navigator
>
...
@@ -30,10 +27,10 @@ const tabs = (routes.tabs || []).map((tab, index) => {
...
@@ -30,10 +27,10 @@ const tabs = (routes.tabs || []).map((tab, index) => {
</
Stack
.
Navigator
>
</
Stack
.
Navigator
>
}
}
return
(
return
(
<
Tab
.
Screen
name=
{
tab
.
name
}
key=
{
index
}
<
Tab
.
Screen
name=
{
tab
.
name
}
key=
{
index
+
'tab'
}
options=
{
({
route
})
=>
{
options=
{
({
route
})
=>
{
const
routeName
=
getFocusedRouteNameFromRoute
(
route
)
const
routeName
=
getFocusedRouteNameFromRoute
(
route
)
const
hiddenTabBar
=
tabRouterNames
.
includes
(
routeName
)
const
hiddenTabBar
=
(
route
as
any
).
state
&&
(
route
as
any
).
state
.
index
&&
(
route
as
any
).
state
.
index
===
0
return
{
return
{
tabBarVisible
:
hiddenTabBar
,
tabBarVisible
:
hiddenTabBar
,
...
tab
.
options
||
{}
...
tab
.
options
||
{}
...
@@ -47,6 +44,8 @@ const RouteApp = () => {
...
@@ -47,6 +44,8 @@ const RouteApp = () => {
return
(
return
(
<
NavigationContainer
ref=
{
ref
=>
TopStackNavigationRef
(
ref
)
}
>
<
NavigationContainer
ref=
{
ref
=>
TopStackNavigationRef
(
ref
)
}
>
<
Tab
.
Navigator
tabBarOptions=
{
{
<
Tab
.
Navigator
tabBarOptions=
{
{
}
}
screenOptions=
{
{
tabBarVisible
:
true
,
}
}
>
}
}
>
{
tabs
}
{
tabs
}
</
Tab
.
Navigator
>
</
Tab
.
Navigator
>
...
...
src/router/routes.tsx
View file @
5ffbf57c
...
@@ -37,6 +37,9 @@ const routesConfig: {
...
@@ -37,6 +37,9 @@ const routesConfig: {
{
{
component
:
Home
,
component
:
Home
,
name
:
'Home'
,
name
:
'Home'
,
options
:
{
}
},
},
{
{
name
:
'Message'
,
name
:
'Message'
,
...
@@ -47,6 +50,11 @@ const routesConfig: {
...
@@ -47,6 +50,11 @@ const routesConfig: {
{
{
title
:
'About'
,
title
:
'About'
,
name
:
'About'
,
name
:
'About'
,
options
:
{
tabBarLabel
:
'About'
,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>,
tabBarBadge
:
4
},
children
:
[
children
:
[
{
{
name
:
'About'
,
name
:
'About'
,
...
@@ -61,14 +69,24 @@ const routesConfig: {
...
@@ -61,14 +69,24 @@ const routesConfig: {
{
{
title
:
'Person'
,
title
:
'Person'
,
name
:
'Person'
,
name
:
'Person'
,
options
:
{
tabBarLabel
:
'Person'
,
tabBarIcon
:
(
props
)
=>
<
View
style=
{
{
width
:
30
,
height
:
30
,
backgroundColor
:
'blue'
}
}
></
View
>,
tabBarBadge
:
4
},
children
:
[
children
:
[
{
{
name
:
'Person'
,
name
:
'Person'
,
component
:
Person
,
component
:
Person
,
options
:
{
}
},
},
{
{
name
:
'Message'
,
name
:
'Message'
,
component
:
Message
,
component
:
Message
,
options
:
{
header
:
null
}
}
}
]
]
}
}
...
...
src/utils/dva.ts
View file @
5ffbf57c
...
@@ -5,46 +5,46 @@ import { createLogger } from 'redux-logger'
...
@@ -5,46 +5,46 @@ import { createLogger } from 'redux-logger'
import
{
Store
}
from
'redux'
;
import
{
Store
}
from
'redux'
;
let
app
:
{
let
app
:
{
use
:
(
arg0
:
{
onError
(
err
:
any
):
void
})
=>
void
;
use
:
(
arg0
:
{
onError
(
err
:
any
):
void
})
=>
void
;
model
:
(
arg0
:
any
)
=>
any
;
model
:
(
arg0
:
any
)
=>
any
;
start
:
()
=>
void
;
start
:
()
=>
void
;
_store
:
Store
;
_store
:
Store
;
getStore
:
()
=>
Store
;
getStore
:
()
=>
Store
;
dispatch
:
any
;
dispatch
:
any
;
};
};
let
store
:
Store
;
let
store
:
Store
;
let
dispatch
;
let
dispatch
;
let
registered
:
boolean
;
let
registered
:
boolean
;
function
createApp
(
opt
:
any
)
{
function
createApp
(
opt
:
any
)
{
// redux 的日志
// redux 的日志
opt
.
onAction
=
[
createLogger
()];
opt
.
onAction
=
[
createLogger
()];
app
=
create
(
opt
);
app
=
create
(
opt
);
app
.
use
(
immer
());
app
.
use
(
immer
());
app
.
use
(
createLoading
());
app
.
use
(
createLoading
());
app
.
use
({
app
.
use
({
onError
(
err
:
any
)
{
onError
(
err
:
any
)
{
console
.
log
(
'dvaError'
,
err
);
console
.
log
(
'dvaError'
,
err
);
},
},
});
});
if
(
!
registered
)
{
if
(
!
registered
)
{
opt
.
models
.
forEach
((
model
:
any
)
=>
app
.
model
(
model
));
opt
.
models
.
forEach
((
model
:
any
)
=>
app
.
model
(
model
));
}
registered
=
true
;
app
.
start
();
store
=
app
.
_store
;
app
.
getStore
=
()
=>
store
;
dispatch
=
store
.
dispatch
;
app
.
dispatch
=
dispatch
;
return
app
;
}
}
registered
=
true
;
app
.
start
();
store
=
app
.
_store
;
app
.
getStore
=
()
=>
store
;
dispatch
=
store
.
dispatch
;
app
.
dispatch
=
dispatch
;
return
app
;
}
export
default
{
export
default
{
createApp
,
createApp
,
getDispatch
()
{
getDispatch
()
{
return
app
.
dispatch
;
return
app
.
dispatch
;
},
},
};
};
\ No newline at end of file
\ No newline at end of file
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