代理
代理模块提供设置和获取(立即和被动)HTTP 代理配置的函数。请注意,无法从 API 更改代理设置的状态(启用或禁用)。
示例
import * as api from '@podman-desktop/api';
export async function activate(extensionContext: api.ExtensionContext): Promise<void> {
const handleProxyConfiguration = (e: boolean | undefined, s: api.ProxySettings | undefined) => {
console.log(e, s);
}
let enabled: boolean | undefined = undefined;
let settings: api.ProxySettings | undefined = undefined;
// Configuration changes
extensionContext.subscriptions.push(
api.proxy.onDidStateChange((e: boolean) => {
enabled = e;
handleProxyConfiguration(enabled, settings);
}),
api.proxy.onDidUpdateProxy((s: api.ProxySettings) => {
settings = s;
handleProxyConfiguration(enabled, settings);
}),
);
// Initial configuration
enabled = api.proxy.isEnabled();
settings = api.proxy.getProxySettings();
handleProxyConfiguration(enabled, settings);
}