🎨 移除扩展模块相关代码

This commit is contained in:
2026-02-24 13:38:29 +08:00
parent 0f9c9c9b9c
commit 0ebe197cc1
28 changed files with 39 additions and 4996 deletions

View File

@@ -1,67 +0,0 @@
package app
import (
"git.echol.cn/loser/st/server/global"
"gorm.io/datatypes"
)
// AIExtension 扩展Extension
type AIExtension struct {
global.GVA_MODEL
UserID uint `json:"userId" gorm:"not null;index;comment:所属用户ID"`
User *AppUser `json:"user" gorm:"foreignKey:UserID"`
// 基础信息
Name string `json:"name" gorm:"type:varchar(200);not null;index;comment:扩展名称(唯一标识)"`
DisplayName string `json:"displayName" gorm:"type:varchar(200);comment:扩展显示名称"`
Version string `json:"version" gorm:"type:varchar(50);default:'1.0.0';comment:版本号"`
Author string `json:"author" gorm:"type:varchar(200);comment:作者"`
Description string `json:"description" gorm:"type:text;comment:扩展描述"`
Homepage string `json:"homepage" gorm:"type:varchar(500);comment:主页链接"`
Repository string `json:"repository" gorm:"type:varchar(500);comment:仓库地址"`
License string `json:"license" gorm:"type:varchar(100);comment:许可证"`
// 分类与标签
ExtensionType string `json:"extensionType" gorm:"type:varchar(20);default:'ui';comment:扩展类型:ui,server,hybrid"`
Category string `json:"category" gorm:"type:varchar(50);comment:分类:utilities,themes,integrations,tools"`
Tags datatypes.JSON `json:"tags" gorm:"type:jsonb;comment:标签列表"`
// 依赖管理
Dependencies datatypes.JSON `json:"dependencies" gorm:"type:jsonb;comment:依赖扩展"`
Conflicts datatypes.JSON `json:"conflicts" gorm:"type:jsonb;comment:冲突扩展"`
// 文件路径
ScriptPath string `json:"scriptPath" gorm:"type:varchar(500);comment:脚本文件路径"`
StylePath string `json:"stylePath" gorm:"type:varchar(500);comment:样式文件路径"`
AssetPaths datatypes.JSON `json:"assetPaths" gorm:"type:jsonb;comment:资源文件路径列表"`
// 配置与元数据
ManifestData datatypes.JSON `json:"manifestData" gorm:"type:jsonb;comment:manifest 元数据"`
Settings datatypes.JSON `json:"settings" gorm:"type:jsonb;comment:扩展配置"`
Options datatypes.JSON `json:"options" gorm:"type:jsonb;comment:扩展选项"`
Metadata datatypes.JSON `json:"metadata" gorm:"type:jsonb;comment:额外元数据"`
// 状态管理
IsEnabled bool `json:"isEnabled" gorm:"default:false;comment:是否启用"`
IsInstalled bool `json:"isInstalled" gorm:"default:true;comment:是否已安装"`
IsSystemExt bool `json:"isSystemExt" gorm:"default:false;comment:是否系统扩展"`
// 安装信息
InstallSource string `json:"installSource" gorm:"type:varchar(50);comment:安装来源:url,git,file,marketplace"`
SourceURL string `json:"sourceUrl" gorm:"type:varchar(500);comment:源地址"`
Branch string `json:"branch" gorm:"type:varchar(100);default:'main';comment:Git 分支"`
AutoUpdate bool `json:"autoUpdate" gorm:"default:false;comment:是否自动更新"`
LastUpdateCheck *int64 `json:"lastUpdateCheck" gorm:"comment:最后检查更新时间戳"`
AvailableVersion string `json:"availableVersion" gorm:"type:varchar(50);comment:可用的新版本"`
InstallDate *int64 `json:"installDate" gorm:"comment:安装日期时间戳"`
LastEnabled *int64 `json:"lastEnabled" gorm:"comment:最后启用时间戳"`
// 统计信息
UsageCount int `json:"usageCount" gorm:"default:0;comment:使用次数"`
ErrorCount int `json:"errorCount" gorm:"default:0;comment:错误次数"`
LoadTime int `json:"loadTime" gorm:"default:0;comment:加载时间(ms)"`
}
func (AIExtension) TableName() string {
return "ai_extensions"
}

View File

