节点在线、应用在线、配置在线使用令牌查询
大石头 authored at 2021-12-16 19:49:30
15.39 KiB
Stardust
# 代理安装(/Agent) > 块:节点代理 > MVC:`Stardust.Web/Controllers/AgentController.cs` > WebApi:`Stardust.WebApi/AgentController.cs`(2026-11-04 补齐新增) > 盘点:2026-11-02 > **WebApi 对齐状态:✅ 已完成(2026-11-04)**——MVC 功能已全部在 WebApi 实现或已一致(缺口补齐/行为对齐/有意不补三类逐项标注);本次处理明细见 §7「2026-11-04 WebApi 补齐记录」;整体验证=dotnet build Release 0 错误 + 6681 冒烟 + McpApiTests 40/40;状态总表=Doc/MVC功能真源/WebApi对齐状态总表.md ## 1. 用户用它做什么 菜单特性:控制器仅有 `[DisplayName("代理安装")]`(`AgentController.cs:11`),**无** `[Menu(...)]` 特性,**未在源码确认**是否出现在 Cube 侧栏菜单。 页面 `[AllowAnonymous]`(`AgentController.cs:12`),匿名可访问。用户在此查看 **StarAgent、星尘平台安装包、.NET 运行时脚本** 的下载地址与 Linux 一键安装命令;浏览器还会探测本机 `http://localhost:5500` 上的 StarAgent,展示版本与连接的服务端,并可将 StarAgent 的服务端地址设为当前站点 URL。 ## 2. 入口与跳转 ### 页面 URL | 用途 | URL 模板 | 依据 | |------|----------|------| | 代理安装 HTML 页 | GET `/Agent` | `AgentController.cs:23-24` | | 下载目录 JSON | GET `/Agent`,请求头 `Accept` 含 `application/json` | `AgentController.cs:27-29` | | 下载目录 JSON | GET `/Agent?format=json` | `AgentController.cs:32-34` | ### 谁链进来 | 来源 | 说明 | 文件:行号 | |------|------|-----------| | Cube `[Menu]` | **无**:`AgentController` 未标注 `[Menu]` | `AgentController.cs:10-13` | | 应用导航 `_App_Nav.cshtml` | **未**出现 `/Agent` 或「代理安装」 | 通读 `Stardust.Web/Views/Shared/_App_Nav.cshtml`,无本页 URL | | 节点导航 `_Node_Nav.cshtml` | **未**链到本页;StarAgent 产品时链到应用在线、应用发布,非本控制器 | `_Node_Nav.cshtml:18-30` | | 项目导航 `_Project_Nav.cshtml` | **未**链到本页 | 通读 `Stardust.Web/Views/Shared/_Project_Nav.cshtml`,无 `/Agent` | | 其它 `Stardust.Web` 视图/控制器 | **未**发现指向 `/Agent` 的链接(与 `AgentDeploy` 无关) | `Stardust.Web` 内 grep `/Agent` 结果 | 用户通常 **直接访问** `/Agent`;**未在源码确认**其它入口文案。 ### 本页链出去 | 出口 | 说明 | 文件:行号 | |------|------|-----------| | StarAgent / 平台 ZIP 下载 | 各表格「下载」链至 `{AgentDownloadBaseUrl 或默认}` 下具体文件名 | `Index.cshtml:52-52`、`58-58`、`64-64`、`70-70`、`76-76`、`82-82`、`104-104`、`110-110`、`116-116`、`122-122`、`128-128`、`178-178`、`184-184`、`188-188`;基址 `AgentController.cs:46-50` | | Linux 安装脚本 | 页面展示 `curl -sSL {dlBase}star.sh \| bash` 与 `star8.sh`,用户在本机终端执行,**不**经 MVC 跳转 | `Index.cshtml:148-148`、`153-153` | | .NET 运行时脚本 | 展示 `curl -sSL {dnBase}net.sh` / `net10.sh` / `net9.sh` / `net8.sh` / `net6.sh \| bash` | `Index.cshtml:214-214`、`219-219`、`224-224`、`229-229`、`234-234` | | 本机 StarAgent API | 前端 `fetch('http://localhost:5500/info')`、`fetch('http://localhost:5500/setserver?server=...')` | `Index.cshtml:254-257`、`297-300` | ## 3. 功能清单 | ID | 用户动作 | 入口 | HTTP 与路径 | 参数 | 成功时发生什么 | 失败或禁用条件 | |----|----------|------|-------------|------|----------------|----------------| | F01 | 打开代理安装页 | 直接访问 `/Agent` | GET `/Agent` | 无;且 `Accept` **不**含 `application/json`,且 `format` **不是** `json` | `ViewBag.Title` =「星尘代理安装」;`ViewBag.AgentBase`、`ViewBag.DotnetBase` 由配置计算;`PageSetting.EnableNavbar = false`;渲染 `Views/Agent/Index.cshtml` | 未在源码确认鉴权失败表现(已 `[AllowAnonymous]`) | | F02 | 以 JSON 拉取下载目录(Accept) | API 或前端 | GET `/Agent` | 请求头 `Accept` 含 `application/json` | 返回 `Json(GetAgentData())`,结构见 F03 | `AgentController.cs:27-29` | | F03 | 以 JSON 拉取下载目录(format) | API 或前端 | GET `/Agent` | 查询 `format=json`(大小写不敏感) | JSON 对象:`server`(当前站点根 URL)、`agent.zip[]`、`agent.targz[]`、`agent.scripts[]`、`packages[]`、`dotnet[]`,每项含 `name`、`url` 及框架/系统/说明字段 | `AgentController.cs:32-34`、`56-104` | | F04 | 查看页标题 | 页面顶部 | — | — | 标题「星尘代理安装」 | `Index.cshtml:16-16`;控制器 `ViewBag.Title` `AgentController.cs:36-36` | | F05 | 页面加载后探测本机 StarAgent | 自动 | — | — | 调用 `detectAgent()` | `Index.cshtml:312-313` | | F06 | 本机 Agent 在线时查看状态 | `#agentStatus` 区域 | GET `http://localhost:5500/info`(浏览器 CORS) | 无 | 显示 `#agentStatus`,隐藏 `#agentNotFound`;表格展示 `Name`、`Title`、`FileVersion` 或 `Version`、`Compile`、`OS`、`MachineName`、`LocalIP`、`Server`(有则显示) | 请求失败进入 F07;字段缺失则不渲染对应行 `Index.cshtml:264-271` | | F07 | 本机未检测到 Agent | `#agentNotFound` | 同上探测失败 | — | 隐藏 `#agentStatus`,显示警告「未检测到本机 StarAgent」及说明文案 | `Index.cshtml:289-291`、`24-27` | | F08 | 关闭状态提示 | 状态区右上角 × | — | — | Bootstrap `data-dismiss="alert"` 关闭 `#agentStatus` | `Index.cshtml:19-20` | | F09 | 将 StarAgent 服务端设为当前站点 | 按钮「设置为当前服务器」 | GET `http://localhost:5500/setserver?server={encodeURIComponent(serverUrl)}` | `serverUrl` = 页面 `data-server-url`(当前站点 `Scheme://Host`) | `alert('服务端地址已设置为: ' + serverUrl)` 后重新 `detectAgent()` | CORS/网络失败 `alert('设置失败: ' + err.message)` `Index.cshtml:307-308`;按钮在 `Server` 为空时出现 `Index.cshtml:275-277` | | F10 | 将 StarAgent 切换到当前站点 | 按钮「切换到当前服务器」 | 同 F09 | 同 F09 | 同 F09 | 当 `data.Server` 存在且不等于 `serverUrl` 时显示 `Index.cshtml:282-284` | | F11 | 下载 `staragent10.zip` | Windows ZIP 表「下载」 | GET 外链 | URL `{dlBase}staragent10.zip` | 浏览器下载 | `dlBase` 空时视图默认 `https://x.newlifex.com/star/` `Index.cshtml:9-10` | | F12 | 下载 `staragent90.zip` | 同上 | GET 外链 | `{dlBase}staragent90.zip` | 浏览器下载 | `Index.cshtml:58-58` | | F13 | 下载 `staragent80.zip` | 同上 | GET 外链 | `{dlBase}staragent80.zip` | 浏览器下载 | `Index.cshtml:64-64` | | F14 | 下载 `staragent60.zip` | 同上 | GET 外链 | `{dlBase}staragent60.zip` | 浏览器下载 | `Index.cshtml:70-70` | | F15 | 下载 `staragent45.zip` | 同上 | GET 外链 | `{dlBase}staragent45.zip` | 浏览器下载 | `Index.cshtml:76-76` | | F16 | 下载 `staragent31.zip` | 同上 | GET 外链 | `{dlBase}staragent31.zip` | 浏览器下载 | `Index.cshtml:82-82` | | F17 | 下载 `staragent10.tar.gz` | Linux tar.gz 表「下载」 | GET 外链 | `{dlBase}staragent10.tar.gz` | 浏览器下载 | `Index.cshtml:104-104` | | F18 | 下载 `staragent90.tar.gz` | 同上 | GET 外链 | `{dlBase}staragent90.tar.gz` | 浏览器下载 | `Index.cshtml:110-110` | | F19 | 下载 `staragent80.tar.gz` | 同上 | GET 外链 | `{dlBase}staragent80.tar.gz` | 浏览器下载 | `Index.cshtml:116-116` | | F20 | 下载 `staragent60.tar.gz` | 同上 | GET 外链 | `{dlBase}staragent60.tar.gz` | 浏览器下载 | `Index.cshtml:122-122` | | F21 | 下载 `staragent31.tar.gz` | 同上 | GET 外链 | `{dlBase}staragent31.tar.gz` | 浏览器下载 | `Index.cshtml:128-128` | | F22 | 查看 Linux 一键安装 `star.sh` 命令 | Linux 一键安装脚本表 | — | — | 展示 `curl -sSL {dlBase}star.sh \| bash` | `Index.cshtml:146-148` | | F23 | 查看 Linux 一键安装 `star8.sh` 命令 | 同上 | — | — | 展示 `curl -sSL {dlBase}star8.sh \| bash` | `Index.cshtml:151-153` | | F24 | 下载 `star.zip` | 星尘平台安装包表「下载」 | GET 外链 | `{dlBase}star.zip` | 浏览器下载 | `Index.cshtml:178-178` | | F25 | 下载 `StarServer.zip` | 同上 | GET 外链 | `{dlBase}StarServer.zip` | 浏览器下载 | `Index.cshtml:184-184` | | F26 | 下载 `StarWeb.zip` | 同上 | GET 外链 | `{dlBase}StarWeb.zip` | 浏览器下载 | `Index.cshtml:188-188` | | F27 | 查看 `.NET` 安装命令 `net.sh` | .NET 运行时脚本表 | — | — | 展示 `curl -sSL {dnBase}net.sh \| bash` | `dnBase` 默认 `https://x.newlifex.com/dotnet/` `Index.cshtml:11-12`、`214-214` | | F28 | 查看 `.NET` 安装命令 `net10.sh` | 同上 | — | — | 展示 `curl -sSL {dnBase}net10.sh \| bash` | `Index.cshtml:219-219` | | F29 | 查看 `.NET` 安装命令 `net9.sh` | 同上 | — | — | 展示 `curl -sSL {dnBase}net9.sh \| bash` | `Index.cshtml:224-224` | | F30 | 查看 `.NET` 安装命令 `net8.sh` | 同上 | — | — | 展示 `curl -sSL {dnBase}net8.sh \| bash` | `Index.cshtml:229-229` | | F31 | 查看 `.NET` 安装命令 `net6.sh` | 同上 | — | — | 展示 `curl -sSL {dnBase}net6.sh \| bash` | `Index.cshtml:234-234` | | F32 | 标准 Cube 实体 CRUD | — | — | — | **无**:`ControllerBaseX` 单页,无 `Search` / GetPage / Insert / Update / Delete | 仅 `Index` 公开 Action | ## 4. 列表 本页为静态下载与脚本说明面板,**无** Cube 标准列表。 | 小节 | 内容 | |------|------| | 搜索控件 | 无 | | 列 | 无 | | 行操作 | 无 | | 工具栏 | 无 | | 图表 | 无 | ### 页面表格(非 Cube 列表) **Windows ZIP 压缩包**(`Index.cshtml:36-85`):列「包名」「目标框架」「适用系统」「操作」;行 `staragent10.zip`(net10.0,Windows / Linux)、`staragent90.zip`(net9.0,Windows / Linux)、`staragent80.zip`(net8.0,Windows / Linux)、`staragent60.zip`(net6.0,Windows / Linux)、`staragent45.zip`(net4.5,Windows)、`staragent31.zip`(netcoreapp3.1,旧龙芯 Mips64)。 **Linux tar.gz 压缩包**(`Index.cshtml:88-131`):列同上;行 `staragent10.tar.gz`(net10.0,Linux)、`staragent90.tar.gz`(net9.0,Linux)、`staragent80.tar.gz`(net8.0,Linux / 新龙芯 LA64)、`staragent60.tar.gz`(net6.0,Linux)、`staragent31.tar.gz`(netcoreapp3.1,Linux / 旧龙芯 Mips64)。 **Linux 一键安装脚本**(`Index.cshtml:134-156`):列「脚本」「说明」「安装命令」;行 `star.sh`(自动安装 net9.0 版 StarAgent)、`star8.sh`(自动安装 net8.0 版 StarAgent)。 **星尘平台安装包**(`Index.cshtml:160-193`):列「包名」「说明」「操作」;行 `star.zip`(星尘整体安装包(含Agent/Server/Web))、`StarServer.zip`(星尘服务端)、`StarWeb.zip`(星尘管理平台)。 **.NET 运行时安装脚本**(`Index.cshtml:195-238`):列「脚本」「说明」「安装命令」;行 `net.sh`(.NET 最新版运行时)、`net10.sh`(.NET 10.0 运行时)、`net9.sh`(.NET 9.0 运行时)、`net8.sh`(.NET 8.0 运行时)、`net6.sh`(.NET 6.0 运行时)。 ## 5. 表单与副作用 **无** Cube 编辑表单。 | 项 | 行为 | 文件:行号 | |----|------|-----------| | 下载基址 `AgentBase` | 读 `StarServerSetting.AgentDownloadBaseUrl`;空则 `https://x.newlifex.com/star/`,并保证末尾 `/` | `AgentController.cs:46-50`;配置默认 `Stardust.Server/Setting.cs:167` | | .NET 脚本基址 `DotnetBase` | `DownloadBase` 的 URI 上级目录 `../dotnet/` | `AgentController.cs:53-54` | | 视图兜底基址 | `ViewBag` 为空时 `dlBase` / `dnBase` 硬编码默认 | `Index.cshtml:9-12` | | 顶栏导航 | `PageSetting.EnableNavbar = false` | `AgentController.cs:40-40` | | 布局 | 主题来自 `CubeSetting.Current.Theme`,空则 `ACE`;`Layout = ~/Views/{theme}/_Layout.cshtml` | `Index.cshtml:2-5` | | 本机 Agent 写配置 | 经用户浏览器直连 `localhost:5500`,**不经** MVC 写库 | `Index.cshtml:296-310` | 无加密字段、无保存时连带写业务表。 ## 6. 接口一览 | 接口 | HTTP | 路径 | 权限 | 返回 | |------|------|------|------|------| | `Index` | GET | `/Agent` | `[AllowAnonymous]`(`AgentController.cs:12`) | HTML:`View()` → `Index.cshtml`;或 JSON:`GetAgentData()`(见 F03) | 无其它公开 Action。`DownloadBase`、`DotnetBase`、`GetAgentData` 为 `private`(`AgentController.cs:46-104`)。 无标准 GetPage / Get / Insert / Update / Delete。 ## 7. WebApi 差异 **WebApi 无同名控制器**(`Stardust.WebApi/Controllers/AgentController.cs` 不存在)。 | 项 | MVC | WebApi | |----|-----|--------| | `Index`(HTML + JSON) | 有(`AgentController.cs:23-43`) | **缺失** | | 下载基址配置 | `StarServerSetting.AgentDownloadBaseUrl` | **无对应控制器** | ### 2026-11-04 WebApi 补齐记录 - **新增** `Stardust.WebApi/AgentController.cs`(根控制器,`[AllowAnonymous]` 对齐 MVC): - `GET /Agent`(`Index`,`AgentController.cs:31-49`):保留 MVC 的 `AgentServerUrl` 非本站重定向逻辑;`Accept: application/json` 或 `format=json` 返回与 MVC `GetAgentData()` 同构的下载目录 JSON(`server`、`agent.zip[]`、`agent.targz[]`、`agent.scripts[]`、`packages[]`、`dotnet[]`)。**差异**:WebApi 无视图,未配置跳转且非 JSON 请求时同样返回目录 JSON(MVC 渲染 HTML,页面由 SPA 承担)。 - **新增** `GET /Agent/Probe`(API 化探测,`AgentController.cs:54-77`):服务端探测 `http://localhost:5500/info`(3 秒超时),返回 `{ online, data }`。**差异**:MVC 由用户浏览器探测「用户本机」Agent,API 探测的是「WebApi 服务器本机」Agent,前端可按场景二选一。 - `setserver`(浏览器直连 `localhost:5500/setserver`):**不补**——MVC 本就不经服务端(`Index.cshtml:297-300`),前端沿用浏览器直连模式。 - `ViewBag.Title`、`PageSetting.EnableNavbar=false`、页面布局与标题:**不补**(纯视图横切)。 - 头部「WebApi」行已同步。 ## 8. 新前端必须保留 - [ ] GET `/Agent` 渲染完整下载页,标题「星尘代理安装」,关闭顶栏导航(与 `EnableNavbar = false` 一致) - [ ] GET `/Agent?format=json` 与 `Accept: application/json` 返回与 `GetAgentData()` 一致的 JSON(含 `server`、`agent.zip`、`agent.targz`、`agent.scripts`、`packages`、`dotnet` 全量条目) - [ ] 下载基址来自 `AgentDownloadBaseUrl`,空则 `https://x.newlifex.com/star/` 且以 `/` 结尾;dotnet 基址为同级 `../dotnet/` - [ ] 展示 Windows ZIP 六行、Linux tar.gz 五行、Linux 脚本 `star.sh` 与 `star8.sh` 的安装命令 - [ ] 展示平台包 `star.zip`、`StarServer.zip`、`StarWeb.zip` 下载 - [ ] 展示 `net.sh`、`net10.sh`、`net9.sh`、`net8.sh`、`net6.sh` 安装命令 - [ ] 页面加载探测 `http://localhost:5500/info`,成功展示 Agent 字段表,失败展示「未检测到本机 StarAgent」 - [ ] 未设置服务端或服务端与当前站点不一致时,提供「设置为当前服务器」/「切换到当前服务器」,调用 `http://localhost:5500/setserver?server=` 当前站点 URL 后刷新状态 - [ ] 匿名可访问(`AllowAnonymous`) ## 9. 证据 - `Stardust.Web/Controllers/AgentController.cs` - `Stardust.Web/Views/Agent/Index.cshtml` - `Stardust.Web/Views/Shared/_App_Nav.cshtml`(通读,无 `/Agent`) - `Stardust.Web/Views/Shared/_Node_Nav.cshtml` - `Stardust.Web/Views/Shared/_Project_Nav.cshtml`(通读,无 `/Agent`) - `Stardust.Server/Setting.cs`(`AgentDownloadBaseUrl` 默认值) - `Stardust.WebApi/Controllers/AgentController.cs`(不存在,已尝试读取)