flatpak

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package flatpak 桌面实例管理(KasmVNC 启动/停止/状态)

Package flatpak HTTP 处理器

Package flatpak KasmVNC 自动安装/升级管理

Package flatpak Flatpak 应用模块

Package flatpak 核心服务

Package flatpak 类型定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveInstall

type ActiveInstall struct {
	AppID     string    `json:"app_id"`
	AppName   string    `json:"app_name"`
	StartedAt time.Time `json:"started_at"`
	Status    string    `json:"status"` // installing, success, error
	Error     string    `json:"error,omitempty"`
}

ActiveInstall 正在进行的安装任务

type Desktop

type Desktop struct {
	// contains filtered or unexported fields
}

Desktop KasmVNC 桌面实例管理器

func NewDesktop

func NewDesktop(logger *zap.Logger, dataDir string, installer *Installer) *Desktop

NewDesktop 创建桌面管理器

func (*Desktop) GetConfig

func (d *Desktop) GetConfig() DesktopConfig

GetConfig 获取配置

func (*Desktop) GetRunningApps

func (d *Desktop) GetRunningApps() []*RunningApp

GetRunningApps 获取运行中的应用

func (*Desktop) GetStatus

func (d *Desktop) GetStatus() *DesktopStatus

GetStatus 获取桌面状态

func (*Desktop) LaunchApp

func (d *Desktop) LaunchApp(appID, name string, args []string) error

LaunchApp 在桌面中启动 Flatpak 应用

func (*Desktop) Restart

func (d *Desktop) Restart() error

Restart 重启桌面

func (*Desktop) SetConfig

func (d *Desktop) SetConfig(config DesktopConfig)

SetConfig 更新配置

func (*Desktop) Start

func (d *Desktop) Start() error

Start 启动 KasmVNC 桌面实例

func (*Desktop) Stop

func (d *Desktop) Stop()

Stop 停止桌面

type DesktopConfig

type DesktopConfig struct {
	Display           int    `json:"display"`
	WebSocketPort     int    `json:"websocket_port"`
	DefaultResolution string `json:"default_resolution"`
	AudioEnabled      bool   `json:"audio_enabled"`
	ClipboardSync     bool   `json:"clipboard_sync"`
	AutoStart         bool   `json:"auto_start"`
}

DesktopConfig 桌面配置

func DefaultDesktopConfig

func DefaultDesktopConfig() DesktopConfig

DefaultDesktopConfig 默认桌面配置

type DesktopStatus

type DesktopStatus struct {
	Running        bool     `json:"running"`
	Display        int      `json:"display"`
	WebSocketPort  int      `json:"websocket_port"`
	VNCURL         string   `json:"vnc_url"`
	PID            int      `json:"pid"`
	Uptime         int64    `json:"uptime"`
	Resolution     string   `json:"resolution"`
	RunningApps    []string `json:"running_apps"`
	KasmVNCVersion string   `json:"kasmvnc_version"`
}

DesktopStatus 桌面实例状态

type FlatpakApp

type FlatpakApp struct {
	AppID       string `json:"app_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`
	Icon        string `json:"icon,omitempty"`
	Category    string `json:"category,omitempty"`
	Installed   bool   `json:"installed"`
	Size        string `json:"size,omitempty"`
	Runtime     string `json:"runtime,omitempty"`
	Remote      string `json:"remote,omitempty"`
	Running     bool   `json:"running"`
}

FlatpakApp Flatpak 应用

type GHProxyProvider

type GHProxyProvider interface {
	// IsPremium 是否为付费会员
	IsPremium() bool
	// GetGHProxyURL 获取 GitHub 加速代理 URL
	GetGHProxyURL(originalURL string) (string, error)
}

GHProxyProvider GitHub 加速代理提供者接口 由 premium 模块实现,为 flatpak 提供加速下载能力

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler HTTP 处理器

func NewHandler

func NewHandler(service *Service) *Handler

NewHandler 创建处理器实例

func (*Handler) GetActiveInstalls

func (h *Handler) GetActiveInstalls(c *gin.Context)

GetActiveInstalls 获取当前正在安装的应用列表

func (*Handler) GetDesktopConfig

func (h *Handler) GetDesktopConfig(c *gin.Context)

GetDesktopConfig 获取桌面配置

func (*Handler) GetDesktopStatus

func (h *Handler) GetDesktopStatus(c *gin.Context)

GetDesktopStatus 获取桌面状态

func (*Handler) GetInstalledApps

func (h *Handler) GetInstalledApps(c *gin.Context)

GetInstalledApps 获取已安装的 Flatpak 应用

func (*Handler) GetRecommendedApps

func (h *Handler) GetRecommendedApps(c *gin.Context)

