🎨 优化扩展模块,完成ai接入和对话功能
This commit is contained in:
@@ -67,7 +67,7 @@ func (AIExtension) TableName() string {
|
||||
return "ai_extensions"
|
||||
}
|
||||
|
||||
// AIExtensionManifest 扩展清单结构 (对应 manifest.json)
|
||||
// AIExtensionManifest 扩展清单结构 (对应 manifest.json,兼容 SillyTavern 格式)
|
||||
type AIExtensionManifest struct {
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"display_name,omitempty"`
|
||||
@@ -75,6 +75,7 @@ type AIExtensionManifest struct {
|
||||
Description string `json:"description"`
|
||||
Author string `json:"author"`
|
||||
Homepage string `json:"homepage,omitempty"`
|
||||
HomePage string `json:"homePage,omitempty"` // SillyTavern 兼容(驼峰命名)
|
||||
Repository string `json:"repository,omitempty"`
|
||||
License string `json:"license,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
@@ -83,13 +84,54 @@ type AIExtensionManifest struct {
|
||||
Dependencies map[string]string `json:"dependencies,omitempty"` // {"extension-name": ">=1.0.0"}
|
||||
Conflicts []string `json:"conflicts,omitempty"`
|
||||
Entry string `json:"entry,omitempty"` // 主入口文件
|
||||
Js string `json:"js,omitempty"` // SillyTavern 兼容: JS 入口文件
|
||||
Style string `json:"style,omitempty"` // 样式文件
|
||||
Css string `json:"css,omitempty"` // SillyTavern 兼容: CSS 样式文件
|
||||
Assets []string `json:"assets,omitempty"` // 资源文件列表
|
||||
Settings map[string]interface{} `json:"settings,omitempty"` // 默认设置
|
||||
Options map[string]interface{} `json:"options,omitempty"` // 扩展选项
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"` // 扩展元数据
|
||||
AutoUpdate bool `json:"auto_update,omitempty"` // 是否自动更新(SillyTavern 兼容)
|
||||
InlineScript string `json:"inline_script,omitempty"` // 内联脚本(SillyTavern 兼容)
|
||||
Requires []string `json:"requires,omitempty"` // SillyTavern 兼容: 依赖列表
|
||||
Optional []string `json:"optional,omitempty"` // SillyTavern 兼容: 可选依赖
|
||||
LoadingOrder int `json:"loading_order,omitempty"` // SillyTavern 兼容: 加载顺序
|
||||
I18n map[string]string `json:"i18n,omitempty"` // SillyTavern 兼容: 国际化文件
|
||||
}
|
||||
|
||||
// GetEffectiveName 获取有效名称,兼容 SillyTavern manifest 没有 name 字段的情况
|
||||
func (m *AIExtensionManifest) GetEffectiveName() string {
|
||||
if m.Name != "" {
|
||||
return m.Name
|
||||
}
|
||||
if m.DisplayName != "" {
|
||||
return m.DisplayName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetEffectiveHomepage 获取有效主页地址
|
||||
func (m *AIExtensionManifest) GetEffectiveHomepage() string {
|
||||
if m.Homepage != "" {
|
||||
return m.Homepage
|
||||
}
|
||||
return m.HomePage
|
||||
}
|
||||
|
||||
// GetEffectiveEntry 获取有效的 JS 入口文件路径
|
||||
func (m *AIExtensionManifest) GetEffectiveEntry() string {
|
||||
if m.Entry != "" {
|
||||
return m.Entry
|
||||
}
|
||||
return m.Js
|
||||
}
|
||||
|
||||
// GetEffectiveStyle 获取有效的 CSS 样式文件路径
|
||||
func (m *AIExtensionManifest) GetEffectiveStyle() string {
|
||||
if m.Style != "" {
|
||||
return m.Style
|
||||
}
|
||||
return m.Css
|
||||
}
|
||||
|
||||
// AIExtensionSettings 用户的扩展配置(已废弃,配置现在直接存储在 AIExtension.Settings 中)
|
||||
|
||||
Reference in New Issue
Block a user