From: Zhiting Lin Date: Wed, 17 Oct 2018 06:56:43 +0000 (+0800) Subject: merge dashboard into electron X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8ffc8278aa449e3e3569d35c5c9db692e0bea8fe;p=bytom%2Fbytom-electron.git merge dashboard into electron --- 8ffc8278aa449e3e3569d35c5c9db692e0bea8fe diff --cc package-lock.json index 29fe355,bd2a0eb..d90e885 --- a/package-lock.json +++ b/package-lock.json @@@ -4,17 -4,20 +4,31 @@@ "lockfileVersion": 1, "requires": true, "dependencies": { + "7zip-bin": { + "version": "4.0.2", + "resolved": "http://registry.npm.taobao.org/7zip-bin/download/7zip-bin-4.0.2.tgz", + "integrity": "sha1-arvcIvM8q3QgU3d6JtsuJcpScXk=", + "dev": true + }, + "@types/node": { + "version": "8.10.17", + "resolved": "http://registry.npm.taobao.org/@types/node/download/@types/node-8.10.17.tgz", + "integrity": "sha1-1IzxDw3G3PWfgn9aP8ekpgBDGNM=", + "dev": true + "@babel/runtime": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.2.tgz", + "integrity": "sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==", + "requires": { + "regenerator-runtime": "0.12.1" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + } + } }, "abbrev": { "version": "1.1.1", @@@ -2399,10 -1758,19 +2413,19 @@@ "object-assign": "4.1.1" } }, + "create-react-context": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/create-react-context/-/create-react-context-0.2.3.tgz", + "integrity": "sha512-CQBmD0+QGgTaxDL3OX1IDXYqjkp2It4RIbcb99jS6AEg27Ga+a9G3JtK6SIu0HBwPLZlmwt9F7UwWA4Bn92Rag==", + "requires": { + "fbjs": "0.8.16", + "gud": "1.0.0" + } + }, "cross-spawn": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz", - "integrity": "sha1-ElYDfsufDF9549bvE14wdwGEuYI=", + "version": "5.1.0", + "resolved": "http://registry.npm.taobao.org/cross-spawn/download/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "dev": true, "requires": { "lru-cache": "4.1.3", @@@ -4961,16 -3449,16 +4984,21 @@@ "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true }, + "growl": { + "version": "1.8.1", + "resolved": "http://registry.npm.taobao.org/growl/download/growl-1.8.1.tgz", + "integrity": "sha1-Sy3sjZB+k9szZiTc7AGDUC+MlCg=", + "dev": true + }, + "gud": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", + "integrity": "sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw==" + }, "har-schema": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true + "resolved": "http://registry.npm.taobao.org/har-schema/download/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" }, "har-validator": { "version": "5.0.3", @@@ -5112,10 -3559,19 +5140,18 @@@ "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=", "dev": true }, + "html-parse-stringify2": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-parse-stringify2/-/html-parse-stringify2-2.0.1.tgz", + "integrity": "sha1-3FZwtyksoVi3vJFsmmc1rIhyg0o=", + "requires": { + "void-elements": "2.0.1" + } + }, "http-errors": { "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "resolved": "http://registry.npm.taobao.org/http-errors/download/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", - "dev": true, "requires": { "depd": "1.1.2", "inherits": "2.0.3", @@@ -5202,19 -3636,15 +5238,24 @@@ "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", "dev": true }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "http://registry.npm.taobao.org/https-proxy-agent/download/https-proxy-agent-2.2.1.tgz", + "integrity": "sha1-UVUpcPoE1yPgTFbQQXjD+SWSu8A=", + "requires": { + "agent-base": "4.2.0", + "debug": "3.1.0" + } + }, "i18next": { - "version": "10.5.1", - "resolved": "http://registry.npm.taobao.org/i18next/download/i18next-10.5.1.tgz", - "integrity": "sha1-+OHKThXEQOvDqaXD0BXDptKIeJA=" + "version": "11.9.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-11.9.1.tgz", + "integrity": "sha512-sUAfCdKYi8EufO6B8aY5RF/hqweCpRKvbxUhlzlmlAr+LgJQ2kXe/5y02kaPu6ApFIiW5WOz8+3ehoy97LUtMw==" + }, + "i18next-browser-languagedetector": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-2.2.3.tgz", + "integrity": "sha512-sJZ2n9Vgax0vGer23hJMwyO3FRO7P0dq2DXZPXWE329g3snfJUcw+S24Mp3lqJaxL/0McDu4BD75ds6pzIfhhw==" }, "iconv-lite": { "version": "0.4.23", @@@ -7673,21 -5072,11 +7714,20 @@@ "asap": "2.0.6" } }, + "promisify-call": { + "version": "2.0.4", + "resolved": "http://registry.npm.taobao.org/promisify-call/download/promisify-call-2.0.4.tgz", + "integrity": "sha1-1IwtRWUszM1SgB3ey9UzptS9X7o=", + "optional": true, + "requires": { + "with-callback": "1.0.2" + } + }, "prop-types": { - "version": "15.6.1", - "resolved": "http://registry.npm.taobao.org/prop-types/download/prop-types-15.6.1.tgz", - "integrity": "sha1-NmREU1ZCVd3aORGR+zoSXL32VMo=", + "version": "15.6.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz", + "integrity": "sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==", "requires": { - "fbjs": "0.8.16", "loose-envify": "1.3.1", "object-assign": "4.1.1" } @@@ -7983,10 -5350,31 +8023,31 @@@ } } }, + "react-i18next": { + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-8.0.7.tgz", + "integrity": "sha512-oJDVe5X8QK72NYYH7/VQtopONZPcNiarlWdVuCSkn9PucQCEAOf/yRt0V2LdjC4nBY48Y20/540glwR1nlE9gA==", + "requires": { + "@babel/runtime": "7.1.2", + "create-react-context": "0.2.3", + "hoist-non-react-statics": "3.0.1", + "html-parse-stringify2": "2.0.1" + }, + "dependencies": { + "hoist-non-react-statics": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.0.1.tgz", + "integrity": "sha512-1kXwPsOi0OGQIZNVMPvgWJ9tSnGMiMfJdihqEzrPEXlHOBh9AAHXX/QYmAJTXztnz/K+PQ8ryCb4eGaN6HlGbQ==", + "requires": { + "react-is": "16.3.2" + } + } + } + }, "react-is": { - "version": "16.3.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.3.2.tgz", - "integrity": "sha512-ybEM7YOr4yBgFd6w8dJqwxegqZGJNBZl6U27HnGKuTZmDvVrD5quWOK/wAnMywiZzW+Qsk+l4X2c70+thp/A8Q==" + "version": "16.4.0", + "resolved": "http://registry.npm.taobao.org/react-is/download/react-is-16.4.0.tgz", + "integrity": "sha1-zJ/chVrDTS59nS63BZu8JA01/88=" }, "react-lazy-cache": { "version": "3.0.1", @@@ -8122,64 -5510,12 +8183,64 @@@ "requires": { "dom-helpers": "3.3.1", "loose-envify": "1.3.1", - "prop-types": "15.6.1" + "prop-types": "15.6.2" } }, + "read-config-file": { + "version": "3.0.1", + "resolved": "http://registry.npm.taobao.org/read-config-file/download/read-config-file-3.0.1.tgz", + "integrity": "sha1-MH7S4WL6VDBtCubUHpzcgpcg0qk=", + "dev": true, + "requires": { + "ajv": "6.5.0", + "ajv-keywords": "3.2.0", + "bluebird-lst": "1.0.5", + "dotenv": "5.0.1", + "dotenv-expand": "4.2.0", + "fs-extra-p": "4.6.0", + "js-yaml": "3.11.0", + "json5": "1.0.1", + "lazy-val": "1.0.3" + }, + "dependencies": { + "ajv": { + "version": "6.5.0", + "resolved": "http://registry.npm.taobao.org/ajv/download/ajv-6.5.0.tgz", + "integrity": "sha1-TIr/34CIfY8TLJxSq4otxNC3skw=", + "dev": true, + "requires": { + "fast-deep-equal": "2.0.1", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1", + "uri-js": "4.2.2" + } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "http://registry.npm.taobao.org/fast-deep-equal/download/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "json5": { + "version": "1.0.1", + "resolved": "http://registry.npm.taobao.org/json5/download/json5-1.0.1.tgz", + "integrity": "sha1-d5+wAYYE+oVOrL9iUhgNg1Q+Pb4=", + "dev": true, + "requires": { + "minimist": "1.2.0" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, "read-pkg": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "resolved": "http://registry.npm.taobao.org/read-pkg/download/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { @@@ -10185,9 -6917,14 +10246,14 @@@ "indexof": "0.0.1" } }, + "void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" + }, "w3c-blob": { "version": "0.0.1", - "resolved": "https://registry.npmjs.org/w3c-blob/-/w3c-blob-0.0.1.tgz", + "resolved": "http://registry.npm.taobao.org/w3c-blob/download/w3c-blob-0.0.1.tgz", "integrity": "sha1-sM01KhpQ9RVWNCD/1YYflQ8dhbg=" }, "warning": { diff --cc package.json index d69f526,18230f8..842fbfb --- a/package.json +++ b/package.json @@@ -91,11 -22,9 +91,13 @@@ "bootstrap-sass": "~3.3.7", "btoa": "^1.1.2", "classnames": "~2.2.5", + "electron-settings": "~3.1.4", + "glob": "~7.1.2", + "i18next": "~10.5.1", + "log4js": "^2.5.3", "fetch-ponyfill": "~3.0.2", + "i18next": "^11.9.1", + "i18next-browser-languagedetector": "^2.2.3", "lodash": "~4.17.4", "moment": "^2.22.1", "moment-timezone": "^0.5.17", diff --cc src/features/app/components/Container.jsx index 0ca51ca,fb49892..94de606 --- a/src/features/app/components/Container.jsx +++ b/src/features/app/components/Container.jsx @@@ -38,42 -37,17 +39,42 @@@ class Container extends React.Componen this.props.showConfiguration() } } - componentDidMount() { - this.props.fetchAccountItem().then(resp => { - if (resp.data.length == 0) { - this.setState({noAccountItem: true}) - } - }) + 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.uptdateLang(arg) + }) + window.ipcRenderer.on('ConfiguredNetwork', (event, arg) => { + if(arg === 'startNode'){ + this.props.fetchInfo().then(() => { + this.props.fetchAccountItem().then(resp => { + if (resp.data.length == 0) { + this.setState({noAccountItem: true}) + } + }) + 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.lang === 'zh'){ + if(this.props.lng === 'zh'){ moment.locale('zh-cn') }else{ - moment.locale(this.props.lang) + moment.locale(this.props.lng) } } @@@ -93,14 -70,22 +89,23 @@@ render() { let layout + const lang = this.props.lang + const { i18n } = this.props + i18n.on('languageChanged', function(lng) { + if(lng === 'zh'){ + moment.locale('zh-cn') + }else{ + moment.locale(lng) + } + }) + if (!this.props.authOk) { layout = - } else if (!this.props.configKnown) { - return Connecting to Bytom Core... } else if (!this.props.configured) { layout = {this.props.children} + } else if (!this.props.configKnown) { + return {lang === 'zh'? '正在连接到Bytom Core...' : 'Connecting to Bytom Core...'} } else if (!this.props.accountInit && this.state.noAccountItem){ layout = {this.props.children} } else{ @@@ -125,22 -110,15 +130,21 @@@ export default connect( (state) => ({ authOk: !state.core.requireClientToken || state.core.validToken, - configKnown: true, - configured: true, + configKnown: state.core.configKnown, + configured: state.core.configured, onTestnet: state.core.onTestnet, + flashMessages: state.app.flashMessages, accountInit: state.core.accountInit, - lang: state.core.lang }), (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)), + uptdateLang: (param) => dispatch(actions.core.updateLang(param)), + updateConfiguredStatus: () => dispatch(actions.core.updateConfiguredStatus), + markFlashDisplayed: (key) => dispatch(actions.app.displayedFlash(key)), fetchAccountItem: () => dispatch(actions.account.fetchItems()) }) - )(Container) + )( withI18n() (Container) ) diff --cc src/features/app/components/Navigation/Navigation.jsx index 99591ad,167d4a8..3086ad9 --- a/src/features/app/components/Navigation/Navigation.jsx +++ b/src/features/app/components/Navigation/Navigation.jsx @@@ -4,8 -4,9 +4,10 @@@ import {Link} from 'react-router import styles from './Navigation.scss' import {navIcon} from '../../utils' import Sync from '../Sync/Sync' +import appAction from '../../../app/actions' import {docsRoot, releaseUrl} from '../../../../utility/environment' + import { capitalize } from 'utility/string' + import {withNamespaces} from 'react-i18next' class Navigation extends React.Component { constructor(props) { @@@ -121,18 -112,7 +121,11 @@@ export default connect update: state.core.update, coreData: state.core.coreData, routing: state.routing, // required for s to update active state on navigation - lang: state.core.lang, showNavAdvance: state.app.navAdvancedState === 'advance' } - } + }, + (dispatch) => ({ + showNavAdvanced: () => dispatch(appAction.showNavAdvanced), - hideNavAdvanced: () => dispatch(appAction.hideNavAdvanced), - setLang: (event) => { - dispatch({ - type: 'UPDATE_CORE_LANGUAGE', - lang: event - }) - } ++ hideNavAdvanced: () => dispatch(appAction.hideNavAdvanced) + }) - )(Navigation) + )( withNamespaces('translations')(Navigation)) diff --cc src/features/core/actions.js index 8da5490,10c5beb..e7156bc --- a/src/features/core/actions.js +++ b/src/features/core/actions.js @@@ -4,8 -4,6 +4,7 @@@ const updateInfo = (param) => ({type: ' const setClientToken = (token) => ({type: 'SET_CLIENT_TOKEN', token}) const clearSession = ({ type: 'USER_LOG_OUT' }) const updateBTMAmountUnit = (param) => ({type: 'UPDATE_BTM_AMOUNT_UNIT', param}) +const updateConfiguredStatus = ({ type: 'SET_CONFIGURED' }) - const updateLang = (param) => ({type: 'UPDATE_CORE_LANGUAGE', lang:param}) const updateMiningState = (param) => { return (dispatch) => { @@@ -90,8 -88,6 +89,7 @@@ let actions = setClientToken, updateInfo, updateBTMAmountUnit, - updateLang, + updateConfiguredStatus, updateMiningState, fetchCoreInfo, clearSession, diff --cc src/features/core/components/CoreIndex/CoreIndex.jsx index 1d5c88f,6fe94af..523c152 --- a/src/features/core/components/CoreIndex/CoreIndex.jsx +++ b/src/features/core/components/CoreIndex/CoreIndex.jsx @@@ -5,7 -5,9 +5,8 @@@ import { PageContent, PageTitle, Consol import React from 'react' import styles from './CoreIndex.scss' import actions from 'actions' + import {withNamespaces} from 'react-i18next' - class CoreIndex extends React.Component { constructor(props) { super(props) diff --cc src/features/core/reducers.js index 9ca64c7,99e8f20..9b810d4 --- a/src/features/core/reducers.js +++ b/src/features/core/reducers.js @@@ -206,36 -204,8 +206,28 @@@ export const btmAmountUnit = (state = ' return state } +let configuredState = false +if(window.remote){ + configuredState = window.remote.getGlobal('fileExist') +} +export const configured = (state = configuredState, action) => { + if( mode === 'electron'){ + if (action.type == 'SET_CONFIGURED') { + return true + } + return state + }else{ + return true + } +} + - const defaultLang = window.navigator.language.startsWith('zh') ? 'zh' : 'en' - const lang = (state = defaultLang, action) => { - if (action.type === 'UPDATE_CORE_LANGUAGE') { - return action.lang || '' - } - return state - } - const mingStatus = (state = false, action) => { if (action.type == 'UPDATE_CORE_INFO') { + if(window.remote && window.remote.getGlobal('mining').isMining!= action.param.data.mining){ + window.remote.getGlobal('mining').isMining = action.param.data.mining + window.ipcRenderer.send('refresh-menu') + } + return action.param.data.mining } return state