OSDN Git Service

merge the master vapor into electron
authorZhiting Lin <zlin035@uottawa.ca>
Wed, 17 Jul 2019 09:30:26 +0000 (17:30 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Wed, 17 Jul 2019 09:30:26 +0000 (17:30 +0800)
1  2 
modules/interface/locales/en/translation.json
modules/interface/locales/zh/translation.json
src/Root.jsx
src/features/app/components/Container.jsx
src/features/app/components/Navigation/Navigation.jsx
src/features/core/components/CoreIndex/CoreIndex.jsx
src/features/core/reducers.js
src/features/initialization/components/Index/Index.jsx
src/utility/environment.js
src/utility/localStorage.js
static/styles/resources.scss

      "mnemonic":"mnemonic",
      "mnemonicRequire":"Mnemonic is Required",
      "create": "Create Wallet",
-     "createDescription":"This option will create a default account, key password and give you a option to keep you mnemonic.  Warning: key seed words will display only once, it's important to remember your password.",
-     "welcome":"Welcome to Bytom __network__"
+     "createDescription":"This option will create a default account, key password.  Warning: it's important to remember your password.",
+     "welcome":"Welcome to Vapor __network__"
    },
 +  "welcome":{
 +    "connect":"Connecting to Bytom Core...",
 +    "join":"Joining network",
 +    "joining":"Joining network...",
 +    "title":"Configure Bytom Core",
 +    "mainnetTitle":"Join the Bytom Mainnet",
 +    "mainnetMsg":"For common users to enter. Mainnet is the production network, that carry real Bytom transactions.",
 +    "testnetTitle":"Join the Bytom Testnet",
 +    "testnetMsg":"For developers or bytom testers to enter. Testnet is an alternative Bytom blockchain, and to be used for testing.",
 +    "solonetTitle":"Create the Bytom Soloent",
 +    "solonetMsg":"For users/developers to run and test wallet's new function. Solonet is a private sandbox blockchain network."
 +  },
    "backup":{
      "title":"Backup and Restore",
      "backup":"Back Up",
      "mnemonic":"助记词",
      "mnemonicRequire":"助记词是必须项",
      "create": "新建钱包",
-     "createDescription":"这个选项将生成默认的挖矿账户和默认密钥。 助记词将会在此生成,您可以选择保留助记词或者跳过。 注意: 助记词只生成一次, 请将密码,助记词妥善保存",
+     "createDescription":"这个选项将生成默认的挖矿账户和默认密钥。注意: 请将密码妥善保存",
      "welcome":"欢迎来到__network__"
    },
 +  "welcome":{
 +    "connect":"正在连接到Bytom Core...",
 +    "join":"加入网络",
 +    "joining":"加入网络...",
 +    "title":"配置 Bytom Core",
 +    "mainnetTitle":"加入 Bytom 主网",
 +    "mainnetMsg":"普通用户选择加入。这是实际的Bytom网络,包含真实的交易信息。",
 +    "testnetTitle":"加入 Bytom 测试网络",
 +    "testnetMsg":"开发者选择加入。这是Bytom的测试网络,用于Bytom的相关测试。",
 +    "solonetTitle":"创建 Bytom 单机网络",
 +    "solonetMsg":"创建一个沙盒私有网络供用户运行和测试功能。"
 +  },
    "backup":{
      "title":"备份与恢复",
      "backup":"备份",
diff --cc src/Root.jsx
@@@ -9,7 -9,7 +9,7 @@@ import makeRoutes from './routes
  
  export default class Root extends React.Component {
    componentWillMount() {
-     document.title = 'Bytom Wallet'
 -    document.title = 'Vapor Dashboard'
++    document.title = 'Vapor Wallet'
    }
  
    render() {
@@@ -10,12 -10,6 +10,9 @@@ const CORE_POLLING_TIME = 2 * 100
  class Container extends React.Component {
    constructor(props) {
      super(props)
-     this.state = {
-       noAccountItem: false
-     }
 +    if(props.location.pathname.includes('index.html')) {
 +      this.redirectRoot(props)
 +    }
      this.redirectRoot = this.redirectRoot.bind(this)
    }
  
        return
      }
  
 -    if (accountInit) {
 -      if (location.pathname === '/'|| location.pathname.indexOf('initialization') >= 0) {
 +    if(!configured){
 +      this.props.showConfiguration()
-     }else if(!accountInit && this.state.noAccountItem){
++    }else if(!accountInit){
 +      this.props.showInitialization()
 +    }else {
 +      if (location.pathname === '/' ||
 +        location.pathname.indexOf('configuration') >= 0 ||
 +        location.pathname.includes('index.html') ||
 +        location.pathname.indexOf('initialization') >= 0) {
          this.props.showRoot()
        }
 -    } else {
 -      this.props.showInitialization()
      }
    }
  
    componentDidMount() {
-     this.props.fetchKeyItem().then(resp => {
-       if (resp.data.length == 0) {
-         this.setState({noAccountItem: true})
-         this.redirectRoot(this.props)
-       }
-     })
 +    if(window.ipcRenderer){
 +      window.ipcRenderer.on('redirect', (event, arg) => {
 +        this.props.history.push(arg)
 +      })
 +      window.ipcRenderer.on('btmAmountUnitState', (event, arg) => {
 +        this.props.uptdateBtmAmountUnit(arg)
 +      })
 +      window.ipcRenderer.on('lang', (event, arg) => {
 +        this.props.i18n.changeLanguage(arg)
 +      })
 +      window.ipcRenderer.on('ConfiguredNetwork', (event, arg) => {
 +        if(arg === 'startNode'){
 +          this.props.fetchInfo().then(() => {
 +            this.props.fetchKeyItem().then(resp => {
 +              if (resp.data.length == 0) {
 +                this.setState({noAccountItem: true})
 +                this.props.showInitialization()
 +              }
 +            })
 +            this.props.showRoot()
 +          })
 +          setInterval(() => this.props.fetchInfo(), CORE_POLLING_TIME)
 +        }
 +        if(arg === 'init'){
 +          this.props.updateConfiguredStatus()
 +        }
 +      })
 +      window.ipcRenderer.on('mining', (event, arg) => {
 +        let isMining = (arg == 'true')
 +        this.props.updateMiningState(isMining)
 +      })
 +    }
      if(this.props.lng === 'zh'){
        moment.locale('zh-cn')
      }else{
  
    render() {
      let layout
-     const { t, i18n } = this.props
 -
+     const { i18n, t } = this.props
      i18n.on('languageChanged', function(lng) {
        if(lng === 'zh'){
          moment.locale('zh-cn')
  
      if (!this.props.authOk) {
        layout = <Login/>
 -    } else if (!this.props.configKnown) {
 -      return <Loading>{t('main.loading')}</Loading>
      } else if (!this.props.configured) {
        layout = <Config>{this.props.children}</Config>
-     } else if (!this.props.accountInit && this.state.noAccountItem){
 +    } else if (!this.props.configKnown) {
 +      return <Loading>{t('welcome.connect')}</Loading>
+     } else if (!this.props.accountInit){
        layout = <Config>{this.props.children}</Config>
      } else{
        layout = <Main>{this.props.children}</Main>
@@@ -141,19 -130,18 +168,23 @@@ export default connect
    (state) => ({
      authOk: !state.core.requireClientToken || state.core.validToken,
      configKnown: state.core.configKnown,
 -    configured: true,
 +    configured: state.core.configured,
-     onTestnet: state.core.onTestnet,
 +    flashMessages: state.app.flashMessages,
      accountInit: state.core.accountInit,
+     currentAccount: state.account.currentAccount
    }),
    (dispatch) => ({
      fetchInfo: options => dispatch(actions.core.fetchCoreInfo(options)),
 +    updateMiningState: param => dispatch(actions.core.updateMiningState(param)),
      showRoot: () => dispatch(actions.app.showRoot),
 +    showConfiguration: () => dispatch(actions.app.showConfiguration()),
 +    uptdateBtmAmountUnit: (param) => dispatch(actions.core.updateBTMAmountUnit(param)),
 +    updateConfiguredStatus: () => dispatch(actions.core.updateConfiguredStatus),
      showInitialization: () => dispatch(actions.app.showInitialization()),
-     fetchKeyItem: () => dispatch(actions.key.fetchItems())
+     updateAccountInit: (param) => dispatch(actions.app.updateAccountInit(param)),
+     fetchKeyItem: () => dispatch(actions.key.fetchItems()),
+     fetchAccountItem: () => dispatch(actions.account.fetchItems()),
+     setDefaultAccount:() => dispatch(actions.account.setDefaultAccount()),
+     switchAccount:(alias) => dispatch(actions.account.switchAccount(alias))
    })
  )( withI18n() (Container) )
@@@ -12,18 -12,12 +13,20 @@@ import actions from 'actions
  class Navigation extends React.Component {
    constructor(props) {
      super(props)
      this.openTutorial = this.openTutorial.bind(this)
+     this.state = {
+       showFed: false
+     }
    }
  
 +  componentDidMount() {
 +    if(window.ipcRenderer){
 +      window.ipcRenderer.on('toggleNavState', (event, arg) => {
 +        arg === 'advance'? this.props.showNavAdvanced() : this.props.hideNavAdvanced()
 +      })
 +    }
 +  }
 +
    openTutorial(event) {
      event.preventDefault()
      this.props.openTutorial()
            </li>
          </ul>
  
-         <ul className={styles.navigation}>
-           <li className={styles.navigationTitle}>{ t('crumbName.developer') }</li>
-           <li>
-             <a href='http://localhost:9888/equity' target='_blank'>
-               {navIcon('transaction', styles)}
-               { t('crumbName.equity')}
-             </a>
-           </li>
-         </ul>
 -        {/*<ul className={styles.navigation}>*/}
 -          {/*<li className={styles.navigationTitle}>{ t('crumbName.developer') }</li>*/}
 -          {/*<li>*/}
 -            {/*<a href='/equity' target='_blank'>*/}
 -              {/*{navIcon('transaction', styles)}*/}
 -              {/*{ t('crumbName.equity')}*/}
 -            {/*</a>*/}
 -          {/*</li>*/}
 -        {/*</ul>*/}
 -
  
          <Sync/>
  
@@@ -125,7 -140,6 +139,8 @@@ export default connect
      }
    },
    (dispatch) => ({
-     hideNavAdvanced: () => dispatch(appAction.hideNavAdvanced)
 +    showNavAdvanced: () => dispatch(appAction.showNavAdvanced),
++    hideNavAdvanced: () => dispatch(appAction.hideNavAdvanced),
+     fetchFederationItem: () => dispatch(actions.federation.fetchItems()),
    })
  )( withNamespaces('translations')(Navigation))
Simple merge
@@@ -7,8 -7,13 +7,8 @@@ import { useRouterHistory } from 'react
  import { createHistory } from 'history'
  
  let apiHost, basename
- apiHost = process.env.API_URL || 'http://localhost:9888'
 -if (process.env.NODE_ENV === 'production') {
 -  apiHost = window.location.origin
 -  basename = '/dashboard'
 -} else {
 -  apiHost = process.env.API_URL || 'http://localhost:9889'
 -  basename = ''
 -}
++apiHost = process.env.API_URL || 'http://localhost:9889'
 +basename = ''
  
  export const chainClient = () => new chainSdk.Client({
    url: apiHost,
Simple merge
Simple merge