├── .babelrc ├── .buckconfig ├── .eslintrc.json ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .npmignore ├── .watchmanconfig ├── AppEntry.js ├── LICENSE ├── README.md ├── android ├── app │ ├── BUCK │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── example │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystores │ ├── BUCK │ └── debug.keystore.properties └── settings.gradle ├── app.json ├── images ├── 1-1.png ├── 1-2.png ├── 1-3.png ├── 2-1.PNG ├── 2-2.PNG ├── 2-3.PNG ├── screenshot1.png └── screenshot2.png ├── index.android.js ├── index.ios.js ├── ios ├── example-tvOS │ └── Info.plist ├── example-tvOSTests │ └── Info.plist ├── example.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── erichua.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── example-tvOS.xcscheme │ │ │ └── example.xcscheme │ └── xcuserdata │ │ └── erichua.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── example │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── main.m └── exampleTests │ ├── Info.plist │ └── exampleTests.m ├── library ├── Dashboard.js ├── TianYan.js ├── components │ └── Tab.js ├── images │ ├── close.png │ └── tianyan-icon.png ├── index.js └── plugins │ ├── Plugin.js │ ├── components │ ├── Button.js │ ├── ButtonGroup.js │ ├── Search.js │ └── Text.js │ ├── console │ ├── Console.js │ ├── components │ │ ├── Loading.js │ │ └── ResultBoard.js │ └── images │ │ └── icon_success.png │ ├── network │ └── Network.js │ └── utils │ ├── DumpObject.js │ ├── ProxyFetch.js │ ├── StyleValues.js │ └── isColor.js ├── package.json ├── packager-config.js ├── react-native-web-demo ├── .env ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── index.html │ ├── manifest.json │ ├── robots.txt │ └── tianyan-icon.png └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── serviceWorker.js │ └── setupTests.js └── scripts ├── publish-npm.sh └── setup.sh /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": ["standard", "standard-jsx"] 4 | } 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | emoji=true 26 | 27 | module.system=haste 28 | 29 | experimental.strict_type_args=true 30 | 31 | munge_underscores=true 32 | 33 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 34 | 35 | suppress_type=$FlowIssue 36 | suppress_type=$FlowFixMe 37 | suppress_type=$FixMe 38 | 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 41 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 42 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 43 | 44 | unsafe.enable_getters_and_setters=true 45 | 46 | [version] 47 | ^0.40.0 48 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | yarn-error.log 2 | node_modules/ 3 | .idea/ 4 | yarn.lock 5 | npm-debug.log 6 | __tests__/ 7 | _cacache/ 8 | _logs/ 9 | index-v5/ 10 | ios/build/ 11 | anonymous-cli-metrics.json 12 | react-native-web-demo/src/library 13 | library/.watchmanconfig 14 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example/ 2 | android/ 3 | ios/ 4 | .idea/ 5 | node_modules/ 6 | yarn-error.log 7 | yarn.lock 8 | npm-debug.log 9 | __tests__/ 10 | _cacache/ 11 | _logs/ 12 | index-v5/ 13 | ios/build/ 14 | anonymous-cli-metrics.json 15 | ./images 16 | react-native-web-demo 17 | 18 | 19 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /AppEntry.js: -------------------------------------------------------------------------------- 1 | import { 2 | Text, 3 | View, 4 | StyleSheet, 5 | TouchableOpacity 6 | } from 'react-native' 7 | import React, { Component } from 'react' 8 | 9 | import TianYan from './library/index' 10 | 11 | export default class AppEntry extends Component { 12 | render () { 13 | return ( 14 | 15 | 16 | Welcome to tianyan-react-native Demo 17 | 18 | 27 | 28 | Click me to generate log 29 | 30 | 31 | 32 | 33 | Then click the floating icon to see your log 34 | 35 | 43 | 44 | ) 45 | } 46 | 47 | _onPress () { 48 | let i = 1000 49 | while (i--) { 50 | // console.log('oonPress ' + new Date().getTime()) 51 | // console.log('%s %s', 'hello', 'world') 52 | // console.log('%o %i', {a: 1, b: 2, c: {a: 'foo', d: 'bar'}}, 1000) 53 | // console.log(undefined, 'second params') 54 | console.log('ignored log, this will not display in tianyan dashboard') 55 | console.log({a: 1, b: 2, c: {a: 'foo', d: 'bar'}}) 56 | // console.log('x ignored log, this will display in tianyan dashboard') 57 | } 58 | } 59 | } 60 | 61 | const styles = StyleSheet.create({ 62 | container: { 63 | flex: 1, 64 | justifyContent: 'center', 65 | alignItems: 'center', 66 | backgroundColor: '#F5FCFF' 67 | }, 68 | welcome: { 69 | fontSize: 20, 70 | textAlign: 'center', 71 | margin: 10 72 | }, 73 | instructions: { 74 | textAlign: 'center', 75 | color: '#333333', 76 | marginBottom: 5 77 | } 78 | }) 79 | 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wt-console 2 | 3 | [![Open Source Love](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://shields.io/) 4 | [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 5 | 6 | 7 | 注:从[WeTrident项目](https://gitee.com/WeBank/WeTrident)提炼而来。 8 | 9 | ## 📥 安装 10 | 11 | - `npm i @webank/wt-console --save` 12 | - `yarn add @webank/wt-console` 13 | 14 | ## 💡 背景 15 | 16 | App开发过程中,经常会遇到一个场景就是,测试说我遇到一个xxx问题,但是不能复现,之前比较多的解决方案是基于文件日志。我们自己使用过程中发现文件日志太重,而且测试同学取日志的学习成本太高。于是在web项目中开始使用类似vConsole这一类的工具,又因为我们主要使用到的日志查看和日志上传功能。因此我们在React Native实现了类似vConsole的功能,同时在陆续扩展一些功能。 17 | 18 | ## 🌱 特性 19 | 20 | 1. 添加一行代码即可在App内查看日志。 21 | 2. 支持展示Network信息(目前支持fetch api的展示)。 22 | 3. 收拢警告和错误提示,跟RN内烦人的底部黄色警告条说再见。 23 | 24 | ## 📱 截图 25 | 26 | ![](./images/screenshot1.png) 27 | 28 | ![](./images/screenshot2.png) 29 | 30 | ## 📗 用法说明 31 | 32 | 正式使用之前可以先使用snack版本体验,在线示例: [https://snack.expo.io/@erichua23/wt-console-demo](https://snack.expo.io/@erichua23/wt-console-demo) 33 | 34 | ### 基础用法 35 | 将`TianYan`嵌入到App最外层View中: 36 | 37 | ``` jsx 38 | import TianYan from '@webank/wt-console' 39 | 40 | export default class SimpleApp extends Component { 41 | render () { 42 | return ( 43 | 44 | {/* other view */} 45 | 46 | {/* 添加下面一行代码即完成接入 */} 47 | 48 | 49 | 50 | ) 51 | } 52 | } 53 | ``` 54 | 55 | ### 进阶用法 56 | 57 | #### Console插件 58 | 59 | 默认会展示Console板块,内容类型Chrome中的Console板块。 60 | 61 | Console插件支持三个参数: 62 | - `showTimestamp` 是否在日志前面展示时间戳。布尔类型,默认为false 63 | - `ignoreRedBox` 是否忽略RN对console.error默认的处理(默认会展示红屏)。布尔类型,默认为false 64 | - `ignoreYellowBox` 是否忽略RN对console.warn默认的处理(默认会在底部展示小黄条)。布尔类型,默认为false 65 | 66 | ``` jsx 67 | 74 | ``` 75 | 76 | 注: 77 | - 为什么引入`ignoreRedBox`和`ignoreYellowBox`:因为RN对警告的处理比较暴力,直接使用浮窗在底部拦截操作,遇到警告比较多的时候非常烦人。官方提供的了ignore的方式,但是用官方的ignore,又担心某些需要关心的警告被忽略。wt-console采用了折中的策略,将黄色警告条去除后都收拢到wt-console的图标上展示,出现warning的时候开发者可以自有选择当前是否需要继续查看warning的详细信息。如下代码将错误和警告都收拢到wt-console统一管理。 78 | 79 | #### Network插件 80 | 81 | 默认会展示Network板块,展示应用中的网络请求信息。**同时支持一键重发指定请求。** 82 | 83 | ### 开发调试 84 | 85 | ```shell script 86 | // 使用react-native-web进行演示 87 | cd react-native-web-demo 88 | npm i 89 | npm run syncLib // 将 library 同步到 react-native-web-demo/src/ 下面 90 | npm start // 将自动在浏览器打开 91 | ``` 92 | 93 | 94 | ## ❤️ 我们的其他项目 95 | 96 | - [WeTrident](https://github.com/WeBankFinTech/WeTrident): 一站式App开发套件。 97 | - [React Native Search List](https://github.com/UnPourTous/react-native-search-list): A searchable ListView which supports Chinese PinYin and alphabetical index. 98 | - [React Native Popup Stub](https://github.com/UnPourTous/react-native-popup-stub): A smart popup container. 99 | - [WT Console Server](https://github.com/UnPourTous/wt-console-server): An open source log manager backend. 100 | 101 | ## 🤝 类似项目 102 | 103 | - [web-console](https://github.com/whinc/web-console):H5-based mobile web debugging tool similar to chrome devtools. 104 | - [vConsole](https://github.com/Tencent/vConsole):A lightweight, extendable front-end developer tool for mobile web page. 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] 15 | lib_deps.append(':' + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.example", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.example", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.example" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/example/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | }; 29 | 30 | @Override 31 | public ReactNativeHost getReactNativeHost() { 32 | return mReactNativeHost; 33 | } 34 | 35 | @Override 36 | public void onCreate() { 37 | super.onCreate(); 38 | SoLoader.init(this, /* native exopackage */ false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | task wrapper(type: Wrapper) { 4 | gradleVersion = '2.14.1' 5 | } 6 | buildscript { 7 | repositories { 8 | maven { 9 | url "http://maven.aliyun.com/nexus/content/groups/public/" 10 | } 11 | jcenter() 12 | } 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:2.2.3' 15 | 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | mavenLocal() 24 | maven { 25 | url "http://maven.aliyun.com/nexus/content/groups/public/" 26 | } 27 | maven { 28 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 29 | url "$rootDir/../node_modules/react-native/android" 30 | } 31 | jcenter() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /images/1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/1-1.png -------------------------------------------------------------------------------- /images/1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/1-2.png -------------------------------------------------------------------------------- /images/1-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/1-3.png -------------------------------------------------------------------------------- /images/2-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/2-1.PNG -------------------------------------------------------------------------------- /images/2-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/2-2.PNG -------------------------------------------------------------------------------- /images/2-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/2-3.PNG -------------------------------------------------------------------------------- /images/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/screenshot1.png -------------------------------------------------------------------------------- /images/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/images/screenshot2.png -------------------------------------------------------------------------------- /index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react' 8 | import { 9 | AppRegistry 10 | } from 'react-native' 11 | import Entry from './AppEntry' 12 | 13 | export default class example extends Component { 14 | render () { 15 | return ( 16 | 17 | ) 18 | } 19 | } 20 | AppRegistry.registerComponent('example', () => example) 21 | -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react' 8 | import { 9 | AppRegistry 10 | } from 'react-native' 11 | import Entry from './AppEntry' 12 | 13 | export default class example extends Component { 14 | render () { 15 | return ( 16 | 17 | ) 18 | } 19 | } 20 | AppRegistry.registerComponent('example', () => example) 21 | -------------------------------------------------------------------------------- /ios/example-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ios/example-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/example.xcodeproj/project.xcworkspace/xcuserdata/erichua.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/ios/example.xcodeproj/project.xcworkspace/xcuserdata/erichua.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ios/example.xcodeproj/xcshareddata/xcschemes/example-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /ios/example.xcodeproj/xcuserdata/erichua.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | example-tvOS.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | example.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ios/example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"example" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /ios/example/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ios/example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ios/example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | NSLocationWhenInUseUsageDescription 42 | 43 | NSAppTransportSecurity 44 | 45 | 46 | NSExceptionDomains 47 | 48 | localhost 49 | 50 | NSExceptionAllowsInsecureHTTPLoads 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /ios/example/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ios/exampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/exampleTests/exampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface exampleTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation exampleTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /library/Dashboard.js: -------------------------------------------------------------------------------- 1 | import { 2 | View 3 | } from 'react-native' 4 | 5 | import React, { Component } from 'react' 6 | import Tab from './components/Tab' 7 | 8 | export default class Dashboard extends Component { 9 | static registeredPlugins = [] 10 | static customData = null 11 | 12 | static register (plugin, options, element) { 13 | Dashboard.registeredPlugins.push({ 14 | plugin, 15 | options, 16 | element 17 | }) 18 | } 19 | 20 | static setup () { 21 | Dashboard.registeredPlugins.filter((item) => { 22 | return item.plugin && item.plugin.setup 23 | }).forEach((item) => { 24 | item.plugin.setup({ 25 | ...item.options, 26 | customData: {...Dashboard.customData} 27 | }) 28 | }) 29 | } 30 | 31 | static addCustomData (data) { 32 | Dashboard.customData = data 33 | } 34 | 35 | render () { 36 | let pluginArr = [] 37 | Dashboard.registeredPlugins.forEach(item => { 38 | if (item.plugin && item.plugin.name === 'Console') { 39 | pluginArr.unshift(item) 40 | } else { 41 | pluginArr.push(item) 42 | } 43 | }) 44 | return ( 45 | 48 | ({ 51 | title: item.options.tabLabel, 52 | renderContent: () => item.element 53 | }))} 54 | initPage={0} 55 | /> 56 | 57 | ) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /library/TianYan.js: -------------------------------------------------------------------------------- 1 | import { 2 | Animated, 3 | PanResponder, 4 | Dimensions, 5 | TouchableOpacity, 6 | View, 7 | Image, 8 | Text, 9 | StyleSheet 10 | } from 'react-native' 11 | 12 | import React, { Component } from 'react' 13 | import PropTypes from 'prop-types' 14 | 15 | import Dashboard from './Dashboard' 16 | import Console from './plugins/console/Console' 17 | import Network from './plugins/network/Network' 18 | 19 | const { width, height } = Dimensions.get("window"); 20 | const ICON_SIZE = 50 21 | const LEFT_X = 0 22 | const RIGHT_X = width - ICON_SIZE 23 | export default class TianYan extends Component { 24 | static propTypes = { 25 | consoleOptions: PropTypes.object, 26 | networkOptions: PropTypes.object, 27 | options: PropTypes.object 28 | } 29 | static defaultProps = { 30 | consoleOptions: {}, 31 | networkOptions: {} 32 | } 33 | static addPlugin (options, element) { 34 | Dashboard.register({}, options, element) 35 | } 36 | constructor (props) { 37 | super(props) 38 | Dashboard.register( 39 | Console, 40 | { 41 | ...this.props.consoleOptions, 42 | tabLabel: 'Console', 43 | updateErrorCount: (errorCount) => { 44 | this._errorCount = errorCount 45 | }, 46 | updateWarnCount: (warnCount) => { 47 | this._warnCount = warnCount 48 | } 49 | }, 50 | ) 51 | Dashboard.register( 52 | Network, 53 | { 54 | ...this.props.networkOptions, 55 | tabLabel: 'Network' 56 | }, 57 | 58 | ) 59 | Dashboard.setup() 60 | 61 | this.state = { 62 | expendAnim: new Animated.Value(100), 63 | pan: new Animated.ValueXY({ 64 | x: RIGHT_X, 65 | y: 300 66 | }), 67 | showDashboard: false, 68 | errorCount: 0, 69 | warnCount: 0 70 | } 71 | this.x = RIGHT_X 72 | this.y = 300 73 | this.isFold = true 74 | 75 | this.panResponder = PanResponder.create({ 76 | onMoveShouldSetPanResponder: () => true, 77 | onMoveShouldSetPanResponderCapture: () => true, 78 | onStartShouldSetPanResponder: (evt, gestureState) => true, 79 | onStartShouldSetPanResponderCapture: (evt, gestureState) => true, 80 | onPanResponderGrant: this._onPanResponderGrant, 81 | onPanResponderMove: this._onPanResponderMove, 82 | onPanResponderRelease: this._onPanResponderRelease 83 | }) 84 | } 85 | 86 | componentDidMount () { 87 | this._updateCount() 88 | this._autoRefresh() 89 | } 90 | 91 | _autoRefresh () { 92 | this._timer = setTimeout(() => { 93 | if (this._prevErrorCount !== this._errorCount || this._prevWarnCount !== this._warnCount) { 94 | this._prevErrorCount = this._errorCount 95 | this._prevWarnCount = this._warnCount 96 | this._updateCount() 97 | } 98 | this._autoRefresh() 99 | }, 100) 100 | } 101 | 102 | componentWillUnmount () { 103 | clearTimeout(this._timer) 104 | } 105 | 106 | _updateCount () { 107 | this.setState({ 108 | errorCount: this._errorCount, 109 | warnCount: this._warnCount 110 | }) 111 | } 112 | 113 | _onPanResponderGrant = ({nativeEvent: {timestamp}}, gestureState) => { 114 | this.startTime = timestamp 115 | this.state.pan.setOffset({ 116 | x: this.x, 117 | y: this.y 118 | }) 119 | this.state.pan.setValue({ x: 0, y: 0 }) 120 | } 121 | 122 | _onPanResponderMove = (evt, gestureState) => { 123 | // console.log('x, y', gestureState.dx, gestureState.dy) 124 | Animated.event( 125 | [ 126 | null, 127 | { 128 | dx: this.state.pan.x, 129 | dy: this.state.pan.y 130 | } 131 | ] 132 | )(evt, gestureState) 133 | } 134 | _onPanResponderRelease = ({nativeEvent: {timestamp}}, gestureState) => { 135 | this.state.pan.flattenOffset() 136 | let time = timestamp - this.startTime 137 | // console.log('time: ' + time) 138 | if ( 139 | time < 500 && 140 | Math.abs(gestureState.dx) < 10 && 141 | Math.abs(gestureState.dy) < 10 142 | ) { 143 | // 单击 144 | this._toggleDashboard() 145 | } else if ( 146 | time > 500 && 147 | Math.abs(gestureState.dx) < 10 && 148 | Math.abs(gestureState.dy) < 10 149 | ) { 150 | // 长按没有移动,do noting 151 | } else { 152 | this.x = gestureState.moveX > width * 0.5 ? RIGHT_X : LEFT_X 153 | const y = this.state.pan.y._value 154 | const min = 30 155 | const max = height - ICON_SIZE 156 | if (y < min) { 157 | this.y = min 158 | } else if (y > max) { 159 | this.y = max 160 | } else { 161 | this.y = y 162 | } 163 | // console.log('x, y', this.x, this.y) 164 | Animated.parallel([ 165 | Animated.spring(this.state.pan.x, { 166 | toValue: this.x, 167 | duration: 200, 168 | useNativeDriver: true 169 | }), 170 | Animated.spring(this.state.pan.y, { 171 | toValue: this.y, 172 | duration: 200, 173 | useNativeDriver: true 174 | }) 175 | ]).start() 176 | } 177 | } 178 | _toggleDashboard = () => { 179 | if (this.isFold) { 180 | // 展开 181 | this.isFold = false 182 | this.setState({ 183 | showDashboard: true 184 | }) 185 | this.state.expendAnim.setValue(100) 186 | Animated.timing(this.state.expendAnim, { 187 | toValue: 0, 188 | duration: 200, 189 | useNativeDriver: true 190 | }).start() 191 | } else { 192 | // 隐藏 193 | this.isFold = true 194 | this.state.expendAnim.setValue(0) 195 | Animated.timing(this.state.expendAnim, { 196 | toValue: 100, 197 | duration: 200, 198 | useNativeDriver: true 199 | }).start(() => { 200 | this.setState({ 201 | showDashboard: false 202 | }) 203 | }) 204 | } 205 | } 206 | 207 | _getEyeAnimatedStyle () { 208 | return { 209 | transform: [{ 210 | translateX: this.state.pan.x 211 | }, { 212 | translateY: this.state.pan.y 213 | }], 214 | opacity: this.state.expendAnim.interpolate({ 215 | inputRange: [0, 100], 216 | outputRange: [0, 1], 217 | }) 218 | } 219 | } 220 | 221 | _getDashboardAnimatedStyle () { 222 | return { 223 | opacity: this.state.expendAnim.interpolate({ 224 | inputRange: [0, 80, 100], 225 | outputRange: [1, 1, 0], 226 | }), 227 | transform: [{ 228 | translateY: this.state.expendAnim.interpolate({ 229 | inputRange: [0, 100], 230 | outputRange: [0, height] 231 | }) 232 | }, { 233 | translateX: this.state.expendAnim.interpolate({ 234 | inputRange: [0, 100], 235 | outputRange: [0, width] 236 | }) 237 | }] 238 | } 239 | } 240 | 241 | render () { 242 | const { 243 | showDashboard, 244 | errorCount, 245 | warnCount 246 | } = this.state 247 | return [ 248 | 258 | 266 | {errorCount > 0 ? 267 | {errorCount} 268 | : null} 269 | {warnCount > 0 ? 270 | {warnCount} 271 | : null} 272 | , 273 | 283 | 287 | 290 | 293 | 294 | 295 | 296 | {showDashboard ? : null} 297 | 298 | ] 299 | } 300 | } 301 | 302 | const styles = StyleSheet.create({ 303 | logRedBox: { 304 | borderRadius: 10, 305 | height: 18, 306 | backgroundColor: '#FF0000', 307 | alignItems: 'center' 308 | }, 309 | logWarnBox: { 310 | borderRadius: 10, 311 | height: 18, 312 | backgroundColor: '#FFCD36', 313 | alignItems: 'center' 314 | }, 315 | logCount: { 316 | color: '#FFFFFF' 317 | } 318 | }) 319 | -------------------------------------------------------------------------------- /library/components/Tab.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react' 2 | import { 3 | View, 4 | Text, 5 | TouchableOpacity, 6 | StyleSheet, 7 | PixelRatio 8 | } from 'react-native' 9 | import PropTypes from 'prop-types' 10 | const realOnePixel = 1 / PixelRatio.get() 11 | 12 | export default class Tab extends Component { 13 | static propTypes = { 14 | pages: PropTypes.arrayOf(PropTypes.shape({ 15 | title: PropTypes.string.isRequired, 16 | renderContent: PropTypes.func.isRequired 17 | })), 18 | initPage: PropTypes.number, 19 | style: PropTypes.any, 20 | onChangePage: PropTypes.func 21 | } 22 | static defaultProps = { 23 | pages: [], 24 | initPage: 0 25 | } 26 | 27 | constructor (props) { 28 | super(props) 29 | this.state = { 30 | showIndex: props.initPage 31 | } 32 | } 33 | 34 | _onChangePage (index) { 35 | this.setState({ 36 | showIndex: index 37 | }) 38 | this.props.onChangePage && this.props.onChangePage(index) 39 | } 40 | 41 | _renderButton (item, index) { 42 | const { 43 | showIndex 44 | } = this.state 45 | const isShow = showIndex === index 46 | return ( 47 | this._onChangePage(index)} 51 | style={[ 52 | styles.button, 53 | index > 0 ? styles.borderLeft : null 54 | ]} 55 | > 56 | {item.title} 57 | 58 | ) 59 | } 60 | 61 | render () { 62 | const { 63 | pages, 64 | style 65 | } = this.props 66 | const { 67 | showIndex 68 | } = this.state 69 | 70 | return ( 71 | 72 | 73 | {pages.map((item, index) => this._renderButton(item, index))} 74 | 75 | {pages[showIndex] 76 | ? pages[showIndex] && pages[showIndex].renderContent() 77 | : no renderContent for page-{showIndex}} 78 | 79 | ) 80 | } 81 | } 82 | 83 | const styles = StyleSheet.create({ 84 | header: { 85 | height: 40, 86 | flexDirection: 'row', 87 | borderBottomWidth: realOnePixel, 88 | borderBottomColor: 'gray' 89 | }, 90 | button: { 91 | flex: 1, 92 | justifyContent: 'center', 93 | alignItems: 'center' 94 | }, 95 | text: { 96 | fontSize: 16, 97 | color: 'gray' 98 | }, 99 | textActive: { 100 | color: 'black' 101 | }, 102 | borderLeft: { 103 | borderLeftWidth: realOnePixel, 104 | borderLeftColor: 'gray' 105 | } 106 | }) 107 | -------------------------------------------------------------------------------- /library/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/library/images/close.png -------------------------------------------------------------------------------- /library/images/tianyan-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeBankFinTech/wt-console/035cde052d54c98ed4b45722fc6be86d6083bb59/library/images/tianyan-icon.png -------------------------------------------------------------------------------- /library/index.js: -------------------------------------------------------------------------------- 1 | import TianYan from './TianYan' 2 | import Dashboard from './Dashboard' 3 | export default TianYan 4 | export {Dashboard} 5 | -------------------------------------------------------------------------------- /library/plugins/Plugin.js: -------------------------------------------------------------------------------- 1 | import { Component } from 'react' 2 | export default class Plugin extends Component { 3 | setup () { 4 | 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /library/plugins/components/Button.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Text } from 'react-native' 3 | import { TouchableOpacity } from 'react-native' 4 | import PropTypes from 'prop-types' 5 | 6 | export default class Button extends React.Component { 7 | static propTypes = { 8 | onPress: PropTypes.func.isRequired, 9 | text: PropTypes.string.isRequired, 10 | disabled: PropTypes.bool, 11 | style: PropTypes.any 12 | } 13 | static defaultProps = { 14 | fontColor: 'crimson' 15 | } 16 | onPress = () => { 17 | const { 18 | disabled 19 | } = this.props 20 | if (disabled) { 21 | return 22 | } 23 | this.props.onPress() 24 | } 25 | render () { 26 | const { 27 | disabled 28 | } = this.props 29 | return ( 30 | 42 | {this.props.text} 43 | 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /library/plugins/components/ButtonGroup.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react' 2 | import { 3 | View, 4 | Text, 5 | PixelRatio, 6 | TouchableOpacity 7 | } from 'react-native' 8 | import PropTypes from 'prop-types' 9 | 10 | export default class ButtonGroup extends Component { 11 | static propTypes = { 12 | list: PropTypes.arrayOf(PropTypes.shape({ 13 | name: PropTypes.string.isRequired, 14 | onPress: PropTypes.func.isRequired 15 | })) 16 | } 17 | render () { 18 | return ( 19 | 27 | {this.props.list.map((item, index) => { 28 | const eles = [] 29 | if (index > 0) { 30 | eles.push( 31 | 38 | ) 39 | } 40 | eles.push( 41 | 48 | 55 | {item.name} 58 | 59 | 60 | ) 61 | return eles 62 | })} 63 | 64 | ) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /library/plugins/components/Search.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react' 2 | import { View, TextInput } from 'react-native' 3 | import { realOnePixel } from '../utils/DumpObject' 4 | import Button from './Button' 5 | import PropTypes from 'prop-types' 6 | import {monospaceFont} from './Text' 7 | 8 | export default class Search extends Component { 9 | static propTypes = { 10 | defaultValue: PropTypes.string, 11 | value: PropTypes.string, 12 | onChangeText: PropTypes.func, 13 | onEndText: PropTypes.func, 14 | onCleanText: PropTypes.func, 15 | keyboardType: PropTypes.string, 16 | onMaybeFinish:PropTypes.func 17 | } 18 | static defaultProps = { 19 | keyboardType: 'ascii-capable' 20 | } 21 | 22 | constructor () { 23 | super(...arguments) 24 | this.state = { 25 | value: this.props.value 26 | } 27 | } 28 | _onClean = () => { 29 | this.props.onCleanText && this.props.onCleanText('') 30 | this.setState({ 31 | value: '' 32 | }) 33 | } 34 | _onChangeText = (text) => { 35 | this.props.onChangeText && this.props.onChangeText(text) 36 | 37 | if (this.props.onMaybeFinish) { 38 | if (this.textChangeTimer) { 39 | clearTimeout(this.textChangeTimer) 40 | this.textChangeTimer = false 41 | } 42 | 43 | this.textChangeTimer = setTimeout(() => { 44 | this.props.onMaybeFinish(text) 45 | }, 1000) 46 | } 47 | } 48 | _onEndEditing = (event) => { 49 | this.props.onEndText && this.props.onEndText(event.nativeEvent.text) 50 | } 51 | render () { 52 | return ( 53 | 58 | 80 |