Improve: use scrolling css & history api

This commit is contained in:
Dreamacro 2019-06-12 22:10:51 +08:00
parent 293e484f1d
commit 53fb2a0f30
5 changed files with 22 additions and 7 deletions

View File

@ -19,6 +19,7 @@ $mobileBigWidth: 480px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
z-index: 11;
.modal { .modal {
margin-top: -50px; margin-top: -50px;
@ -82,6 +83,11 @@ $mobileBigWidth: 480px;
@media (max-width: 768px) { @media (max-width: 768px) {
.modal-mask { .modal-mask {
.modal {
margin-top: 0;
padding: 18px 20px;
}
.modal-small { .modal-small {
width: $mobileWidth; width: $mobileWidth;
} }

View File

@ -19,7 +19,7 @@ interface ProxyState {
} }
export class Proxy extends React.Component<ProxyProps , ProxyState> { export class Proxy extends React.Component<ProxyProps , ProxyState> {
constructor (props) { constructor (props: ProxyProps) {
super(props) super(props)
const { config } = props const { config } = props
@ -31,9 +31,10 @@ export class Proxy extends React.Component<ProxyProps , ProxyState> {
setLocalStorageItem(name, color) setLocalStorageItem(name, color)
} }
const delay = config.history.length ? config.history.slice(-1)[0].delay : 0
this.state = { this.state = {
delay: -1, delay,
hasError: false, hasError: delay === 0,
color color
} }
} }
@ -85,7 +86,7 @@ export class Proxy extends React.Component<ProxyProps , ProxyState> {
<div className={classnames('proxy-item', { 'proxy-error': hasError }, className)}> <div className={classnames('proxy-item', { 'proxy-error': hasError }, className)}>
<span className="proxy-type" style={{ backgroundColor }}>{config.type}</span> <span className="proxy-type" style={{ backgroundColor }}>{config.type}</span>
<p className="proxy-name">{config.name}</p> <p className="proxy-name">{config.name}</p>
<p className="proxy-delay">{delay === -1 ? '-' : `${delay}ms`}</p> <p className="proxy-delay">{delay === 0 ? '-' : `${delay}ms`}</p>
{/* <Icon className="proxy-editor" type="setting" onClick={onEdit} /> */} {/* <Icon className="proxy-editor" type="setting" onClick={onEdit} /> */}
</div> </div>
) )

View File

@ -32,9 +32,15 @@ export interface Proxies {
} }
} }
interface History {
time: string
delay: number
}
export interface Proxy { export interface Proxy {
name: string name: string
type: 'Direct' | 'Reject' | 'Shadowsocks' | 'Vmess' | 'Socks' | 'Http' type: 'Direct' | 'Reject' | 'Shadowsocks' | 'Vmess' | 'Socks' | 'Http'
history: History[]
} }
export interface Group { export interface Group {
@ -42,6 +48,7 @@ export interface Group {
type: 'Selector' | 'URLTest' | 'Fallback' type: 'Selector' | 'URLTest' | 'Fallback'
now: string now: string
all: string[] all: string[]
history: History[]
} }
export async function getConfig () { export async function getConfig () {
@ -130,7 +137,7 @@ export async function getExternalControllerConfig () {
} }
const hostname = getLocalStorageItem('externalControllerAddr', '127.0.0.1') const hostname = getLocalStorageItem('externalControllerAddr', '127.0.0.1')
const port = getLocalStorageItem('externalControllerPort', '8080') const port = getLocalStorageItem('externalControllerPort', '9090')
const secret = getLocalStorageItem('secret', '') const secret = getLocalStorageItem('secret', '')
if (!hostname || !port) { if (!hostname || !port) {

View File

@ -25,7 +25,7 @@ export class ConfigStore {
@observable @observable
apiInfo: Models.APIInfo = { apiInfo: Models.APIInfo = {
hostname: '127.0.0.1', hostname: '127.0.0.1',
port: '8080', port: '9090',
secret: '' secret: ''
} }
@ -153,7 +153,7 @@ export class ConfigStore {
allowLan: config['allow-lan'], allowLan: config['allow-lan'],
mode: config.mode, mode: config.mode,
externalControllerAddr: getLocalStorageItem('externalControllerAddr', '127.0.0.1'), externalControllerAddr: getLocalStorageItem('externalControllerAddr', '127.0.0.1'),
externalControllerPort: getLocalStorageItem('externalControllerPort', '8080'), externalControllerPort: getLocalStorageItem('externalControllerPort', '9090'),
secret: getLocalStorageItem('secret', '') secret: getLocalStorageItem('secret', '')
} }
} }

View File

@ -71,6 +71,7 @@ body {
width: 100%; width: 100%;
padding: 0 10px; padding: 0 10px;
height: calc(100vh - 60px); height: calc(100vh - 60px);
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;