@@ -1,83 +0,0 @@
package request
import (
common "git.echol.cn/loser/st/server/model/common/request"
)
// CreateExtensionRequest 创建扩展请求
type CreateExtensionRequest struct {
Name string `json:"name" binding:"required"`
DisplayName string `json:"displayName"`
Version string `json:"version"`
Author string `json:"author"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Repository string `json:"repository"`
License string `json:"license"`
Tags []string `json:"tags"`
ExtensionType string `json:"extensionType" binding:"required"`
Category string `json:"category"`
Dependencies map[string]string `json:"dependencies"`
Conflicts []string `json:"conflicts"`
ManifestData map[string]interface{} `json:"manifestData"`
ScriptPath string `json:"scriptPath"`
StylePath string `json:"stylePath"`
AssetPaths []string `json:"assetPaths"`
Settings map[string]interface{} `json:"settings"`
Options map[string]interface{} `json:"options"`
InstallSource string `json:"installSource"`
SourceURL string `json:"sourceUrl"`
Branch string `json:"branch"`
Metadata map[string]interface{} `json:"metadata"`
}
// UpdateExtensionRequest 更新扩展请求
type UpdateExtensionRequest struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
Version string `json:"version"`
Author string `json:"author"`
Homepage string `json:"homepage"`
Repository string `json:"repository"`
License string `json:"license"`
Tags []string `json:"tags"`
ExtensionType string `json:"extensionType"`
Category string `json:"category"`
Dependencies map[string]string `json:"dependencies"`
Conflicts []string `json:"conflicts"`
ManifestData map[string]interface{} `json:"manifestData"`
ScriptPath string `json:"scriptPath"`
StylePath string `json:"stylePath"`
AssetPaths []string `json:"assetPaths"`
Settings map[string]interface{} `json:"settings"`
Options map[string]interface{} `json:"options"`
Metadata map[string]interface{} `json:"metadata"`
}
// ExtensionListRequest 扩展列表查询请求
type ExtensionListRequest struct {
common.PageInfo
Keyword string `json:"keyword" form:"keyword"` // 搜索关键词
Name string `json:"name" form:"name"` // 扩展名称
ExtensionType string `json:"extensionType" form:"extensionType"` // 扩展类型
Category string `json:"category" form:"category"` // 分类
IsEnabled *bool `json:"isEnabled" form:"isEnabled"` // 是否启用
IsInstalled *bool `json:"isInstalled" form:"isInstalled"` // 是否已安装
Tag string `json:"tag" form:"tag"` // 标签
}
// ToggleExtensionRequest 启用/禁用扩展请求
type ToggleExtensionRequest struct {
IsEnabled bool `json:"isEnabled"`
}
// UpdateExtensionSettingsRequest 更新扩展设置请求
type UpdateExtensionSettingsRequest struct {
Settings map[string]interface{} `json:"settings" binding:"required"`
}
// InstallExtensionRequest 从URL安装扩展请求
type InstallExtensionRequest struct {
URL string `json:"url" binding:"required"`
Branch string `json:"branch"`
}

View File

@@ -1,113 +0,0 @@
package response
import (
"encoding/json"
"git.echol.cn/loser/st/server/model/app"
)
// ExtensionResponse 扩展响应
type ExtensionResponse struct {
ID uint `json:"id"`
UserID uint `json:"userId"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Version string `json:"version"`
Author string `json:"author"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Repository string `json:"repository"`
License string `json:"license"`
Tags []string `json:"tags"`
ExtensionType string `json:"extensionType"`
Category string `json:"category"`
Dependencies map[string]string `json:"dependencies"`
Conflicts []string `json:"conflicts"`
ScriptPath string `json:"scriptPath"`
StylePath string `json:"stylePath"`
AssetPaths []string `json:"assetPaths"`
ManifestData map[string]interface{} `json:"manifestData"`
Settings map[string]interface{} `json:"settings"`
Options map[string]interface{} `json:"options"`
Metadata map[string]interface{} `json:"metadata"`
IsEnabled bool `json:"isEnabled"`
IsInstalled bool `json:"isInstalled"`
IsSystemExt bool `json:"isSystemExt"`
InstallSource string `json:"installSource"`
SourceURL string `json:"sourceUrl"`
Branch string `json:"branch"`
AutoUpdate bool `json:"autoUpdate"`
LastUpdateCheck *int64 `json:"lastUpdateCheck"`
AvailableVersion string `json:"availableVersion"`
InstallDate *int64 `json:"installDate"`
LastEnabled *int64 `json:"lastEnabled"`
UsageCount int `json:"usageCount"`
ErrorCount int `json:"errorCount"`
LoadTime int `json:"loadTime"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
// ExtensionListResponse 扩展列表响应
type ExtensionListResponse struct {
List []ExtensionResponse `json:"list"`
Total int64 `json:"total"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
// unmarshalJSONB 通用 JSONB 反序列化辅助函数
func unmarshalJSONB[T any](data []byte, fallback T) T {
if len(data) == 0 {
return fallback
}
var result T
if err := json.Unmarshal(data, &result); err != nil {
return fallback
}
return result
}
// ToExtensionResponse 将 AIExtension 转换为 ExtensionResponse
func ToExtensionResponse(ext *app.AIExtension) ExtensionResponse {
return ExtensionResponse{
ID: ext.ID,
UserID: ext.UserID,
Name: ext.Name,
DisplayName: ext.DisplayName,
Version: ext.Version,
Author: ext.Author,
Description: ext.Description,
Homepage: ext.Homepage,
Repository: ext.Repository,
License: ext.License,
Tags: unmarshalJSONB(ext.Tags, []string{}),
ExtensionType: ext.ExtensionType,
Category: ext.Category,
Dependencies: unmarshalJSONB(ext.Dependencies, map[string]string{}),
Conflicts: unmarshalJSONB(ext.Conflicts, []string{}),
ScriptPath: ext.ScriptPath,
StylePath: ext.StylePath,
AssetPaths: unmarshalJSONB(ext.AssetPaths, []string{}),
ManifestData: unmarshalJSONB(ext.ManifestData, map[string]interface{}{}),
Settings: unmarshalJSONB(ext.Settings, map[string]interface{}{}),
Options: unmarshalJSONB(ext.Options, map[string]interface{}{}),
Metadata: unmarshalJSONB(ext.Metadata, map[string]interface{}{}),
IsEnabled: ext.IsEnabled,
IsInstalled: ext.IsInstalled,
IsSystemExt: ext.IsSystemExt,
InstallSource: ext.InstallSource,
SourceURL: ext.SourceURL,
Branch: ext.Branch,
AutoUpdate: ext.AutoUpdate,
LastUpdateCheck: ext.LastUpdateCheck,
AvailableVersion: ext.AvailableVersion,
InstallDate: ext.InstallDate,
LastEnabled: ext.LastEnabled,
UsageCount: ext.UsageCount,
ErrorCount: ext.ErrorCount,
LoadTime: ext.LoadTime,
CreatedAt: ext.CreatedAt.Unix(),
UpdatedAt: ext.UpdatedAt.Unix(),
}
}