Skip to content

Commit 57229f2

Browse files
committed
🔨 [app] 调整一些细节,并增加app nav 的RESET处理
1 parent 4c82c1a commit 57229f2

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

build/metro/babel-transformer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const cacheKeyParts = [
1919
require('babel-preset-fbjs/package.json').version,
2020
];
2121

22+
const { NODE_ENV, PLATFORM, TRPG_HOST } = process.env;
23+
console.log(
24+
`环境变量:\n\tNODE_ENV:${NODE_ENV}\n\tPLATFORM:${PLATFORM}\n\tTRPG_HOST:${TRPG_HOST}`
25+
);
26+
2227
/**
2328
* Return a memoized function that checks for the existence of a
2429
* project level .babelrc file, and if it doesn't exist, reads the

src/app/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ require('../shared/utils/common');
77
import { AppRegistry, YellowBox } from 'react-native';
88
import App from './App';
99
import _get from 'lodash/get';
10+
import projectConfig from '../../config/project.config';
1011

1112
// Sentry
12-
import { Sentry } from 'react-native-sentry';
13+
// import { Sentry } from 'react-native-sentry';
1314
import Config from 'config';
1415
const dsn = _get(Config, 'sentry.dsn');
15-
if (dsn) {
16-
Sentry.config(dsn).install();
16+
if (dsn && projectConfig.environment === 'production') {
17+
import('react-native-sentry')
18+
.then((module) => module.Sentry)
19+
.then((Sentry) => {
20+
Sentry.config(dsn).install();
21+
});
1722
}
1823

1924
YellowBox.ignoreWarnings(['Require cycle:']); // Metro warning, Specific for Sentry

src/app/redux/reducers/nav.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { NavigationActions, StackActions } from 'react-navigation';
22
import { AppNavigator } from '../../router';
33
import constants from '../../../redux/constants';
4-
const {
5-
LOGIN_SUCCESS,
6-
LOGIN_TOKEN_SUCCESS,
7-
LOGOUT,
8-
} = constants;
4+
const { RESET, LOGIN_SUCCESS, LOGIN_TOKEN_SUCCESS, LOGOUT } = constants;
95
import navConstants from '../constants/nav';
10-
const {
11-
SWITCH_NAV,
12-
REPLACE_NAV,
13-
BACK_NAV,
14-
} = navConstants;
6+
const { SWITCH_NAV, REPLACE_NAV, BACK_NAV } = navConstants;
157

168
let initialNavState = AppNavigator.router.getStateForAction(
179
NavigationActions.init()
@@ -20,6 +12,15 @@ let initialNavState = AppNavigator.router.getStateForAction(
2012
export default function nav(state = initialNavState, action) {
2113
let nextState;
2214
switch (action.type) {
15+
case RESET:
16+
nextState = AppNavigator.router.getStateForAction(
17+
StackActions.reset({
18+
index: 0,
19+
actions: [NavigationActions.navigate({ routeName: 'Login' })],
20+
}),
21+
state
22+
);
23+
break;
2324
case LOGIN_SUCCESS:
2425
case LOGIN_TOKEN_SUCCESS:
2526
nextState = AppNavigator.router.getStateForAction(

0 commit comments

Comments
 (0)