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