Documentation ¶
Index ¶
- Constants
- func DecodeHex(str string) ([]byte, error)
- func DecodeUTF16(b []byte) (string, error)
- type DictList
- type DictType
- type DictionaryItem
- type DirDcitType
- type DirItem
- type GeneralDictionary
- type ImgType
- type KeyQueryIndex
- type MdictKeyWordIndex
- type MdictMeta
- type PlainDictionaryInfo
- type PlainDictionaryItem
- type Resp
Constants ¶
View Source
const ( SuccessErrCode = 200 InnerSysErrCode = 500 BadParamErrCode = 401 BadReqCode = 400 UnknownErrorCode = 999 )
View Source
const IndexTypeMdict = "IndexTypeMdict"
View Source
const IndexTypeStardict = "IndexTypeMdict"
Variables ¶
This section is empty.
Functions ¶
func DecodeUTF16 ¶
Types ¶
type DictList ¶
type DictList []*PlainDictionaryItem
type DictType ¶
type DictType string
const DictTypeMdict DictType = "Mdict"
const DictTypeStarDict DictType = "StarDict"
type DictionaryItem ¶
type DictionaryItem struct { *PlainDictionaryItem MainDict GeneralDictionary PathInfo *DirItem }
func (*DictionaryItem) ToPlain ¶
func (dict *DictionaryItem) ToPlain() *PlainDictionaryItem
type DirDcitType ¶
type DirDcitType string
type DirItem ¶
type DirItem struct { BaseDir string CurrentDir string IsValid bool DictType DictType // 特殊文件类型 CoverImgPath string CoverImgType ImgType ConfigPath string LicensePath string // medict 文件路径 MdictMdxFileName string MdictMdxAbsPath string MdictMddAbsPath []string // StartDict文件路径 StarDictDzAbsPath string StarDictAbsPath string StarDictIdxAbsPath string StarDictIfoAbsPath string }
DirItem 词典文件单元,以文件夹为基本单元,一个文件夹代表一个文件 词典类型优先级: 0: mdict: mdx/mdd 1: startdict: dz/ifo/idx 特殊文件 - .dtype 文件: 词典类型文件,可以是 _mdict.dtype 或是 _startdict.dtype 固定名称类型 - _cover.jpg 文件: 词典封面文件,仅支持 jpg 类型 - _dict.toml 文件: 当前词典配置文件,控制词典行为,暂未实现 - _dict.license 文件: 当前词典的授权文件, 通常为 GPL 授权
type GeneralDictionary ¶
type GeneralDictionary interface { // 取得当前词典所有词列表 KeyList() []string // BuildIndex 构建索引 BuildIndex() error // DictType 返回词典类型, 目前仅支持 mdict 和 stardict DictType() DictType // Description 返回词典描述 Description() *PlainDictionaryInfo // Name 返回词典名称(主要是为了解决mdict的外部资源问题) Name() string // Lookup 直接输入 keyword 遍历词典搜索 Lookup(keyword string) ([]byte, error) // LookupResource 搜索词典资源,包括 css/js/图片/字体等, 仅限制支持在词典所在文件夹 LookupResource(keyword string) ([]byte, error) // Locate 使用索引定位词条,并返回 html 释义 Locate(entry *KeyQueryIndex) ([]byte, error) // Search 返回近似词条索引列表,用于后续 Locate Search(keyword string) ([]*KeyQueryIndex, error) }
type ImgType ¶
type ImgType string
const ImgTypeJPG ImgType = "jpg"
const ImgTypePNG ImgType = "png"
type KeyQueryIndex ¶
type KeyQueryIndex struct { IndexType string `json:"index_type"` *MdictKeyWordIndex }
type MdictKeyWordIndex ¶
type MdictKeyWordIndex struct { ID int `json:"id"` KeyWord string `json:"keyword"` RecordLocateStartOffset int64 `json:"record_start_offset"` RecordLocateEndOffset int64 `json:"record_end_offset"` IsUTF16 int `json:"is_utf16"` IsRecordEncrypt int `json:"is_record_encrypt"` IsMDD int `json:"is_mdd"` RecordBlockDataStartOffset int64 `json:"record_block_data_start_offset"` RecordBlockDataCompressSize int64 `json:"record_block_data_compress_size"` RecordBlockDataDeCompressSize int64 `json:"record_block_data_decompress_size"` KeyWordDataStartOffset int64 `json:"keyword_data_start_offset"` KeyWordDataEndOffset int64 `json:"keyword_data_end_offset"` }
type PlainDictionaryInfo ¶
type PlainDictionaryItem ¶
type Resp ¶
func BuildError ¶
func BuildRawError ¶
func BuildSuccess ¶
func BuildSuccess(data interface{}) *Resp
Click to show internal directories.
Click to hide internal directories.