129 lines
7.0 KiB
Go
129 lines
7.0 KiB
Go
package Editor
|
||
|
||
// Config 定义了上传和管理图片、视频、文件等的配置信息
|
||
type Config struct {
|
||
// 图片上传配置
|
||
ImageActionName string `json:"imageActionName"` // 执行上传图片的action名称,默认值:image
|
||
ImageFieldName string `json:"imageFieldName"` // 提交的图片表单名称,默认值:file
|
||
ImageMaxSize int `json:"imageMaxSize"` // 上传大小限制,单位B,默认值:2048000
|
||
ImageAllowFiles []string `json:"imageAllowFiles"` // 允许的图片格式,默认值:[".png", ".jpg", ".jpeg"]
|
||
ImageCompressEnable bool `json:"imageCompressEnable"` // 是否压缩图片,默认值:true
|
||
ImageCompressBorder int `json:"imageCompressBorder"` // 图片压缩最长边限制,默认值:1600
|
||
ImageInsertAlign string `json:"imageInsertAlign"` // 插入图片时的浮动方式,默认值:none
|
||
ImageUrlPrefix string `json:"imageUrlPrefix"` // 图片访问路径前缀,默认值:空
|
||
|
||
// 涂鸦上传配置
|
||
ScrawlActionName string `json:"scrawlActionName"` // 执行上传涂鸦的action名称,默认值:scrawl
|
||
ScrawlFieldName string `json:"scrawlFieldName"` // 提交的涂鸦表单名称,默认值:file
|
||
ScrawlMaxSize int `json:"scrawlMaxSize"` // 涂鸦上传大小限制,单位B,默认值:2048000
|
||
ScrawlUrlPrefix string `json:"scrawlUrlPrefix"` // 涂鸦访问路径前缀,默认值:空
|
||
ScrawlInsertAlign string `json:"scrawlInsertAlign"` // 插入涂鸦时的浮动方式,默认值:none
|
||
|
||
// 截图上传配置
|
||
SnapscreenActionName string `json:"snapscreenActionName"` // 执行上传截图的action名称,默认值:snap
|
||
SnapscreenUrlPrefix string `json:"snapscreenUrlPrefix"` // 截图访问路径前缀,默认值:空
|
||
SnapscreenInsertAlign string `json:"snapscreenInsertAlign"` // 插入截图时的浮动方式,默认值:none
|
||
|
||
// 图片抓取配置
|
||
CatcherActionName string `json:"catcherActionName"` // 执行抓取远程图片的action名称,默认值:catch
|
||
CatcherFieldName string `json:"catcherFieldName"` // 提交的图片列表表单名称,默认值:source
|
||
CatcherLocalDomain []string `json:"catcherLocalDomain"` // 例外的图片抓取域名,默认值:["127.0.0.1", "localhost"]
|
||
CatcherUrlPrefix string `json:"catcherUrlPrefix"` // 抓取图片访问路径前缀,默认值:空
|
||
CatcherMaxSize int `json:"catcherMaxSize"` // 抓取图片上传大小限制,单位B,默认值:10485760
|
||
CatcherAllowFiles []string `json:"catcherAllowFiles"` // 允许的抓取图片格式,默认值:[".png", ".jpg", ".jpeg"]
|
||
|
||
// 视频上传配置
|
||
VideoActionName string `json:"videoActionName"` // 执行上传视频的action名称,默认值:video
|
||
VideoFieldName string `json:"videoFieldName"` // 提交的视频表单名称,默认值:file
|
||
VideoUrlPrefix string `json:"videoUrlPrefix"` // 视频访问路径前缀,默认值:空
|
||
VideoMaxSize int `json:"videoMaxSize"` // 上传视频大小限制,单位B,默认值:102400000
|
||
VideoAllowFiles []string `json:"videoAllowFiles"` // 允许的视频格式,默认值:[".mp4"]
|
||
|
||
// 文件上传配置
|
||
FileActionName string `json:"fileActionName"` // 执行上传文件的action名称,默认值:file
|
||
FileFieldName string `json:"fileFieldName"` // 提交的文件表单名称,默认值:file
|
||
FileUrlPrefix string `json:"fileUrlPrefix"` // 文件访问路径前缀,默认值:空
|
||
FileMaxSize int `json:"fileMaxSize"` // 上传文件大小限制,单位B,默认值:104857600
|
||
FileAllowFiles []string `json:"fileAllowFiles"` // 允许的文件格式,默认值:[".zip", ".pdf", ".doc"]
|
||
|
||
// 图片列表配置
|
||
ImageManagerActionName string `json:"imageManagerActionName"` // 执行图片管理的action名称,默认值:listImage
|
||
ImageManagerListSize int `json:"imageManagerListSize"` // 每次列出文件数量,默认值:20
|
||
ImageManagerUrlPrefix string `json:"imageManagerUrlPrefix"` // 图片管理访问路径前缀,默认值:空
|
||
ImageManagerInsertAlign string `json:"imageManagerInsertAlign"` // 插入的图片浮动方式,默认值:none
|
||
ImageManagerAllowFiles []string `json:"imageManagerAllowFiles"` // 列出的图片文件类型,默认值:[".jpg", ".png", ".jpeg"]
|
||
|
||
// 文件列表配置
|
||
FileManagerActionName string `json:"fileManagerActionName"` // 执行文件管理的action名称,默认值:listFile
|
||
FileManagerUrlPrefix string `json:"fileManagerUrlPrefix"` // 指定要列出文件的目录,默认值:空
|
||
FileManagerListSize int `json:"fileManagerListSize"` // 每次列出文件数量,默认值:20
|
||
FileManagerAllowFiles []string `json:"fileManagerAllowFiles"` // 列出的文件类型,默认值:[".zip", ".pdf", ".doc"]
|
||
|
||
// 公式配置
|
||
FormulaConfig FormulaConfig `json:"formulaConfig"` // 公式渲染相关配置
|
||
}
|
||
|
||
// FormulaConfig 定义了公式渲染的相关配置
|
||
type FormulaConfig struct {
|
||
ImageUrlTemplate string `json:"imageUrlTemplate"` // 公式渲染的图片URL模板
|
||
}
|
||
|
||
// UploadDto 上传返回数据
|
||
type UploadDto struct {
|
||
Original string `json:"original"`
|
||
State string `json:"state"`
|
||
Title string `json:"title"`
|
||
Type string `json:"type"`
|
||
Url string `json:"url"`
|
||
}
|
||
|
||
// GetConfig 封装方法,返回配置信息
|
||
func GetConfig() Config {
|
||
return Config{
|
||
ImageActionName: "image",
|
||
ImageFieldName: "file",
|
||
ImageMaxSize: 8388608,
|
||
ImageAllowFiles: []string{".jpg", ".png", ".jpeg"},
|
||
ImageCompressEnable: false,
|
||
ImageCompressBorder: 5000,
|
||
ImageInsertAlign: "none",
|
||
ImageUrlPrefix: "",
|
||
ScrawlActionName: "crawl",
|
||
ScrawlFieldName: "file",
|
||
ScrawlMaxSize: 10485760,
|
||
ScrawlUrlPrefix: "",
|
||
ScrawlInsertAlign: "none",
|
||
SnapscreenActionName: "snap",
|
||
SnapscreenUrlPrefix: "",
|
||
SnapscreenInsertAlign: "none",
|
||
CatcherActionName: "catch",
|
||
CatcherFieldName: "source",
|
||
CatcherLocalDomain: []string{"127.0.0.1", "localhost"},
|
||
CatcherUrlPrefix: "",
|
||
CatcherMaxSize: 10485760,
|
||
CatcherAllowFiles: []string{".jpg", ".png", ".jpeg"},
|
||
VideoActionName: "video",
|
||
VideoFieldName: "file",
|
||
VideoUrlPrefix: "",
|
||
VideoMaxSize: 104857600,
|
||
VideoAllowFiles: []string{".mp4"},
|
||
FileActionName: "file",
|
||
FileFieldName: "file",
|
||
FileUrlPrefix: "",
|
||
FileMaxSize: 104857600,
|
||
FileAllowFiles: []string{".zip", ".pdf", ".doc"},
|
||
ImageManagerActionName: "listImage",
|
||
ImageManagerListSize: 20,
|
||
ImageManagerUrlPrefix: "",
|
||
ImageManagerInsertAlign: "none",
|
||
ImageManagerAllowFiles: []string{".jpg", ".png", ".jpeg"},
|
||
FileManagerActionName: "listFile",
|
||
FileManagerUrlPrefix: "",
|
||
FileManagerListSize: 20,
|
||
FileManagerAllowFiles: []string{".zip", ".pdf", ".doc"},
|
||
FormulaConfig: FormulaConfig{
|
||
ImageUrlTemplate: "https://r.latexeasy.com/image.svg?{}",
|
||
},
|
||
}
|
||
}
|