Skip to content

Commit

Permalink
feat: rm home input
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen committed Aug 16, 2021
1 parent 904bca7 commit 24a00e0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 52 deletions.
12 changes: 10 additions & 2 deletions src/pages/apis/pages/device/network/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
*/
import Taro from "@tarojs/taro-rn";
import { Button, View } from "@tarojs/components";
import { useState } from "react";
import JSONTree from '../../../../components/jsontree';

import "./index.scss";

const Index = () => {
const [networkStatus1, setNetworkStatus1] = useState({});
const [networkStatus2, setNetworkStatus2] = useState({});

const _handleCallback1 = (...res) => {
const _handleCallback1 = (res) => {
console.log("回调函数 C1", res);
setNetworkStatus1(res);
}

const _handleCallback2 = (...res) => {
const _handleCallback2 = (res) => {
console.log("回调函数 C2", res);
setNetworkStatus2(res)
}

return (
Expand All @@ -32,6 +38,7 @@ const Index = () => {
>
Taro.onNetworkStatusChange(C1)
</Button>
<JSONTree data={networkStatus1} />
<Button
type="primary"
className="api-page-btn-success"
Expand All @@ -41,6 +48,7 @@ const Index = () => {
>
Taro.onNetworkStatusChange(C2)
</Button>
<JSONTree data={networkStatus2} />
<Button
type="primary"
className="api-page-btn-warning"
Expand Down
3 changes: 2 additions & 1 deletion src/pages/apis/pages/network/request/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.api-page {
padding: 32px;
&-btns {
padding-bottom: 20px;
&-btn1 {
background-color: $color-success;
color: #fff;
Expand All @@ -12,4 +13,4 @@
background-color: $color-error;
}
}
}
}
23 changes: 15 additions & 8 deletions src/pages/apis/pages/network/request/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@
* @FilePath: /taro-react-native/src/pages/apis/pages/network/request/index.tsx
*/
import Taro from '@tarojs/taro';
import { View, Text, Button } from '@tarojs/components';
import { View, Button } from '@tarojs/components';
import { useState } from "react";
import JSONTree from '../../../../components/jsontree';

import './index.scss'

const PageView = () => {
const [data, setData] = useState({});

const _onRequest = () => {
Taro.request({
url: '',
url: 'https://gitee.com/o2team/Taro/raw/next/package.json',
data: {},
header: {
'content-type': 'application/json',
},
// success: res => {
// console.log(res);
// },
// fail: err => {
// console.log(err)
// }
success: res => {
console.log(res);
setData(res);
},
fail: err => {
console.log(err);
setData(err);
}
})
}

Expand All @@ -36,6 +42,7 @@ const PageView = () => {
className="api-page-btns-btn1"
>Taro.request</Button>
</View>
<JSONTree data={data} />
</View>
)
}
Expand Down
18 changes: 6 additions & 12 deletions src/pages/home/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.index {
flex: 1;
padding-top: 120px;
padding-top: 200px;
padding-bottom: 200px;
}

Expand Down Expand Up @@ -39,19 +39,13 @@
.load {
padding: 32px;
&-header {
flex-direction: row;
align-items: center;
flex-direction: column;
align-items: flex-end;
padding-left: 20px;
padding-right: 20px;
background-color: #ffffff;
&-input {
flex: 1;
margin-right: 50px;
font-size: $font-size-xl;
}
&-icon {
height: 40px;
width: 40px;
height: 60px;
width: 60px;
/* #ifdef rn */
tint-color: $color-brand;
/* #endif */
Expand All @@ -71,7 +65,7 @@
justify-content: space-between;
padding: 32px;
}

&-item {
padding: 28px 32px;
background-color: #ffffff;
Expand Down
31 changes: 2 additions & 29 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { Component, Fragment } from 'react';
import Taro from '@tarojs/taro';
import { NativeModules } from 'react-native';
import { View, Text, Image, Input, Button } from '@tarojs/components'
import { View, Text, Image } from '@tarojs/components'
import './index.scss'

const DevManager = NativeModules.RNDevManager;
Expand All @@ -18,7 +18,6 @@ export default class Index extends Component<any, any> {
constructor(props: any) {
super(props);
this.state = {
inputValue: 'localhost:8081',
list: [],
};
}
Expand Down Expand Up @@ -88,19 +87,6 @@ export default class Index extends Component<any, any> {
})
}

_onInputChange = e => {
const value = e.detail.value;
this.setState({
inputValue: value
});
}

_onPressLoad = e => {
const { inputValue } = this.state;
this._loadBundleByUrl(inputValue);
this._saveUrlToStorage(inputValue);
}

_clearBundles = async () => {
try {
const res = await Taro.showModal({ title: '确定清空吗?', content: '清空后历史数据将不再保存', confirmColor: '#6190E8' });
Expand All @@ -118,7 +104,7 @@ export default class Index extends Component<any, any> {
}

render() {
const { list = [], inputValue } = this.state;
const { list = [] } = this.state;
return (
<View className='index'>
<View className='info'>
Expand All @@ -130,25 +116,12 @@ export default class Index extends Component<any, any> {
</View>
<View className='load'>
<View className='load-header'>
<Input
name='input'
type='text'
placeholder='请输入IP:8081'
value={inputValue}
onInput={this._onInputChange}
className='load-header-input'
></Input>
<Image
src={require('../../assets/common/icon_scan.png')}
className='load-header-icon'
onClick={this._onPressScan}
/>
</View>
<Button
type='primary'
className='load-btn'
onClick={this._onPressLoad}
>加载</Button>
</View>
{list.length > 0 && (
<View className='bundle'>
Expand Down

0 comments on commit 24a00e0

Please sign in to comment.