Skip to content

Commit

Permalink
chore: up
Browse files Browse the repository at this point in the history
  • Loading branch information
zhpd committed Nov 25, 2021
1 parent e6e8c35 commit b7dd4ef
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions src/modules/network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {
Text,
TextInput,
TouchableOpacity,
Alert,
View,
} from 'react-native';
import JsonTree from 'react-native-json-tree';
import dayjs from 'dayjs';
import event from './event';
import { debounce } from './tool';
import theme from './theme';
Expand Down Expand Up @@ -284,6 +286,10 @@ class Network extends Component<Props, State> {
}
);
};
copyText(text: string) {
Clipboard.setString(text);
Alert.alert('Info', 'Copy successfully', [{ text: 'OK' }]);
}

copy2cURL(item: any) {
let headerStr = '';
Expand All @@ -299,6 +305,7 @@ class Network extends Component<Props, State> {
if (item.method === 'POST' && item.postData)
cURL += ` --data-binary '${item.postData}'`;
Clipboard.setString(cURL);
Alert.alert('Info', 'Copy successfully', [{ text: 'OK' }]);
}

retryFetch(item: any) {
Expand Down Expand Up @@ -377,9 +384,18 @@ class Network extends Component<Props, State> {
>
<Text>[ Copy cURL to clipboard ]</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
Clipboard.setString(JSON.stringify(_item.getData));
Alert.alert('Info', 'Copy successfully', [{ text: 'OK' }]);
}}
>
<Text>[ Copy request query to clipboard ]</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
Clipboard.setString(_item.response);
Alert.alert('Info', 'Copy successfully', [{ text: 'OK' }]);
}}
>
<Text>[ Copy response to clipboard ]</Text>
Expand All @@ -391,15 +407,25 @@ class Network extends Component<Props, State> {
</Text>
<View style={styles.nwDetailItem}>
<Text>URL:</Text>
<Text>{_item.url}</Text>
<TouchableOpacity
onLongPress={() => {
this.copyText(_item.url);
}}
>
<Text>{_item.url}</Text>
</TouchableOpacity>
</View>
<View style={styles.nwDetailItem}>
<Text>startTime:</Text>
<Text>{_item.startTime}</Text>
<Text>{`${dayjs(_item.startTime).format(
'YYYY-M-D HH:mm:ss SSS'
)}`}</Text>
</View>
<View style={styles.nwDetailItem}>
<Text>endTime:</Text>
<Text>{_item.endTime}</Text>
<Text> endTime:</Text>
<Text>{`${dayjs(_item.endTime).format(
'YYYY-M-D HH:mm:ss SSS'
)}`}</Text>
</View>
</View>
{_item.reqHeaders && (
Expand All @@ -410,7 +436,13 @@ class Network extends Component<Props, State> {
{Object.keys(_item.reqHeaders).map((key) => (
<View style={styles.nwDetailItem} key={key}>
<Text>{key}:</Text>
<Text>{_item.reqHeaders[key]}</Text>
<TouchableOpacity
onLongPress={() => {
this.copyText(_item.reqHeaders[key]);
}}
>
<Text>{_item.reqHeaders[key]}</Text>
</TouchableOpacity>
</View>
))}
</View>
Expand All @@ -423,7 +455,13 @@ class Network extends Component<Props, State> {
{Object.keys(_item.resHeaders).map((key) => (
<View style={styles.nwDetailItem} key={key}>
<Text>{key}:</Text>
<Text>{_item.resHeaders[key]}</Text>
<TouchableOpacity
onLongPress={() => {
this.copyText(_item.resHeaders[key]);
}}
>
<Text>{_item.resHeaders[key]}</Text>
</TouchableOpacity>
</View>
))}
</View>
Expand Down Expand Up @@ -525,9 +563,15 @@ const styles = StyleSheet.create({
flex1: {
flex: 1,
},
flex2: {
flex: 2,
},
flex3: {
flex: 3,
},
flex4: {
flex: 4,
},
nwDetailItem: {
flexDirection: 'row',
paddingLeft: 5,
Expand Down

0 comments on commit b7dd4ef

Please sign in to comment.