diff --git a/config/application.yaml b/config/application.yaml
index 8bb7d7e..a581c12 100644
--- a/config/application.yaml
+++ b/config/application.yaml
@@ -3,3 +3,4 @@ server:
dir:
root: \Gitlab\note
main: PDF
+message: 阿里云2C2G3M 99元/年,老用户也可以哦
\ No newline at end of file
diff --git a/controller/CategoryController.go b/controller/CategoryController.go
index b984e18..6b6643b 100644
--- a/controller/CategoryController.go
+++ b/controller/CategoryController.go
@@ -3,6 +3,7 @@ package controller
import (
"gin-demo/response"
"gin-demo/util"
+ "html/template"
"os"
"strings"
@@ -31,6 +32,10 @@ func (c CategoryController) Show(ctx *gin.Context) {
}
}
rootDir := viper.GetString("dir.root")
+ message := template.HTML("")
+ if "" != viper.GetString("message") {
+ message = template.HTML(viper.GetString("message"))
+ }
path := rootDir + urlPath
pathInfo, err := os.Stat(path)
listResult := util.GetFileList(path)
@@ -40,18 +45,18 @@ func (c CategoryController) Show(ctx *gin.Context) {
}
if pathInfo.IsDir() {
if urlPath == "/" {
- path = path + viper.GetString("dir.main")
+ path = path + viper.GetString("dir.main")
}
htmlContext := util.GetDirStr(path)
//fmt.Println(htmlContext)
- response.Success(ctx, gin.H{"title": pathInfo.Name(), "htmlContext": htmlContext, "list": listResult})
+ response.Success(ctx, gin.H{"title": pathInfo.Name(), "htmlContext": htmlContext, "list": listResult, "message": message})
} else if strings.HasSuffix(pathInfo.Name(), ".md") {
// 后缀判断
htmlContext := util.GetMdStr(path)
//fmt.Println(htmlContext)
title := pathInfo.Name()
title = strings.ReplaceAll(title, ".md", "")
- response.Success(ctx, gin.H{"title": title, "htmlContext": htmlContext, "list": listResult})
+ response.Success(ctx, gin.H{"title": title, "htmlContext": htmlContext, "list": listResult, "message": message})
} else {
ctx.Header("Cache-Control", "public,s-maxage=300,max-age=31536000")
ctx.File(path)
diff --git a/main.go b/main.go
index 25a2619..257e524 100644
--- a/main.go
+++ b/main.go
@@ -28,6 +28,7 @@ func InitConfig() {
viper.SetConfigType("yml")
viper.AddConfigPath(workDir + "/config")
err := viper.ReadInConfig()
+ viper.WatchConfig()
if err != nil {
panic("")
}
diff --git a/templates/index.html b/templates/index.html
index 37d80d5..f3fb13e 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -66,6 +66,7 @@
overflow-x: auto;
overflow-y: hidden;">
+
{{.message}}
{{.title}}
{{ .htmlContext }}