Skip to content

API 参考

⚠️ 公共 API 仍在开发中,可能会有所变更。

IPC 接口

WSL Dashboard 暴露了一个本地 IPC 套接字,供脚本和第三方工具集成使用。

连接

连接到以下 Unix 域套接字:

\\.\pipe\wsl-dashboard

命令

list_distributions

返回所有已安装的 WSL 发行版列表。

请求:

json
{ "cmd": "list_distributions" }

响应:

json
{
  "distributions": [
    { "name": "Ubuntu-22.04", "state": "Running", "version": 2 },
    { "name": "Debian", "state": "Stopped", "version": 2 }
  ]
}

start_distribution

启动一个已停止的发行版。

请求:

json
{ "cmd": "start_distribution", "name": "Ubuntu-22.04" }

响应:

json
{ "success": true }

stop_distribution

停止一个正在运行的发行版。

请求:

json
{ "cmd": "stop_distribution", "name": "Ubuntu-22.04" }

响应:

json
{ "success": true }

Licensed under GPL-3.0.