mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 10:08:03 +08:00
实现文档编辑
This commit is contained in:
@@ -22,4 +22,7 @@ db_password=123456
|
||||
cover=/static/images/book.jpg
|
||||
|
||||
#默认编辑器
|
||||
editor=markdown
|
||||
editor=markdown
|
||||
|
||||
#上传文件的后缀
|
||||
upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif
|
@@ -27,4 +27,7 @@ cover=/static/images/book.jpg
|
||||
avatar=/static/images/headimgurl.jpg
|
||||
|
||||
#默认阅读令牌长度
|
||||
token_size=12
|
||||
token_size=12
|
||||
|
||||
#上传文件的后缀
|
||||
upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif
|
@@ -1,7 +1,10 @@
|
||||
// package conf 为配置相关.
|
||||
package conf
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 登录用户的Session名
|
||||
const LoginSessionName = "LoginSessionName"
|
||||
@@ -53,4 +56,36 @@ func GetTokenSize() int {
|
||||
|
||||
func GetDefaultCover() string {
|
||||
return beego.AppConfig.DefaultString("cover","/static/images/book.jpg")
|
||||
}
|
||||
|
||||
func GetUploadFileExt() []string {
|
||||
ext := beego.AppConfig.DefaultString("upload_file_ext","png|jpg|jpeg|gif|txt|doc|docx|pdf")
|
||||
|
||||
temp := strings.Split(ext,"|")
|
||||
|
||||
exts := make([]string,len(temp))
|
||||
|
||||
i := 0
|
||||
for _,item := range temp {
|
||||
if item != "" {
|
||||
exts[i] = item
|
||||
i++
|
||||
}
|
||||
}
|
||||
return exts
|
||||
}
|
||||
|
||||
func IsAllowUploadFileExt(ext string) bool {
|
||||
|
||||
if strings.HasPrefix(ext,".") {
|
||||
ext = string(ext[1:])
|
||||
}
|
||||
exts := GetUploadFileExt()
|
||||
|
||||
for _,item := range exts {
|
||||
if strings.EqualFold(item,ext) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user