mirror of
https://github.com/fatedier/frp.git
synced 2026-07-16 09:19:17 +08:00
web/frps: use API v2 for client and proxy details (#5386)
This commit is contained in:
@@ -32,7 +32,7 @@ export const getProxiesV2 = async (params: ProxyListV2Params = {}) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const toLegacyProxyStats = (proxy: ProxyV2Info): ProxyStatsInfo => ({
|
export const toLegacyProxyStats = (proxy: ProxyV2Info): ProxyStatsInfo => ({
|
||||||
name: proxy.name,
|
name: proxy.name,
|
||||||
type: proxy.type,
|
type: proxy.type,
|
||||||
conf: proxy.spec,
|
conf: proxy.spec,
|
||||||
@@ -43,13 +43,20 @@ 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.phase,
|
status: proxy.status.state || proxy.status.phase || '',
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getProxy = (type: string, name: string) => {
|
export const getProxy = (type: string, name: string) => {
|
||||||
return http.get<ProxyStatsInfo>(`../api/proxy/${type}/${name}`)
|
return http.get<ProxyStatsInfo>(`../api/proxy/${type}/${name}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getProxyByNameV2 = async (name: string) => {
|
||||||
|
const proxy = await http.getV2<ProxyV2Info>(
|
||||||
|
`../api/v2/proxies/${encodeURIComponent(name)}`,
|
||||||
|
)
|
||||||
|
return toLegacyProxyStats(proxy)
|
||||||
|
}
|
||||||
|
|
||||||
export const getProxyByName = (name: string) => {
|
export const getProxyByName = (name: string) => {
|
||||||
return http.get<ProxyStatsInfo>(`../api/proxies/${name}`)
|
return http.get<ProxyStatsInfo>(`../api/proxies/${name}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ export interface ProxyV2Info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ProxyV2Status {
|
export interface ProxyV2Status {
|
||||||
phase: string
|
state?: string
|
||||||
|
phase?: string
|
||||||
todayTrafficIn: number
|
todayTrafficIn: number
|
||||||
todayTrafficOut: number
|
todayTrafficOut: number
|
||||||
curConns: number
|
curConns: number
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ import {
|
|||||||
Tickets,
|
Tickets,
|
||||||
Location,
|
Location,
|
||||||
} from '@element-plus/icons-vue'
|
} from '@element-plus/icons-vue'
|
||||||
import { getProxyByName } from '../api/proxy'
|
import { getProxyByNameV2 } from '../api/proxy'
|
||||||
import { getServerInfo } from '../api/server'
|
import { getServerInfo } from '../api/server'
|
||||||
import {
|
import {
|
||||||
BaseProxy,
|
BaseProxy,
|
||||||
@@ -365,9 +365,9 @@ const fetchProxy = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await getProxyByName(name)
|
const data = await getProxyByNameV2(name)
|
||||||
const info = await fetchServerInfo()
|
const info = await fetchServerInfo()
|
||||||
const type = data.conf?.type || ''
|
const type = data.type || data.conf?.type || ''
|
||||||
|
|
||||||
if (type === 'tcp') {
|
if (type === 'tcp') {
|
||||||
proxy.value = new TCPProxy(data)
|
proxy.value = new TCPProxy(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user