GetRecommendedApps 获取推荐应用列表

func (*Handler) GetRecommendedCategories

func (h *Handler) GetRecommendedCategories(c *gin.Context)

GetRecommendedCategories 获取推荐分类

func (*Handler) GetSetupStatus

func (h *Handler) GetSetupStatus(c *gin.Context)

GetSetupStatus 获取环境检测状态

func (*Handler) InstallAppStream

func (h *Handler) InstallAppStream(c *gin.Context)

InstallAppStream SSE 流式安装应用

func (*Handler) ProxyVNC

func (h *Handler) ProxyVNC(c *gin.Context)

ProxyVNC 反向代理 KasmVNC HTTP 和 WebSocket 请求

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(r *gin.RouterGroup)

RegisterRoutes 注册路由

func (*Handler) RestartDesktop

func (h *Handler) RestartDesktop(c *gin.Context)

RestartDesktop 重启桌面

func (*Handler) RunApp

func (h *Handler) RunApp(c *gin.Context)

RunApp 运行应用

func (*Handler) RunSetupStream

func (h *Handler) RunSetupStream(c *gin.Context)

RunSetupStream SSE 流式执行环境安装

func (*Handler) SearchApps

func (h *Handler) SearchApps(c *gin.Context)

SearchApps 搜索 Flathub 应用

func (*Handler) ServeIcon

func (h *Handler) ServeIcon(c *gin.Context)

ServeIcon 提供 Flatpak 应用图标

func (*Handler) StartDesktop

func (h *Handler) StartDesktop(c *gin.Context)

StartDesktop 启动桌面

func (*Handler) StopDesktop

func (h *Handler) StopDesktop(c *gin.Context)

StopDesktop 停止桌面

func (*Handler) UninstallApp

func (h *Handler) UninstallApp(c *gin.Context)

UninstallApp 卸载应用

func (*Handler) UpdateDesktopConfig

func (h *Handler) UpdateDesktopConfig(c *gin.Context)

UpdateDesktopConfig 更新桌面配置

func (*Handler) WatchInstallProgress

func (h *Handler) WatchInstallProgress(c *gin.Context)

WatchInstallProgress SSE 重连安装进度

type InstallRequest

type InstallRequest struct {
	AppID   string `json:"app_id" binding:"required"`
	AppName string `json:"app_name"`
}

InstallRequest 安装请求

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer KasmVNC 安装管理器

func NewInstaller

func NewInstaller(logger *zap.Logger) *Installer

NewInstaller 创建安装管理器

func (*Installer) CheckSystemDeps

func (inst *Installer) CheckSystemDeps() *SetupStatus

CheckSystemDeps 检查系统依赖

func (*Installer) GetBinaryPath

func (inst *Installer) GetBinaryPath() string

GetBinaryPath 获取 kasmvncserver / Xkasmvnc 可执行文件路径

func (*Installer) GetDownloadURL

func (inst *Installer) GetDownloadURL() (string, string, error)

GetDownloadURL 获取下载地址(国内自动走 ghproxy 加速)

func (*Installer) GetInstalledVersion

func (inst *Installer) GetInstalledVersion() string

GetInstalledVersion 获取已安装的版本

func (*Installer) GetVNCServerPath

func (inst *Installer) GetVNCServerPath() string

GetVNCServerPath 获取 kasmvncserver 脚本路径

func (*Installer) GetWebDir

func (inst *Installer) GetWebDir() string

GetWebDir 获取 Web 客户端目录

func (*Installer) Install

func (inst *Installer) Install(onProgress func(line string)) error

Install 下载并安装 KasmVNC

func (*Installer) IsInstalled

func (inst *Installer) IsInstalled() bool

IsInstalled 检查 KasmVNC 是否已安装(通过系统包管理器)

func (*Installer) NeedsUpdate

func (inst *Installer) NeedsUpdate() bool

NeedsUpdate 检查是否需要更新

func (*Installer) SetGHProxyProvider

func (inst *Installer) SetGHProxyProvider(provider GHProxyProvider)

SetGHProxyProvider 设置 GitHub 加速代理提供者

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module Flatpak 模块

func New

func New() *Module

New 创建模块实例

func (*Module) Dependencies

func (m *Module) Dependencies() []string

func (*Module) GetInstaller

func (m *Module) GetInstaller() *Installer

GetInstaller 获取安装管理器实例(供其他模块注入加速提供者)

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init(ctx *module.Context) error

Init 初始化模块

func (*Module) Name

func (m *Module) Name() string

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(group *gin.RouterGroup)

RegisterRoutes 注册路由

func (*Module) Start

func (m *Module) Start() error

Start 启动模块

func (*Module) Stop

func (m *Module) Stop() error

