Skip to content

Commit

Permalink
feat: 站点运行时间暴露至配置文件内
Browse files Browse the repository at this point in the history
  • Loading branch information
shi-lai-mu committed Oct 7, 2019
1 parent 595062a commit c98d5b1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
5 changes: 4 additions & 1 deletion config/default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const config: DefaultConfig = {
host: 'http://localhost',
port: 3000,
apiHost: 'http://localhost:7001',
}
},
web: {
runDate: 1535150280000,
},
}

export default {
Expand Down
9 changes: 9 additions & 0 deletions interface/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ export interface DefaultConfig {
*/
apiHost: string;
};
/**
* 网站相关
*/
web: {
/**
* 运行时间
*/
runDate: number;
}
}
16 changes: 9 additions & 7 deletions layouts/default/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'
import Link from 'next/link'
import { unForm } from '../../utils/date'
import config from '../../config/default.config'

export default class LayoutsDefauleFooter extends React.Component {

state = {
loadTime: 0,
currentTime: Date.now(),
currentTime: '-年-月-日-时-分-秒',
}

componentDidMount() {
Expand All @@ -17,9 +18,10 @@ export default class LayoutsDefauleFooter extends React.Component {
})
})
// 站点运行时间计算
const webRunDate: number = config.web.runDate
setInterval(() => {
this.setState({
currentTime: unForm(1535150280000),
currentTime: unForm(webRunDate),
})
}, 1000)
}
Expand All @@ -31,18 +33,18 @@ export default class LayoutsDefauleFooter extends React.Component {
<div className="default-layouts-footer">
<div className="web-info">
<div>© CopyRight 2018-2019, <a href="//slmblog.com">SLMBLOG.COM</a>, Inc.All Rights Reserved.</div>
<div className="copyright-right">
<div className="web-param">
<span>渲染{ loadTime }ms</span>
<span>站点已运行 { currentTime }</span>
</div>
<div>
<Link href={{ pathname: "/other/terms" }}>
<a data-tag="page-toggle">条款和免责</a>
</Link>
<Link href={{ pathname: "/other/about"}}>
<a data-tag="page-toggle">关于本站</a>
</Link>
</div>
<div className="web-param">
<span>渲染{ loadTime }ms</span>
<span>站点已运行 { currentTime }</span>
</div>
</div>
<div className="beian">
<span className="beian-a">
Expand Down

0 comments on commit c98d5b1

Please sign in to comment.