init: Create & Init Taro TeraWallet

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-27 17:52:23 +08:00
commit 07f128ca04
41 changed files with 12320 additions and 0 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

15
.eslintrc Normal file
View File

@ -0,0 +1,15 @@
{
"extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"useJSXTextNode": true,
"project": "./tsconfig.json"
}
}

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store
*.log

21
config/dev.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
},
weapp: {},
h5: {
devServer: {
public: "https://tera-wallet.miaowoo.cc",
disableHostCheck: true,
proxy: {
'^/api': {
target: 'https://teraapi.sixi.com',
ws: true,
changeOrigin: true
}
}
},
}
}

102
config/index.js Normal file
View File

@ -0,0 +1,102 @@
const config = {
projectName: 'TeraWallet',
date: '2019-7-26',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: {
babel: {
sourceMap: true,
presets: [
['env', {
modules: false
}]
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread'
]
}
},
defineConstants: {
},
copy: {
patterns: [
],
options: {
}
},
weapp: {
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
pxtransform: {
enable: true,
config: {
}
},
url: {
enable: true,
config: {
limit: 10240 // 设定转换尺寸上限
}
},
cssModules: {
enable: false, // 默认为 false如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
},
h5: {
publicPath: '/',
staticDirectory: 'static',
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
}
},
cssModules: {
enable: false, // 默认为 false如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
}
}
module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
return merge({}, config, require('./prod'))
}

18
config/prod.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
},
weapp: {},
h5: {
/**
* 如果h5端编译后体积过大可以使用webpack-bundle-analyzer插件对打包体积进行分析
* 参考代码如下
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
}
}

18
global.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
declare module "*.png";
declare module "*.gif";
declare module "*.jpg";
declare module "*.jpeg";
declare module "*.svg";
declare module "*.css";
declare module "*.less";
declare module "*.scss";
declare module "*.sass";
declare module "*.styl";
// @ts-ignore
declare const process: {
env: {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
[key: string]: any;
}
}

77
package.json Normal file
View File

@ -0,0 +1,77 @@
{
"name": "tera-wallet",
"version": "1.0.0",
"private": true,
"description": "泰瑞管理工具",
"templateInfo": {
"name": "default",
"typescript": true,
"css": "sass"
},
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "^1.3.10",
"@tarojs/components": "1.3.10",
"@tarojs/redux": "^1.3.10",
"@tarojs/redux-h5": "^1.3.10",
"@tarojs/router": "1.3.10",
"@tarojs/taro": "1.3.10",
"@tarojs/taro-alipay": "1.3.10",
"@tarojs/taro-h5": "1.3.10",
"@tarojs/taro-qq": "1.3.10",
"@tarojs/taro-quickapp": "1.3.10",
"@tarojs/taro-swan": "1.3.10",
"@tarojs/taro-tt": "1.3.10",
"@tarojs/taro-weapp": "1.3.10",
"dva-core": "^1.4.0",
"dva-loading": "^3.0.12",
"nerv-devtools": "^1.4.0",
"nervjs": "^1.4.0",
"taro-ui": "^2.2.1"
},
"devDependencies": {
"@tarojs/cli": "^1.3.10",
"@tarojs/plugin-babel": "1.3.10",
"@tarojs/plugin-csso": "1.3.10",
"@tarojs/plugin-sass": "1.3.10",
"@tarojs/plugin-uglifyjs": "1.3.10",
"@tarojs/webpack-runner": "1.3.10",
"@types/react": "^16.4.6",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^5.16.0",
"eslint-config-taro": "1.3.10",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.3.10",
"stylelint": "9.3.0",
"stylelint-config-taro-rn": "1.3.10",
"stylelint-taro-rn": "1.3.10",
"typescript": "^3.0.1"
}
}

13
project.config.json Normal file
View File

@ -0,0 +1,13 @@
{
"miniprogramRoot": "./dist",
"projectname": "TeraWallet",
"description": "泰瑞管理工具",
"appid": "1109699640",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}

13
project.qq.json Normal file
View File

@ -0,0 +1,13 @@
{
"miniprogramRoot": "./dist",
"projectname": "TeraWallet",
"description": "泰瑞管理工具",
"appid": "1109699640",
"setting": {
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false
},
"compileType": "miniprogram"
}

11
src/app.scss Normal file
View File

@ -0,0 +1,11 @@
@import "~taro-ui/dist/style/index.scss";
.flex-wrp{
display: flex;
justify-content: center;
align-items: center;
}
.flex-item{
flex-grow: 1;
text-align: center;
}

70
src/app.tsx Normal file
View File

@ -0,0 +1,70 @@
import '@tarojs/async-await'
import Taro, { Component, Config } from '@tarojs/taro'
import { Provider } from '@tarojs/redux';
import dva from './utils/dva';
import models from './models';
import './app.scss'
// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释:
if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
require('nerv-devtools')
}
const app = dva.createApp({
initialState: {},
models
});
const store = app.getStore();
class App extends Component {
/**
* 指定config的类型声明为: Taro.Config
*
* typescript object Key
* navigationBarTextStyle: 'black' string
* navigationBarTextStyle: 'black' | 'white' ,
*/
config: Config = {
pages: [
'pages/index/index',
'pages/my/index'
],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: '泰瑞管家',
navigationBarTextStyle: 'black'
},
tabBar: {
color: "#e6e6e6",
selectedColor: "#2c2c2c",
backgroundColor: "#f8f8f8",
list: [{
pagePath: 'pages/index/index',
text: "首页",
iconPath: "assets/images/home.png",
selectedIconPath: "assets/images/home_select.png"
}, {
pagePath: 'pages/my/index',
text: '我的',
iconPath: "assets/images/my.png",
selectedIconPath: "assets/images/my_select.png"
}]
}
}
// 在 App 类中的 render() 函数没有实际作用
// 请勿修改此函数
render() {
return (
<Provider store={store}>
</Provider>
)
}
}
Taro.render(<App />, document.getElementById('app'))

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
src/assets/images/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
src/assets/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/assets/images/my.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

