mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-23 06:32:28 +08:00
chore: update
This commit is contained in:
@@ -30,7 +30,7 @@ func init() {
|
|||||||
// run mode
|
// run mode
|
||||||
mode := config.RunMode(os.Getenv("RUN_MODE"))
|
mode := config.RunMode(os.Getenv("RUN_MODE"))
|
||||||
if !mode.IsRunMode() {
|
if !mode.IsRunMode() {
|
||||||
panic("config: unsupported env RUN_MODE" + mode)
|
panic("config: unsupported env RUN_MODE: " + mode)
|
||||||
}
|
}
|
||||||
logrus.Infof("Run mode:%s", mode)
|
logrus.Infof("Run mode:%s", mode)
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := filepath.Join(dir, "etc", "app.yml")
|
path := filepath.Join(dir, "etc", "app.yml")
|
||||||
|
|
||||||
data, err := os.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func init() {
|
|||||||
// run mode
|
// run mode
|
||||||
mode := config.RunMode(os.Getenv("RUN_MODE"))
|
mode := config.RunMode(os.Getenv("RUN_MODE"))
|
||||||
if !mode.IsRunMode() {
|
if !mode.IsRunMode() {
|
||||||
panic("config: unsupported env RUN_MODE" + mode)
|
panic("config: unsupported env RUN_MODE: " + mode)
|
||||||
}
|
}
|
||||||
logrus.Infof("Run mode:%s", mode)
|
logrus.Infof("Run mode:%s", mode)
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := filepath.Join(WorkDir, "etc", "app.yml")
|
path := filepath.Join(WorkDir, "etc", "app.yml")
|
||||||
|
|
||||||
data, err := os.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func handleAcctLogin(c *gin.Context) {
|
|||||||
|
|
||||||
internal.Ei.Account.LoginIP = c.ClientIP()
|
internal.Ei.Account.LoginIP = c.ClientIP()
|
||||||
internal.Ei.Account.LoginAt = time.Now()
|
internal.Ei.Account.LoginAt = time.Now()
|
||||||
internal.Ei.UpdateAccount(context.Background(), user, map[string]interface{}{
|
internal.Store.UpdateAccount(context.Background(), user, map[string]interface{}{
|
||||||
"login_ip": internal.Ei.Account.LoginIP,
|
"login_ip": internal.Ei.Account.LoginIP,
|
||||||
"login_at": internal.Ei.Account.LoginAt,
|
"login_at": internal.Ei.Account.LoginAt,
|
||||||
})
|
})
|
||||||
@@ -89,7 +89,7 @@ func handleAPIBlogger(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := internal.Ei.UpdateBlogger(context.Background(), map[string]interface{}{
|
err := internal.Store.UpdateBlogger(context.Background(), map[string]interface{}{
|
||||||
"blog_name": bn,
|
"blog_name": bn,
|
||||||
"b_title": bt,
|
"b_title": bt,
|
||||||
"bei_an": ba,
|
"bei_an": ba,
|
||||||
@@ -124,7 +124,7 @@ func handleAPIAccount(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := internal.Ei.UpdateAccount(context.Background(), internal.Ei.Account.Username,
|
err := internal.Store.UpdateAccount(context.Background(), internal.Ei.Account.Username,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"email": e,
|
"email": e,
|
||||||
"phone_n": pn,
|
"phone_n": pn,
|
||||||
@@ -160,7 +160,7 @@ func handleAPIPassword(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
newPwd := tools.EncryptPasswd(internal.Ei.Account.Username, nw)
|
newPwd := tools.EncryptPasswd(internal.Ei.Account.Username, nw)
|
||||||
|
|
||||||
err := internal.Ei.UpdateAccount(context.Background(), internal.Ei.Account.Username,
|
err := internal.Store.UpdateAccount(context.Background(), internal.Ei.Account.Username,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"password": newPwd,
|
"password": newPwd,
|
||||||
})
|
})
|
||||||
@@ -181,7 +181,7 @@ func handleDraftDelete(c *gin.Context) {
|
|||||||
responseNotice(c, NoticeNotice, "参数错误", "")
|
responseNotice(c, NoticeNotice, "参数错误", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = internal.Ei.RemoveArticle(context.Background(), id)
|
err = internal.Store.RemoveArticle(context.Background(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("handleDraftDelete.RemoveArticle: ", err)
|
logrus.Error("handleDraftDelete.RemoveArticle: ", err)
|
||||||
responseNotice(c, NoticeNotice, "删除失败", "")
|
responseNotice(c, NoticeNotice, "删除失败", "")
|
||||||
@@ -310,7 +310,7 @@ func handleAPIPostCreate(c *gin.Context) {
|
|||||||
article.UpdatedAt = time.Now()
|
article.UpdatedAt = time.Now()
|
||||||
}
|
}
|
||||||
// 数据库更新
|
// 数据库更新
|
||||||
err = internal.Ei.UpdateArticle(context.Background(), article.ID, map[string]interface{}{
|
err = internal.Store.UpdateArticle(context.Background(), article.ID, map[string]interface{}{
|
||||||
"title": article.Title,
|
"title": article.Title,
|
||||||
"content": article.Content,
|
"content": article.Content,
|
||||||
"serie_id": article.SerieID,
|
"serie_id": article.SerieID,
|
||||||
@@ -384,7 +384,7 @@ func handleAPISerieCreate(c *gin.Context) {
|
|||||||
responseNotice(c, NoticeNotice, "专题不存在", "")
|
responseNotice(c, NoticeNotice, "专题不存在", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = internal.Ei.UpdateSerie(context.Background(), mid, map[string]interface{}{
|
err = internal.Store.UpdateSerie(context.Background(), mid, map[string]interface{}{
|
||||||
"slug": slug,
|
"slug": slug,
|
||||||
"name": name,
|
"name": name,
|
||||||
"desc": desc,
|
"desc": desc,
|
||||||
@@ -422,7 +422,7 @@ func handleAPITrashDelete(c *gin.Context) {
|
|||||||
responseNotice(c, NoticeNotice, "参数错误", "")
|
responseNotice(c, NoticeNotice, "参数错误", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = internal.Ei.RemoveArticle(context.Background(), id)
|
err = internal.Store.RemoveArticle(context.Background(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responseNotice(c, NoticeNotice, err.Error(), "")
|
responseNotice(c, NoticeNotice, err.Error(), "")
|
||||||
return
|
return
|
||||||
@@ -440,7 +440,7 @@ func handleAPITrashRecover(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
err = internal.Ei.UpdateArticle(context.Background(), id, map[string]interface{}{
|
err = internal.Store.UpdateArticle(context.Background(), id, map[string]interface{}{
|
||||||
"deleted_at": time.Time{},
|
"deleted_at": time.Time{},
|
||||||
"is_draft": true,
|
"is_draft": true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,22 +39,13 @@ var (
|
|||||||
func init() {
|
func init() {
|
||||||
// init timezone
|
// init timezone
|
||||||
var err error
|
var err error
|
||||||
tools.TimeLocation, err = time.LoadLocation(
|
tools.TimeLocation, err = time.LoadLocation(config.Conf.General.Timezone)
|
||||||
config.Conf.General.Timezone)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// init store
|
|
||||||
logrus.Info("store drivers: ", store.Drivers())
|
|
||||||
store, err := store.NewStore(config.Conf.Database.Driver,
|
|
||||||
config.Conf.Database.Source)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
// Ei init
|
// Ei init
|
||||||
Ei = &Cache{
|
Ei = &Cache{
|
||||||
lock: sync.Mutex{},
|
lock: sync.Mutex{},
|
||||||
Store: store,
|
|
||||||
TagArticles: make(map[string]model.SortedArticles),
|
TagArticles: make(map[string]model.SortedArticles),
|
||||||
ArticlesMap: make(map[string]*model.Article),
|
ArticlesMap: make(map[string]*model.Article),
|
||||||
}
|
}
|
||||||
@@ -70,7 +61,6 @@ func init() {
|
|||||||
// Cache 整站缓存
|
// Cache 整站缓存
|
||||||
type Cache struct {
|
type Cache struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
store.Store
|
|
||||||
|
|
||||||
// load from db
|
// load from db
|
||||||
Blogger *model.Blogger
|
Blogger *model.Blogger
|
||||||
@@ -92,7 +82,7 @@ func (c *Cache) AddArticle(article *model.Article) error {
|
|||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
// store
|
// store
|
||||||
err := c.InsertArticle(context.Background(), article, ArticleStartID)
|
err := Store.InsertArticle(context.Background(), article, ArticleStartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -131,7 +121,7 @@ func (c *Cache) DelArticle(id int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// set delete
|
// set delete
|
||||||
err := c.UpdateArticle(context.Background(), id, map[string]interface{}{
|
err := Store.UpdateArticle(context.Background(), id, map[string]interface{}{
|
||||||
"deleted_at": time.Now(),
|
"deleted_at": time.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -147,7 +137,7 @@ func (c *Cache) AddSerie(serie *model.Serie) error {
|
|||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
err := c.InsertSerie(context.Background(), serie)
|
err := Store.InsertSerie(context.Background(), serie)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -166,7 +156,7 @@ func (c *Cache) DelSerie(id int) error {
|
|||||||
if len(serie.Articles) > 0 {
|
if len(serie.Articles) > 0 {
|
||||||
return errors.New("请删除该专题下的所有文章")
|
return errors.New("请删除该专题下的所有文章")
|
||||||
}
|
}
|
||||||
err := c.RemoveSerie(context.Background(), id)
|
err := Store.RemoveSerie(context.Background(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -236,7 +226,7 @@ func (c *Cache) PageArticleBE(se int, kw string, draft, del bool, p,
|
|||||||
search.Fields[store.SearchArticleTitle] = kw
|
search.Fields[store.SearchArticleTitle] = kw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
articles, count, err := c.LoadArticleList(context.Background(), search)
|
articles, count, err := Store.LoadArticleList(context.Background(), search)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
@@ -410,7 +400,7 @@ func (c *Cache) loadOrInit() error {
|
|||||||
BTitle: fmt.Sprintf("%s's Blog", strings.Title(config.Conf.Account.Username)),
|
BTitle: fmt.Sprintf("%s's Blog", strings.Title(config.Conf.Account.Username)),
|
||||||
Copyright: `本站使用「<a href="//creativecommons.org/licenses/by/4.0/">署名 4.0 国际</a>」创作共享协议,转载请注明作者及原网址。`,
|
Copyright: `本站使用「<a href="//creativecommons.org/licenses/by/4.0/">署名 4.0 国际</a>」创作共享协议,转载请注明作者及原网址。`,
|
||||||
}
|
}
|
||||||
created, err := c.LoadInsertBlogger(context.Background(), blogger)
|
created, err := Store.LoadInsertBlogger(context.Background(), blogger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -423,7 +413,7 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Slug: "about",
|
Slug: "about",
|
||||||
CreatedAt: time.Time{}.AddDate(0, 0, 1),
|
CreatedAt: time.Time{}.AddDate(0, 0, 1),
|
||||||
}
|
}
|
||||||
err = c.InsertArticle(context.Background(), about, ArticleStartID)
|
err = Store.InsertArticle(context.Background(), about, ArticleStartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -436,7 +426,7 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Slug: "blogroll",
|
Slug: "blogroll",
|
||||||
CreatedAt: time.Time{}.AddDate(0, 0, 7),
|
CreatedAt: time.Time{}.AddDate(0, 0, 7),
|
||||||
}
|
}
|
||||||
err = c.InsertArticle(context.Background(), blogroll, ArticleStartID)
|
err = Store.InsertArticle(context.Background(), blogroll, ArticleStartID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -449,13 +439,13 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Username: config.Conf.Account.Username,
|
Username: config.Conf.Account.Username,
|
||||||
Password: pwd,
|
Password: pwd,
|
||||||
}
|
}
|
||||||
_, err = c.LoadInsertAccount(context.Background(), account)
|
_, err = Store.LoadInsertAccount(context.Background(), account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.Account = account
|
c.Account = account
|
||||||
// series
|
// series
|
||||||
series, err := c.LoadAllSerie(context.Background())
|
series, err := Store.LoadAllSerie(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -466,7 +456,7 @@ func (c *Cache) loadOrInit() error {
|
|||||||
Limit: 9999,
|
Limit: 9999,
|
||||||
Fields: map[string]interface{}{store.SearchArticleDraft: false},
|
Fields: map[string]interface{}{store.SearchArticleDraft: false},
|
||||||
}
|
}
|
||||||
articles, _, err := c.LoadArticleList(context.Background(), search)
|
articles, _, err := Store.LoadArticleList(context.Background(), search)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -561,7 +551,7 @@ func (c *Cache) timerClean() {
|
|||||||
|
|
||||||
for now := range ticker.C {
|
for now := range ticker.C {
|
||||||
exp := now.Add(TrashArticleExp)
|
exp := now.Add(TrashArticleExp)
|
||||||
err := c.CleanArticles(context.Background(), exp)
|
err := Store.CleanArticles(context.Background(), exp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("cache.timerClean.CleanArticles: ", err)
|
logrus.Error("cache.timerClean.CleanArticles: ", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/eiblog/eiblog/cmd/eiblog/config"
|
"github.com/eiblog/eiblog/cmd/eiblog/config"
|
||||||
|
"github.com/eiblog/eiblog/cmd/eiblog/handler/internal/store"
|
||||||
"github.com/eiblog/eiblog/pkg/third/disqus"
|
"github.com/eiblog/eiblog/pkg/third/disqus"
|
||||||
"github.com/eiblog/eiblog/pkg/third/es"
|
"github.com/eiblog/eiblog/pkg/third/es"
|
||||||
"github.com/eiblog/eiblog/pkg/third/pinger"
|
"github.com/eiblog/eiblog/pkg/third/pinger"
|
||||||
@@ -15,6 +16,7 @@ var (
|
|||||||
DisqusClient *disqus.DisqusClient
|
DisqusClient *disqus.DisqusClient
|
||||||
QiniuClient *qiniu.QiniuClient
|
QiniuClient *qiniu.QiniuClient
|
||||||
Pinger *pinger.Pinger
|
Pinger *pinger.Pinger
|
||||||
|
Store store.Store
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -23,16 +25,25 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal("init es client: ", err)
|
logrus.Fatal("init es client: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
DisqusClient, err = disqus.NewDisqusClient(config.Conf.Host, config.Conf.Disqus)
|
DisqusClient, err = disqus.NewDisqusClient(config.Conf.Host, config.Conf.Disqus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal("init disqus client: ", err)
|
logrus.Fatal("init disqus client: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
QiniuClient, err = qiniu.NewQiniuClient(config.Conf.Qiniu)
|
QiniuClient, err = qiniu.NewQiniuClient(config.Conf.Qiniu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal("init qiniu client: ", err)
|
logrus.Fatal("init qiniu client: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Pinger, err = pinger.NewPinger(config.Conf.Host, config.Conf.FeedRPC)
|
Pinger, err = pinger.NewPinger(config.Conf.Host, config.Conf.FeedRPC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal("init pinger: ", err)
|
logrus.Fatal("init pinger: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Info("store drivers: ", store.Drivers())
|
||||||
|
Store, err = store.NewStore(config.Conf.Database.Driver, config.Conf.Database.Source)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal("init store: ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func handleAdminPost(c *gin.Context) {
|
|||||||
params := baseBEParams(c)
|
params := baseBEParams(c)
|
||||||
id, err := strconv.Atoi(c.Query("cid"))
|
id, err := strconv.Atoi(c.Query("cid"))
|
||||||
if err == nil && id > 0 {
|
if err == nil && id > 0 {
|
||||||
article, _ := internal.Ei.LoadArticle(context.Background(), id)
|
article, _ := internal.Store.LoadArticle(context.Background(), id)
|
||||||
if article != nil {
|
if article != nil {
|
||||||
params["Title"] = "编辑文章 | " + internal.Ei.Blogger.BTitle
|
params["Title"] = "编辑文章 | " + internal.Ei.Blogger.BTitle
|
||||||
params["Edit"] = article
|
params["Edit"] = article
|
||||||
@@ -169,7 +169,7 @@ func handleDraftDelete(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数错误"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "参数错误"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = internal.Ei.RemoveArticle(context.Background(), id)
|
err = internal.Store.RemoveArticle(context.Background(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "删除错误"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "删除错误"})
|
||||||
return
|
return
|
||||||
@@ -190,7 +190,7 @@ func handleAdminDraft(c *gin.Context) {
|
|||||||
Limit: 9999,
|
Limit: 9999,
|
||||||
Fields: map[string]interface{}{store.SearchArticleDraft: true},
|
Fields: map[string]interface{}{store.SearchArticleDraft: true},
|
||||||
}
|
}
|
||||||
params["List"], _, err = internal.Ei.LoadArticleList(context.Background(), search)
|
params["List"], _, err = internal.Store.LoadArticleList(context.Background(), search)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("handleDraft.LoadDraftArticles: ", err)
|
logrus.Error("handleDraft.LoadDraftArticles: ", err)
|
||||||
c.Status(http.StatusBadRequest)
|
c.Status(http.StatusBadRequest)
|
||||||
@@ -212,7 +212,7 @@ func handleAdminTrash(c *gin.Context) {
|
|||||||
Limit: 9999,
|
Limit: 9999,
|
||||||
Fields: map[string]interface{}{store.SearchArticleTrash: true},
|
Fields: map[string]interface{}{store.SearchArticleTrash: true},
|
||||||
}
|
}
|
||||||
params["List"], _, err = internal.Ei.LoadArticleList(context.Background(), search)
|
params["List"], _, err = internal.Store.LoadArticleList(context.Background(), search)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("handleTrash.LoadArticleList: ", err)
|
logrus.Error("handleTrash.LoadArticleList: ", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ func handleDisqusList(c *gin.Context) {
|
|||||||
} else if internal.DisqusClient.ThreadDetails(artc) == nil {
|
} else if internal.DisqusClient.ThreadDetails(artc) == nil {
|
||||||
dcs.Data.Thread = artc.Thread
|
dcs.Data.Thread = artc.Thread
|
||||||
}
|
}
|
||||||
internal.Ei.UpdateArticle(context.Background(), artc.ID,
|
internal.Store.UpdateArticle(context.Background(), artc.ID,
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"thread": artc.Thread,
|
"thread": artc.Thread,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import (
|
|||||||
|
|
||||||
// RunMode 列表
|
// RunMode 列表
|
||||||
const (
|
const (
|
||||||
RunModeDev RunMode = "dev" // 开发环境
|
RunModeLocal RunMode = "local" // 本地环境
|
||||||
RunModeProd RunMode = "pro" // 生产环境
|
RunModeDev RunMode = "dev" // 开发环境
|
||||||
|
RunModeProd RunMode = "pro" // 生产环境
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunMode 运行模式
|
// RunMode 运行模式
|
||||||
@@ -20,14 +21,9 @@ func (mode RunMode) IsReleaseMode() bool {
|
|||||||
return mode == RunModeProd
|
return mode == RunModeProd
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDevMode 是否时开发模式
|
|
||||||
func (mode RunMode) IsDevMode() bool {
|
|
||||||
return mode == RunModeDev
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsRunMode 是否是runmode
|
// IsRunMode 是否是runmode
|
||||||
func (mode RunMode) IsRunMode() bool {
|
func (mode RunMode) IsRunMode() bool {
|
||||||
return mode == RunModeDev || mode == RunModeProd
|
return mode == RunModeDev || mode == RunModeProd || mode == RunModeLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
// WalkWorkDir walk work dir
|
// WalkWorkDir walk work dir
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
go run cmd/$1/main.go
|
cd cmd/$1 && go run main.go
|
||||||
|
|||||||
Reference in New Issue
Block a user