diff --git a/src/app.ts b/src/app.ts index 5063fc7..2c0b331 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,13 +1,10 @@ export const dva = { config: { - onError(err: ErrorEvent | any) { + onError(err: ErrorEvent) { err.preventDefault(); // tslint:disable-next-line: no-console console.error(err.message); - if (err.name === 'ChunkLoadError') { - location.reload(); - } }, }, }; diff --git a/src/assets/a_android.png b/src/assets/a_android.png new file mode 100644 index 0000000..4a0185e Binary files /dev/null and b/src/assets/a_android.png differ diff --git a/src/assets/a_ios.png b/src/assets/a_ios.png new file mode 100644 index 0000000..9096f0c Binary files /dev/null and b/src/assets/a_ios.png differ diff --git a/src/assets/a_telegram.png b/src/assets/a_telegram.png new file mode 100644 index 0000000..3dc8cc8 Binary files /dev/null and b/src/assets/a_telegram.png differ diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..18b3d82 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,16 @@ + +export default { + exitPaths: [ + '/check', + '/home/estate', + '/home/fund', + '/home/market', + '/home/profile', + ], + baseURL: 'https://server.fiv.tacever.org/v1', + // baseURL: 'http://yapi.faronear.org/mock/20/v1', + linkAndroid: 'xxx', + linkIOS: '', + linkTelegram: 'https://t.me/fivhome', + linkEmail: 'team-fiv@outlook.com', +}; diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 0fe5b82..6e34ac3 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -174,4 +174,11 @@ export default { 'system.chooseLang': 'Choose Language', 'about.title': '关于第五维度', + 'about.desc': '数字货币财富管理平台', + 'about.appTitle': '下载 APP', + 'about.appDesc': '(点击相应图标获取 APP 下载地址)', + 'about.comTitle': '加入社区', + 'about.comDesc': '(点击相应图标获取社区地址)', + 'about.contact': '联系我们', + 'about.copyright': 'Copyright ©2019 第五维度', } diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index e0ca803..d7132a8 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -156,7 +156,7 @@ export default { 'profile.identity': '实名认证', 'profile.share': '社区推广', 'profile.msg': '消息中心', - 'profile.about': '关于洛格', + 'profile.about': '关于第五维度', 'account.title': '我的账户', 'account.nickname': '昵称', @@ -174,4 +174,11 @@ export default { 'system.chooseLang': '请选择语言', 'about.title': '关于第五维度', + 'about.desc': '数字货币财富管理平台', + 'about.appTitle': '下载 APP', + 'about.appDesc': '(点击相应图标获取 APP 下载地址)', + 'about.comTitle': '加入社区', + 'about.comDesc': '(点击相应图标获取社区地址)', + 'about.contact': '联系我们', + 'about.copyright': 'Copyright ©2019 第五维度', } diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index d1f4004..afce216 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -3,19 +3,89 @@ * Routes: * - ./src/pages/routes */ -import React from 'react'; -import Header from '@/components/Header'; +import React, { useState } from 'react'; import { formatMessage } from 'umi-plugin-locale'; +import FittedImage from 'react-fitted-image'; +import { Modal } from 'antd'; +import { QRCanvas } from 'qrcanvas-react'; +import Header from '@/components/Header'; +import config from '@/config'; +import logo from '@/assets/bg_login.png'; +import pAndroid from '@/assets/a_android.png'; +import pIOS from '@/assets/a_ios.png'; +import pTelegram from '@/assets/a_telegram.png'; import styles from './style.less'; const AboutPage: React.FC = () => { + const [info, setInfo] = useState(''); + + const showInfo = ( + setInfo('')} + > +
+ {info && } + {info} +
+
+ ); + return (
-
- body +
+
+ +
+ + {formatMessage({ id: 'app.name' })} + {formatMessage({ id: 'about.desc' })} + +
+ {(config.linkAndroid || config.linkIOS) && ( +
+ {formatMessage({ id: 'about.appTitle' })} + {formatMessage({ id: 'about.appDesc' })} +
+ {config.linkAndroid &&
setInfo(config.linkAndroid)}> +
+ Android +
} + {config.linkIOS &&
setInfo(config.linkIOS)}> +
+ iOS +
} +
+
+ )} + {config.linkTelegram && ( +
+ {formatMessage({ id: 'about.comTitle' })} + {formatMessage({ id: 'about.comDesc' })} +
+
setInfo(config.linkTelegram)}> +
+ Telegram +
+
+
+ )} +
+ {formatMessage({ id: 'about.contact' })} + {config.linkEmail} +
+
+ +
{formatMessage({ id: 'about.copyright' })}
+ {showInfo}
); } diff --git a/src/pages/about/style.less b/src/pages/about/style.less index 6a1573f..560c58f 100644 --- a/src/pages/about/style.less +++ b/src/pages/about/style.less @@ -1,3 +1,5 @@ +@import '../../global.less'; + .container { height: 100%; display: flex; @@ -6,4 +8,73 @@ .body { flex-grow: 1; + display: flex; + flex-direction: column; + align-items: center; + overflow-y: auto; + + :global { + .logo { + width: 64px; + margin: 16px 0 10px; + } + + .app-name, .app-desc { + color: #000; + font-size: 0.9rem; + } + + .app-desc { + margin-bottom: 20px; + } + } +} + +.content { + align-self: stretch; + border: 1px solid @hint-color; + margin: 0 20px; + border-radius: 4px; + padding: 20px; + display: flex; + flex-direction: column; + + :global { + .section { + display: flex; + flex-direction: column; + align-items: center; + } + + .section:nth-child(n+2) { + margin-top: 10px; + } + + .desc { + font-size: 0.8rem; + } + + .icon-list { + display: flex; + flex-direction: row; + justify-content: center; + } + + .icon-item { + display: flex; + flex-direction: column; + align-items: center; + margin: 8px 10px 0; + } + + .icon-icon { + width: 64px; + } + } +} + +.dlg { + display: flex; + flex-direction: column; + align-items: center; } diff --git a/src/pages/home/estate/index.tsx b/src/pages/home/estate/index.tsx index c986d8e..13d4937 100644 --- a/src/pages/home/estate/index.tsx +++ b/src/pages/home/estate/index.tsx @@ -20,7 +20,7 @@ const MinePage: React.FC = ({ useEffect(() => { if (!data || errorList) { - dispatch({ type: 'homeMine/loadList' }); + dispatch({ type: 'homeMine/loadList', payload: false }); } if (!info || errorBasic) { dispatch({ type: 'homeMine/loadBasic' }); @@ -29,8 +29,7 @@ const MinePage: React.FC = ({ const onRefresh = () => { if (refreshingBasic || refreshingList) return; - dispatch({ type: 'homeMine/loadList', payload: true }); - dispatch({ type: 'homeMine/loadBasic' }); + dispatch({ type: 'homeMine/refresh' }); }; const renderBanner = ( diff --git a/src/pages/home/estate/model.ts b/src/pages/home/estate/model.ts index 53ae02e..83224da 100644 --- a/src/pages/home/estate/model.ts +++ b/src/pages/home/estate/model.ts @@ -1,6 +1,7 @@ import { Model } from 'dva'; import { Mines, MineBasic } from '@/types/common'; -import { getMineList, getMineBasic } from './service'; +import { getMineList, getMineBasic, refresh, RefreshData } from './service'; +import { message } from 'antd'; export interface HomeMineModelState { refreshingList: boolean; @@ -78,6 +79,38 @@ const MineModel: Model = { }); } }, + + *refresh(_, { put, call, select }) { + const { refreshingBasic } = yield select((state: any) => state.homeMine); + if (refreshingBasic) return; + + yield put({ + type: 'onUpdateState', + refreshingBasic: true, + refreshingList: true, + errorBasic: false, + errorList: false, + }); + try { + const info = (yield call(refresh)) as RefreshData; + yield put({ + type: 'onUpdateState', + info: info.basic, + data: info.list, + refreshingBasic: false, + refreshingList: false, + errorBasic: false, + }); + } catch (e) { + message.error(e.message); + yield put({ + type: 'onUpdateState', + refreshingBasic: false, + refreshingList: false, + errorBasic: true, + }); + } + }, }, reducers: { diff --git a/src/pages/home/estate/service.ts b/src/pages/home/estate/service.ts index 3299368..f51a2c1 100644 --- a/src/pages/home/estate/service.ts +++ b/src/pages/home/estate/service.ts @@ -2,6 +2,11 @@ import http from '@/utils/http'; import { Mines, MineBasic } from '@/types/common'; import { loadMineList, storeMineList } from '@/utils/storage'; +export interface RefreshData { + basic: MineBasic; + list: Mines; +} + export async function getMineBasic(): Promise { const { ok, @@ -33,3 +38,16 @@ export async function getMineList(refresh = false): Promise { } throw Error(msg); } + +export async function refresh(): Promise { + const { + ok, + data, + msg, + } = await http.get('/fund/refresh'); + if (ok && data) { + storeMineList(data); + return data; + } + throw Error(msg); +} diff --git a/src/pages/routes.tsx b/src/pages/routes.tsx index 164f7b1..031b76d 100644 --- a/src/pages/routes.tsx +++ b/src/pages/routes.tsx @@ -7,7 +7,6 @@ import styles from './index.css'; const unauthorizedPaths = [ '/check', - '/register', ]; const Page: React.FC = ({ diff --git a/src/utils/h5plus.ts b/src/utils/h5plus.ts index a7f57fd..345a099 100644 --- a/src/utils/h5plus.ts +++ b/src/utils/h5plus.ts @@ -1,5 +1,6 @@ import { dispatch, getState } from './utils'; import { routerRedux } from 'dva'; +import config from '@/config'; const isApp = () => { const r = typeof window.plus !== 'undefined'; @@ -32,13 +33,6 @@ const scan = () => { }); }; -const firstPaths = [ - '/check', - '/home/estate', - '/home/fund', - '/home/market', - '/home/profile', -]; const backButtonHandler = () => { const barcode = window.plus.barcode.getBarcodeById(barcodeId); if (barcode) { @@ -46,7 +40,7 @@ const backButtonHandler = () => { return; } const { pathname } = getState().router.location; - if (firstPaths.includes(pathname)) { + if (config.exitPaths.includes(pathname)) { window.plus.runtime.quit(); } else { dispatch(routerRedux.goBack()); diff --git a/src/utils/http.ts b/src/utils/http.ts index 95b8f61..1e57593 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -3,6 +3,7 @@ import { formatMessage } from 'umi-plugin-locale'; import _ from 'lodash'; import { globalState } from '@/services/common'; import { isDev, dispatch } from './utils'; +import config from '@/config'; export interface AppResp { ok: boolean, @@ -19,8 +20,7 @@ const errorMap = { 403: 'common.403', }; -const baseURL = 'https://server.fiv.tacever.org/v1'; -// const baseURL = 'http://yapi.faronear.org/mock/20/v1'; +const { baseURL } = config; const instance = axios.create({ baseURL, });