feat:实现Modules支持

3.0.0
lifeilin01 2020-06-14 14:59:50 +08:00
parent 7104698000
commit 693de8f293
4 changed files with 18 additions and 18 deletions

View File

@ -286,7 +286,7 @@ func ResolveCommand(args []string) {
if err := flagSet.Parse(args); err != nil {
log.Fatal("解析命令失败 ->", err)
}
fmt.Println(conf.WorkingDirectory)
if conf.WorkingDirectory == "" {
if p, err := filepath.Abs(os.Args[0]); err == nil {
conf.WorkingDirectory = filepath.Dir(p)
@ -519,7 +519,7 @@ func init() {
conf.ConfigurationFile = configPath
}
if err := gocaptcha.ReadFonts(conf.WorkingDir("static", "fonts"), ".ttf"); err != nil {
log.Fatal("读取字体文件失败 ->", err)
beego.Error("读取字体文件失败 ->", err)
}
gob.Register(models.Member{})

View File

@ -2,13 +2,14 @@
package conf
import (
"os/exec"
"strings"
"github.com/astaxie/beego"
"strconv"
"path/filepath"
"os"
"fmt"
"github.com/astaxie/beego"
"os"
"path/filepath"
"strconv"
)
// 登录用户的Session名
@ -158,7 +159,7 @@ func GetExportProcessNum() int {
if exportProcessNum <= 0 || exportProcessNum > 4 {
exportProcessNum = 1
}
return exportProcessNum;
return exportProcessNum
}
//导出项目队列的并发数量
@ -168,7 +169,7 @@ func GetExportLimitNum() int {
if exportLimitNum < 0 {
exportLimitNum = 1
}
return exportLimitNum;
return exportLimitNum
}
//等待导出队列的长度
@ -210,7 +211,7 @@ func IsAllowUploadFileExt(ext string) bool {
//重写生成URL的方法加上完整的域名
func URLFor(endpoint string, values ...interface{}) string {
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
pathUrl := beego.URLFor(endpoint, values ...)
pathUrl := beego.URLFor(endpoint, values...)
if baseUrl == "" {
baseUrl = BaseUrl
@ -224,12 +225,12 @@ func URLFor(endpoint string, values ...interface{}) string {
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
return baseUrl + "/" + pathUrl
}
return baseUrl + beego.URLFor(endpoint, values ...)
return baseUrl + beego.URLFor(endpoint, values...)
}
func URLForNotHost(endpoint string,values ...interface{}) string {
func URLForNotHost(endpoint string, values ...interface{}) string {
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
pathUrl := beego.URLFor(endpoint, values ...)
pathUrl := beego.URLFor(endpoint, values...)
if baseUrl == "" {
baseUrl = "/"
@ -243,7 +244,7 @@ func URLForNotHost(endpoint string,values ...interface{}) string {
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
return baseUrl + "/" + pathUrl
}
return baseUrl + beego.URLFor(endpoint, values ...)
return baseUrl + beego.URLFor(endpoint, values...)
}
func URLForWithCdnImage(p string) string {
@ -344,12 +345,12 @@ func WorkingDir(elem ...string) string {
}
func init() {
if p, err := exec.LookPath(os.Args[0]); err == nil {
WorkingDirectory = p
}
if p, err := filepath.Abs("./conf/app.conf"); err == nil {
ConfigurationFile = p
}
if p, err := filepath.Abs("./"); err == nil {
WorkingDirectory = p
}
if p, err := filepath.Abs("./runtime/logs"); err == nil {
LogFile = p
}

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/howeyc/fsnotify v0.9.0
github.com/kardianos/service v1.1.0
github.com/lifei6671/gocaptcha v0.1.1
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/russross/blackfriday v1.5.2
github.com/russross/blackfriday/v2 v2.0.1

View File

@ -16,7 +16,6 @@ import (
)
func main() {
if len(os.Args) >= 3 && os.Args[1] == "service" {
if os.Args[2] == "install" {
daemon.Install()