Stop 停止模块

func (*Module) Version

func (m *Module) Version() string

type RecommendedApp

type RecommendedApp struct {
	AppID       string `json:"app_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Category    string `json:"category"`
	Icon        string `json:"icon,omitempty"`
}

RecommendedApp 推荐应用

type RunRequest

type RunRequest struct {
	AppID string   `json:"app_id" binding:"required"`
	Args  []string `json:"args,omitempty"`
}

RunRequest 启动应用请求

type RunningApp

type RunningApp struct {
	AppID     string    `json:"app_id"`
	Name      string    `json:"name"`
	PID       int       `json:"pid"`
	StartedAt time.Time `json:"started_at"`
}

RunningApp 运行中的应用进程

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service Flatpak 服务

func NewService

func NewService(logger *zap.Logger, dataDir string) *Service

NewService 创建服务实例

func (*Service) GetActiveInstalls

func (s *Service) GetActiveInstalls() []ActiveInstall

GetActiveInstalls 获取当前正在安装的应用列表

func (*Service) GetDesktopConfig

func (s *Service) GetDesktopConfig() DesktopConfig

GetDesktopConfig 获取桌面配置

func (*Service) GetDesktopStatus

func (s *Service) GetDesktopStatus() *DesktopStatus

GetDesktopStatus 获取桌面状态

func (*Service) GetInstalledApps

func (s *Service) GetInstalledApps() []*FlatpakApp

GetInstalledApps 获取已安装的 Flatpak 应用

func (*Service) GetRecommendedApps

func (s *Service) GetRecommendedApps(category string) []*FlatpakApp

GetRecommendedApps 获取推荐应用列表

func (*Service) GetRecommendedCategories

func (s *Service) GetRecommendedCategories() []string

GetRecommendedCategories 获取推荐分类

func (*Service) GetSetupStatus

func (s *Service) GetSetupStatus() *SetupStatus

GetSetupStatus 获取环境检测状态

func (*Service) InstallApp

func (s *Service) InstallApp(appID string, appName string, onProgress func(line string), onComplete func(err error))

InstallApp 安装 Flatpak 应用(带流式进度) 如果已有同一应用的安装任务正在运行,直接返回(前端应通过 WatchInstallProgress 重连)

func (*Service) RestartDesktop

func (s *Service) RestartDesktop() error

RestartDesktop 重启桌面

func (*Service) RunApp

func (s *Service) RunApp(appID string, args []string) error

RunApp 在桌面中运行应用

func (*Service) RunSetup

func (s *Service) RunSetup(onProgress func(line string), onComplete func(err error))

RunSetup 执行环境安装(SSE 流式输出)

func (*Service) SearchApps

func (s *Service) SearchApps(query string, limit int) []*FlatpakApp

SearchApps 搜索 Flathub 应用

func (*Service) Start

func (s *Service) Start() error

Start 启动服务

func (*Service) StartDesktop

func (s *Service) StartDesktop() error

StartDesktop 启动桌面

func (*Service) Stop

func (s *Service) Stop()

Stop 停止服务

func (*Service) StopDesktop

func (s *Service) StopDesktop()

StopDesktop 停止桌面

func (*Service) UninstallApp

func (s *Service) UninstallApp(appID string) error

UninstallApp 卸载 Flatpak 应用

func (*Service) UnsubscribeInstall

func (s *Service) UnsubscribeInstall(appID string, ch chan string)

UnsubscribeInstall 取消订阅

func (*Service) UpdateDesktopConfig

func (s *Service) UpdateDesktopConfig(config DesktopConfig)

UpdateDesktopConfig 更新桌面配置

func (*Service) WatchInstallProgress

func (s *Service) WatchInstallProgress(appID string) (logs []string, ch chan string, status string, errMsg string, exists bool)

WatchInstallProgress 订阅安装进度,返回 (历史日志, 实时通道, 任务状态, 是否存在)

type SetupStatus

type SetupStatus struct {
	KasmVNCInstalled    bool   `json:"kasmvnc_installed"`
	KasmVNCVersion      string `json:"kasmvnc_version"`
	KasmVNCExpected     string `json:"kasmvnc_expected"`
	FlatpakInstalled    bool   `json:"flatpak_installed"`
	FlatpakRemoteOK     bool   `json:"flatpak_remote_ok"`
	OpenboxInstalled    bool   `json:"openbox_installed"`
	PulseAudioInstalled bool   `json:"pulseaudio_installed"`
	PulseAudioRunning   bool   `json:"pulseaudio_running"`
	VirtualSinkReady    bool   `json:"virtual_sink_ready"`
	Ready               bool   `json:"ready"`
}

SetupStatus 环境检测状态

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL