From 4ab108bf5327df19fb1c08253c9297dd554c7c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=B8=80=E9=B8=A3?= <1000000008@qq.com> Date: Thu, 29 Oct 2026 02:10:09 -0400 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=9A=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=94=B9=E4=B8=BA=E4=BB=8E=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terminal/kiosk-shell/src/desktop_service.cpp | 65 +++++++------------- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/terminal/kiosk-shell/src/desktop_service.cpp b/terminal/kiosk-shell/src/desktop_service.cpp index bd2e1bb..2c9687f 100644 --- a/terminal/kiosk-shell/src/desktop_service.cpp +++ b/terminal/kiosk-shell/src/desktop_service.cpp @@ -1,5 +1,7 @@ #include "desktop_service.h" +#include "desktop_store.h" + namespace vdi { void DesktopService::login(const QString& username, const QString& password, AuthCallback callback) { @@ -20,59 +22,34 @@ void DesktopService::login(const QString& username, const QString& password, Aut } void DesktopService::listDesktops(DesktopListCallback callback) { - // 本地演示数据:Windows 可用(Moonlight),Ubuntu/麒麟尚未分配连接信息。 + // 桌面与连接参数来自本地连接配置(现场可配); // 正式版本替换为 /api/v1/terminal/session/desktops(按用户绑定返回)。 - std::vector desktops; - - DesktopInfo windows; - windows.id = QStringLiteral("desk-win10-01"); - windows.name = QStringLiteral("Windows 10"); - windows.os = QStringLiteral("Windows 10 22H2 专业版"); - windows.protocol = Protocol::kMoonlight; - windows.state = DesktopState::kAvailable; - windows.endpoint = QStringLiteral("192.168.1.70"); - windows.app = QStringLiteral("Desktop"); - desktops.push_back(windows); - - DesktopInfo ubuntu; - ubuntu.id = QStringLiteral("desk-ubuntu-01"); - ubuntu.name = QStringLiteral("Ubuntu"); - ubuntu.os = QStringLiteral("Ubuntu 桌面"); - ubuntu.protocol = Protocol::kRdp; - ubuntu.state = DesktopState::kUnassigned; - desktops.push_back(ubuntu); - - DesktopInfo kylin; - kylin.id = QStringLiteral("desk-kylin-01"); - kylin.name = QStringLiteral("麒麟"); - kylin.os = QStringLiteral("银河麒麟桌面"); - kylin.protocol = Protocol::kRdp; - kylin.state = DesktopState::kUnassigned; - desktops.push_back(kylin); - + std::vector desktops = DesktopStore::load(); if (callback) { callback(std::move(desktops), QString()); } } void DesktopService::createTicket(const QString& desktopId, TicketCallback callback) { - // 本地演示票据:直接由桌面列表数据构造。 + // 本地演示票据:由连接配置构造。 // 正式版本替换为 /api/v1/terminal/session/connect-ticket(短期一次性票据)。 ConnectionTicket ticket; ticket.desktopId = desktopId; - std::vector desktops; QString error; - listDesktops([&desktops, &error](std::vector list, const QString& err) { - desktops = std::move(list); - error = err; - }); - - for (const DesktopInfo& d : desktops) { - if (d.id == desktopId) { + listDesktops([&ticket, &error, desktopId](std::vector list, const QString& err) { + if (!err.isEmpty()) { + error = err; + return; + } + for (const DesktopInfo& d : list) { + if (d.id != desktopId) { + continue; + } if (d.state != DesktopState::kAvailable) { - error = QStringLiteral("桌面 %1 尚未分配连接信息").arg(d.name); - break; + error = QStringLiteral("桌面 %1 尚未配置连接地址,请先在“设置”中完成配置") + .arg(d.name); + return; } ticket.protocol = d.protocol; ticket.endpoint = d.endpoint; @@ -80,10 +57,12 @@ void DesktopService::createTicket(const QString& desktopId, TicketCallback callb ticket.width = d.width; ticket.height = d.height; ticket.fps = d.fps; - error.clear(); - break; + return; } - } + if (error.isEmpty() && ticket.endpoint.isEmpty()) { + error = QStringLiteral("桌面不存在"); + } + }); if (callback) { callback(ticket, error);