mirror of
https://github.com/fatedier/frp.git
synced 2026-07-16 09:19:17 +08:00
refactor: clean up frps v2 frontend models (#5399)
This commit is contained in:
@@ -49,7 +49,7 @@ export const toLegacyProxyStats = (proxy: ProxyV2Info): ProxyStatsInfo => ({
|
|||||||
curConns: proxy.status.curConns,
|
curConns: proxy.status.curConns,
|
||||||
lastStartTime: proxy.status.lastStartTime,
|
lastStartTime: proxy.status.lastStartTime,
|
||||||
lastCloseTime: proxy.status.lastCloseTime,
|
lastCloseTime: proxy.status.lastCloseTime,
|
||||||
status: proxy.status.state || proxy.status.phase || '',
|
status: proxy.status.phase,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getProxy = (type: string, name: string) => {
|
export const getProxy = (type: string, name: string) => {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export interface ClientInfoData {
|
|||||||
wireProtocol?: string
|
wireProtocol?: string
|
||||||
hostname: string
|
hostname: string
|
||||||
clientIP?: string
|
clientIP?: string
|
||||||
metas?: Record<string, string>
|
|
||||||
firstConnectedAt: number
|
firstConnectedAt: number
|
||||||
lastConnectedAt: number
|
lastConnectedAt: number
|
||||||
disconnectedAt?: number
|
disconnectedAt?: number
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ export interface ProxyV2Info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ProxyV2Status {
|
export interface ProxyV2Status {
|
||||||
state?: string
|
phase: 'online' | 'offline'
|
||||||
phase?: string
|
|
||||||
todayTrafficIn: number
|
todayTrafficIn: number
|
||||||
todayTrafficOut: number
|
todayTrafficOut: number
|
||||||
curConns: number
|
curConns: number
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export class Client {
|
|||||||
wireProtocol: string
|
wireProtocol: string
|
||||||
hostname: string
|
hostname: string
|
||||||
ip: string
|
ip: string
|
||||||
metas: Map<string, string>
|
|
||||||
firstConnectedAt: Date
|
firstConnectedAt: Date
|
||||||
lastConnectedAt: Date
|
lastConnectedAt: Date
|
||||||
disconnectedAt?: Date
|
disconnectedAt?: Date
|
||||||
@@ -26,12 +25,6 @@ export class Client {
|
|||||||
this.wireProtocol = data.wireProtocol || ''
|
this.wireProtocol = data.wireProtocol || ''
|
||||||
this.hostname = data.hostname
|
this.hostname = data.hostname
|
||||||
this.ip = data.clientIP || ''
|
this.ip = data.clientIP || ''
|
||||||
this.metas = new Map<string, string>()
|
|
||||||
if (data.metas) {
|
|
||||||
for (const [key, value] of Object.entries(data.metas)) {
|
|
||||||
this.metas.set(key, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.firstConnectedAt = new Date(data.firstConnectedAt * 1000)
|
this.firstConnectedAt = new Date(data.firstConnectedAt * 1000)
|
||||||
this.lastConnectedAt = new Date(data.lastConnectedAt * 1000)
|
this.lastConnectedAt = new Date(data.lastConnectedAt * 1000)
|
||||||
if (data.disconnectedAt && data.disconnectedAt > 0) {
|
if (data.disconnectedAt && data.disconnectedAt > 0) {
|
||||||
@@ -52,10 +45,6 @@ export class Client {
|
|||||||
return this.runID
|
return this.runID
|
||||||
}
|
}
|
||||||
|
|
||||||
get shortRunId(): string {
|
|
||||||
return this.runID.substring(0, 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
get wireProtocolLabel(): string {
|
get wireProtocolLabel(): string {
|
||||||
if (!this.wireProtocol) return ''
|
if (!this.wireProtocol) return ''
|
||||||
return `Protocol ${this.wireProtocol}`
|
return `Protocol ${this.wireProtocol}`
|
||||||
@@ -73,28 +62,4 @@ export class Client {
|
|||||||
if (!this.disconnectedAt) return ''
|
if (!this.disconnectedAt) return ''
|
||||||
return formatDistanceToNow(this.disconnectedAt)
|
return formatDistanceToNow(this.disconnectedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
get statusColor(): string {
|
|
||||||
return this.online ? 'success' : 'danger'
|
|
||||||
}
|
|
||||||
|
|
||||||
get metasArray(): Array<{ key: string; value: string }> {
|
|
||||||
const arr: Array<{ key: string; value: string }> = []
|
|
||||||
this.metas.forEach((value, key) => {
|
|
||||||
arr.push({ key, value })
|
|
||||||
})
|
|
||||||
return arr
|
|
||||||
}
|
|
||||||
|
|
||||||
matchesFilter(searchText: string): boolean {
|
|
||||||
const search = searchText.toLowerCase()
|
|
||||||
return (
|
|
||||||
this.key.toLowerCase().includes(search) ||
|
|
||||||
this.user.toLowerCase().includes(search) ||
|
|
||||||
this.clientID.toLowerCase().includes(search) ||
|
|
||||||
this.runID.toLowerCase().includes(search) ||
|
|
||||||
this.wireProtocol.toLowerCase().includes(search) ||
|
|
||||||
this.hostname.toLowerCase().includes(search)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user