mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 22:11:56 +08:00
Update: <Logs> i18n
This commit is contained in:
parent
f9f3e83e31
commit
5820563c1d
@ -1,19 +1,37 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import * as dayjs from 'dayjs'
|
import * as dayjs from 'dayjs'
|
||||||
|
import { translate } from 'react-i18next'
|
||||||
|
import { I18nProps } from '@i18n'
|
||||||
import { Card, Header } from '@components'
|
import { Card, Header } from '@components'
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
|
|
||||||
|
interface Log {
|
||||||
|
type: string
|
||||||
|
payload: string,
|
||||||
|
time: Date
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LogsProps extends I18nProps {}
|
||||||
|
|
||||||
interface LogsState {
|
interface LogsState {
|
||||||
listHeight: number
|
listHeight: number
|
||||||
|
logs: Log[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Logs extends React.Component<{}, LogsState> {
|
class Logs extends React.Component<LogsProps, LogsState> {
|
||||||
state: LogsState = {
|
state: LogsState = {
|
||||||
listHeight: 0
|
listHeight: 0,
|
||||||
|
logs: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private listRef = React.createRef<HTMLUListElement>()
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.setListHeight()
|
this.setListHeight()
|
||||||
|
const logs: Log[] = Array.from(
|
||||||
|
{ length: 32 },
|
||||||
|
() => ({ type: 'info', payload: 'google.com match DomainSuffix using Proxy', time: new Date() })
|
||||||
|
)
|
||||||
|
this.setState({ logs }, () => this.scrollToBottom())
|
||||||
}
|
}
|
||||||
|
|
||||||
setListHeight = () => {
|
setListHeight = () => {
|
||||||
@ -22,45 +40,21 @@ export default class Logs extends React.Component<{}, LogsState> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
scrollToBottom = () => {
|
||||||
const logs = [
|
const ul = this.listRef.current
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
ul.scrollTop = ul.scrollHeight
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
}
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() },
|
|
||||||
{ type: 'info', payload: 'google.com match DomainSuffix using Proxy', timestamp: +new Date() }
|
|
||||||
]
|
|
||||||
|
|
||||||
|
render () {
|
||||||
const listHeight = { height: this.state.listHeight }
|
const listHeight = { height: this.state.listHeight }
|
||||||
|
const { t } = this.props
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<Header title="日志" />
|
<Header title={ t('title') } />
|
||||||
<Card className="logs-card">
|
<Card className="logs-card">
|
||||||
<ul className="logs-panel" style={listHeight}>
|
<ul className="logs-panel" style={listHeight} ref={this.listRef}>
|
||||||
{
|
{
|
||||||
logs.map(
|
this.state.logs.map(
|
||||||
log => (
|
log => (
|
||||||
<li>
|
<li>
|
||||||
<span className="logs-panel-time">{ dayjs().format('YYYY-MM-DD HH:mm:ss') }</span>
|
<span className="logs-panel-time">{ dayjs().format('YYYY-MM-DD HH:mm:ss') }</span>
|
||||||
@ -75,3 +69,5 @@ export default class Logs extends React.Component<{}, LogsState> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default translate(['Logs'])(Logs)
|
||||||
|
@ -27,5 +27,8 @@ export default {
|
|||||||
},
|
},
|
||||||
versionString: 'Current ClashX is the latest version:{{version}}',
|
versionString: 'Current ClashX is the latest version:{{version}}',
|
||||||
checkUpdate: 'Check Update'
|
checkUpdate: 'Check Update'
|
||||||
|
},
|
||||||
|
Logs: {
|
||||||
|
title: 'Logs'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ const options = {
|
|||||||
|
|
||||||
ns: [
|
ns: [
|
||||||
'SideBar',
|
'SideBar',
|
||||||
'Settings'
|
'Settings',
|
||||||
|
'Logs'
|
||||||
],
|
],
|
||||||
|
|
||||||
resources: {
|
resources: {
|
||||||
|
@ -27,5 +27,8 @@ export default {
|
|||||||
},
|
},
|
||||||
versionString: '当前 ClashX 已是最新版本:{{version}}',
|
versionString: '当前 ClashX 已是最新版本:{{version}}',
|
||||||
checkUpdate: '检查更新'
|
checkUpdate: '检查更新'
|
||||||
|
},
|
||||||
|
Logs: {
|
||||||
|
title: '日志'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user