Refactor VPN proxy components and update related behavior
This commit is contained in:
@@ -96,10 +96,50 @@ export const api = {
|
||||
refresh: () => request('/api/subscription/refresh', { method: 'POST' }),
|
||||
forget: () => request('/api/subscription', { method: 'DELETE' }),
|
||||
},
|
||||
apply: (serverId: string) => request('/api/apply', {
|
||||
profiles: {
|
||||
add: (label: string, url: string, expectedRevision: number) => request('/api/profiles', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ label, url, expectedRevision }),
|
||||
}),
|
||||
rename: (profileId: string, label: string, expectedRevision: number) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}`,
|
||||
{
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ label, expectedRevision }),
|
||||
},
|
||||
),
|
||||
selectServer: (profileId: string, serverId: string, expectedRevision: number) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}/server`,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ serverId, expectedRevision }),
|
||||
},
|
||||
),
|
||||
activate: (profileId: string, expectedRevision: number) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}/activate`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ expectedRevision }),
|
||||
},
|
||||
),
|
||||
refresh: (profileId: string, expectedRevision: number) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}/refresh`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ expectedRevision }),
|
||||
},
|
||||
),
|
||||
forget: (profileId: string, mode: 'delete' | 'stop-and-delete', expectedRevision: number) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify({ mode, expectedRevision }),
|
||||
},
|
||||
),
|
||||
},
|
||||
apply: (profileId: string, serverId: string, expectedRevision: number) => request('/api/apply', {
|
||||
method: 'POST',
|
||||
// selectedTag keeps this client compatible with pre-ID Harbor backends.
|
||||
body: JSON.stringify({ serverId, selectedTag: serverId }),
|
||||
body: JSON.stringify({ profileId, serverId, expectedRevision }),
|
||||
}),
|
||||
gatewayAuto: {
|
||||
setEnabled: (enabled: boolean) => request('/api/gateway-auto', {
|
||||
@@ -145,10 +185,13 @@ export const api = {
|
||||
restart: () => request('/api/singbox/restart', { method: 'POST' }),
|
||||
},
|
||||
servers: {
|
||||
ping: (serverIds: string[]) => request('/api/servers/ping-all', {
|
||||
ping: (profileId: string, serverIds: string[]) => request(
|
||||
`/api/profiles/${encodeURIComponent(profileId)}/servers/ping`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ serverIds }),
|
||||
}),
|
||||
},
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -177,6 +220,7 @@ export function parseHarborState(value: unknown): HarborClientState {
|
||||
revision: snapshot.revision,
|
||||
generatedAt: snapshot.generatedAt,
|
||||
mode: snapshot.mode,
|
||||
profiles: snapshot.profiles,
|
||||
subscription: snapshot.subscription,
|
||||
selection: snapshot.selection,
|
||||
connection: snapshot.connection,
|
||||
|
||||
Reference in New Issue
Block a user