22
src/index.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="format-detection" content="telephone=no,address=no">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<script>
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>

2
src/models/index.ts Normal file
View File

@ -0,0 +1,2 @@
import Index from '../pages/index/model'
export default [Index];

7
src/models/types.ts Normal file
View File

@ -0,0 +1,7 @@
export interface DefaultModel<T> {
namespace: string,
state: T,
effects?: { [key: string]: Function },
reducers?: { [key: string]: Function },
subscriptions?: { [key: string]: Function },
}

View File

@ -0,0 +1,34 @@
.page {
position: relative;
background-color: #FDFDFD;
view,
div {
box-sizing: border-box;
}
}
.page-index {
padding: 0 0 30px;
.logo {
margin: 24px auto;
font-size: 0;
text-align: center;
.img {
width: 200px;
height: 200px;
}
}
.page-title {
color: #474747;
font-size: 36px;
font-weight: bold;
text-align: center;
}
.base-info {
margin-top: 24px;
}
}

51
src/pages/index/index.tsx Normal file
View File

@ -0,0 +1,51 @@
import { AtCard, AtNoticebar } from 'taro-ui'
import { connect } from '@tarojs/redux';
import { View, Image } from '@tarojs/components'
import Taro, { Component, Config } from '@tarojs/taro'
import './index.scss'
import logoImg from '../../assets/images/logo.png'
import { IndexProps } from './type';
@connect(({ index }): IndexProps => ({ ...index }))
export default class Index extends Component<IndexProps> {
config: Config = {
navigationBarTitleText: '首页',
enablePullDownRefresh: true
}
componentDidMount() {
Taro.startPullDownRefresh();
}
async onPullDownRefresh() {
await this.props.dispatch({
type: 'index/getCurrentInfo'
})
}
render() {
const {
data
} = this.props
return (
<View className='page page-index'>
<AtNoticebar close marquee icon='volume-plus'>
通知: 钱包目前处于测试阶段 BUG !
</AtNoticebar>
<View className='logo'>
<Image src={logoImg} className='img' mode='scaleToFill' />
</View>
<View className='page-title'></View>
<AtCard className='base-info' title='基本信息'>
<View>: {data.version}</View>
<View>: {data.block}</View>
<View>: {data.supply}</View>
<View> : {data.percent}</View>
<View>: {data.lastMiner}</View>
<View> : {data.lastNumber} {data.lastName}</View>
</AtCard>
</View>
)
}
}

33
src/pages/index/model.ts Normal file
View File

@ -0,0 +1,33 @@
import { getInfo } from './service'
import { DefaultModel } from 'src/models/types';
import { IndexProps } from './type';
export default {
namespace: 'index',
state: {
data: {
version: 0,
block: 0,
supply: 0,
percent: '0.00',
lastMiner: 0,
lastName: 'system',
lastNumber: 0,
}
},
effects: {
*getCurrentInfo({ }, { call, put }) {
let info = yield call(getInfo);
yield put({
type: "setState", payload: {
data: info
}
});
}
},
reducers: {
setState(state: IndexProps, { payload }) {
return { ...state, ...payload }
}
}
} as DefaultModel<IndexProps>

View File

@ -0,0 +1,35 @@
import { getCurrentInfo, getBlockInfo, getAccount, getHistoryTransactions } from '../../rpc/tera'
import coinKit from '../../utils/coin-kit'
import Taro from '@tarojs/taro';
const MAX_CENT = 1e9
async function getInfo() {
Taro.showLoading({
title: '加载中...'
})
let info = await getCurrentInfo();
let system = await getAccount(0);
let lastBlock = await getBlockInfo(info.MaxNumBlockDB);
let lastTrs = await getHistoryTransactions(lastBlock.Miner)
for (const tr of lastTrs) {
if (tr.CorrID == 0 && tr.Direct == "+") {
lastTrs = tr;
break;
}
}
let supply = MAX_CENT - coinKit.toNumber(system.Value)
Taro.hideLoading()
Taro.stopPullDownRefresh()
return {
version: info.VersionNum,
block: info.CurBlockNum,
supply: supply,
percent: (supply / MAX_CENT * 100).toFixed(5),
lastMiner: lastBlock.Miner,
lastName: lastBlock.MinerName,
lastNumber: coinKit.toNumber(lastTrs),
}
}
export { getInfo }

13
src/pages/index/type.ts Normal file
View File

@ -0,0 +1,13 @@
export interface IndexProps {
dispatch?: any,
data: IndexData
}
export interface IndexData {
version: number;
block: number;
supply: number;
percent: string;
lastMiner: number;
lastName: string;
lastNumber: number;
}

34
src/pages/my/index.scss Normal file
View File

@ -0,0 +1,34 @@
.user {
width: 725px;
background: #ffffff;
padding: 30px 25px 30px 0;
margin: 15rpx 0 0 0;
border-top: 1px solid #eee;
border-bottom: 1px solid #dcdcdc;
box-shadow: 0 2px 5px #eeeeee;
.userinfo-avatar{
margin-top: 30px;
flex: 1;
display: inline-block;
width: 100px!important;
height: 100px!important;
border-radius: 80px;
}
.user-info{
flex: 5;
text-align: left;
text,div,span{
display: block;
}
.userinfo-nickname{
padding: 8px 0 10px 0;
font-size: 30px;
color: #818A8F;
}
.edit{
font-size: 30px;
color: #bababa;
line-height: 34px;
}
}
}

36
src/pages/my/index.tsx Normal file
View File

@ -0,0 +1,36 @@
import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import defaultImage from '../../assets/images/logo.png'
import './index.scss'
class Index extends Component {
config: Config = {
navigationBarTitleText: '个人中心',
disableScroll: true
}
state = {
nickName: 'MiaoWoo',
avatarUrl: defaultImage
}
render() {
const {
nickName,
avatarUrl
} = this.state;
return (
<View className='more'>
<View className='user flex-wrp'>
<View className='avatar flex-item'>
<Image className='userinfo-avatar' src={avatarUrl}></Image>
</View>
<View className='user-info flex-item'>
<Text className='userinfo-nickname'>{nickName}</Text>
<Text className='edit'></Text>
</View>
</View>
</View>
)
}
}
export default Index

67
src/rpc/index.ts Normal file
View File

@ -0,0 +1,67 @@
import Taro from "@tarojs/taro";
let host = 'https://teraapi.sixi.com'
function printRequest(method: string, path: string, data: any, response: any, cost: number) {
var groupName = 'RPC CALL DEBUG'
console.group(groupName);
console.log('Request Method :', method);
console.log('Request Path :', path);
console.log('Request Data :', data);
console.log('Response :', response);
console.log('Cost Time :', cost);
console.groupEnd();
}
function showError(content) {
Taro.showModal({
title: "网络请求错误",
content,
showCancel: false
})
}
type METHOD = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';
/**
*
* @param {String} method HTTP方法
* @param {String} path
* @param {String} data
*/
async function request<T>(method: METHOD, path: string, data: any): Promise<T> {
var startTime = new Date().getTime();
var response: any;
try {
response = await Taro.request({
url: `${host}${path}`,
data,
method
})
if (response.statusCode && response.statusCode != 200) {
console.log(JSON.stringify(response.data));
throw Error(response.data);
}
response = response.data;
} catch (e) {
showError(e + '');
throw e;
} finally {
printRequest(method, path, data, response, new Date().getTime() - startTime)
return response;
}
}
function quickMethod(mtehod: METHOD) {
return async function <T = any>(path: string, data?: any): Promise<T> {
return await request<T>(mtehod, path, data);
}
}
export default {
request,
get: quickMethod('GET'),
post: quickMethod('POST'),
put: quickMethod('PUT'),
deleted: quickMethod('DELETE'),
}

37
src/rpc/tera.ts Normal file
View File

@ -0,0 +1,37 @@
import rpc from './index'
import { BlockInfo, CurrentInfo, Account } from './types';
async function getCurrentInfo(): Promise<CurrentInfo> {
return rpc.get('/api/v1/GetCurrentInfo')
}
async function getBlockInfo(blockNumber: number): Promise<BlockInfo> {
let result = await rpc.get('/api/v1/GetBlockList', {
StartNum: blockNumber,
CountNum: 1
})
return result.arr[0];
}
async function getAccount(id: number): Promise<Account> {
let result = await rpc.get('/api/v1/GetAccountList', {
StartNum: id
})
return result.arr[0];
}
async function getHistoryTransactions(id: number, count: number = 3, getDes: number = 1) {
let result = await rpc.get('/api/v1/GetHistoryTransactions', {
AccountID: id,
Count: count,
GetDescription: getDes
})
return result.History;
}
export {
getAccount,
getCurrentInfo,
getBlockInfo,
getHistoryTransactions
}

96
src/rpc/types.ts Normal file
View File

@ -0,0 +1,96 @@
export interface PubKey {
type: string;
data: Buffer;
}
export interface Data {
type: string;
data: Buffer;
}
export interface Value {
SumCOIN: number;
SumCENT: number;
OperationID: number;
Smart: number;
Data: Data;
}
export interface Reserve {
type: string;
data: Buffer;
}
export interface Latest {
Type: number;
BlockNum: number;
TrNum: number;
NextPos: number;
Direct: string;
CorrID: number;
SumCOIN: number;
SumCENT: number;
Pos: number;
}
export interface Account {
Currency: number;
PubKey: PubKey;
Name: string;
Value: Value;
BlockNumCreate: number;
Adviser: number;
Reserve: Reserve;
Num: number;
WN: string;
PubKeyStr: string;
Latest: Latest;
}
export interface PRICEDAO {
NewAccount: number;
NewSmart: number;
NewTokenSmart: number;
}
export interface CurrentInfo {
result: number;
VersionNum: number;
NETWORK: string;
MaxNumBlockDB: number;
CurBlockNum: number;
MaxAccID: number;
MaxDappsID: number;
CurTime: number;
DELTA_CURRENT_TIME: number;
MIN_POWER_POW_TR: number;
FIRST_TIME_BLOCK: number;
CONSENSUS_PERIOD_TIME: number;
NEW_SIGN_TIME: number;
PRICE_DAO: PRICEDAO;
}
export interface BlockInfo {
TreeHash: Buffer;
AddrHash: Buffer;
PrevHash: Buffer;
SumHash: Buffer;
SumPow: number;
Reserv500: number;
TrDataPos: number;
TrDataLen: number;
TrCount: number;
Info: string;
BlockNum: number;
SeqHash: Buffer;
Hash: Buffer;
PowHash: Buffer;
Power: number;
bSave: boolean;
Prepared: boolean;
Num: number;
Miner: number;
MinerName: string;
Hash1: Buffer;
Hash2: Buffer;
}

9
src/utils/coin-kit.ts Normal file
View File

@ -0,0 +1,9 @@
const MAX_CENT = 1e9
function toNumber(Value: { SumCOIN: number; SumCENT: number; }) {
return (Value.SumCOIN * MAX_CENT + Value.SumCENT) / MAX_CENT;
}
export default {
MAX_CENT,
toNumber
}

35
src/utils/dva.ts Normal file
View File

@ -0,0 +1,35 @@
/*
* @Author: Tuisku
* @Date: 2018-12-03 10:27:38
* @LastEditors: Tuisku
* @LastEditTime: 2018-12-14 09:37:03
* @Description: dva帮助类
*/
import { create } from 'dva-core';
import createLoading from 'dva-loading';
let app;
let registered: boolean;
function createApp(opt) {
app = create(opt);
app.use(createLoading({}));
if (!registered) opt.models.forEach(model => app.model(model))
registered = true
app.start();
app.getStore = () => app._store;
app.use({
onError(err) {
console.log(err)
},
})
app.dispatch = app._store.dispatch;
return app;
}
export default {
createApp,
getDispatch() {
return app.dispatch;
}
}

29
src/utils/time-kit.ts Normal file
View File

@ -0,0 +1,29 @@
import i18n from '@/i18n/index.js'
function formatShortTime(time, count = 4) {
const t = Math.floor(time / 86400);
const h = Math.floor((time / 3600) % 24);
const m = Math.floor((time / 60) % 60);
const s = Math.floor(time % 60);
var timeStr = '';
if (t > 0) {
timeStr = timeStr + t + '天';
count--;
}
if (h > 0 && count > 0) {
timeStr = timeStr + h + '时';
count--;
}
if (m > 0 && count > 0) {
timeStr = timeStr + m + '分';
count--;
}
if (count > 0) {
timeStr = timeStr + s + '秒';
}
return timeStr;
}
module.exports = {
formatShortTime
}

32
tsconfig.json Normal file
View File

@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"removeComments": false,
"preserveConstEnums": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"outDir": "lib",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"sourceMap": true,
"baseUrl": ".",
"rootDir": ".",
"jsx": "preserve",
"jsxFactory": "Taro.createElement",
"allowJs": true,
"resolveJsonModule": true,
"typeRoots": [
"node_modules/@types",
"global.d.ts"
]
},
"exclude": [
"node_modules",
"dist"
],
"compileOnSave": false
}

11371
yarn.lock Normal file

File diff suppressed because it is too large Load Diff