40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"blog/config"
|
|
"blog/models"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func Memos(w http.ResponseWriter, r *http.Request) {
|
|
if err := r.ParseForm(); err != nil {
|
|
http.Error(w, "参数解析错误", http.StatusInternalServerError)
|
|
}
|
|
fun := r.Form.Get("name")
|
|
switch fun {
|
|
case "talk":
|
|
Template := models.Template.Talk
|
|
qq := "https://q1.qlogo.cn/g?b=qq&nk=" + config.Cfg.Qq + "&s=5"
|
|
Template.WriteData(w, models.BuildViewData("Talk", map[string]interface{}{
|
|
"url": config.Cfg.MemosURL,
|
|
"user": config.Cfg.MemosUser,
|
|
"tag": config.Cfg.MemosTalkTag,
|
|
"author": config.Cfg.Author,
|
|
"qq": qq,
|
|
}))
|
|
case "album":
|
|
Template := models.Template.Album
|
|
tag := strings.Split(config.Cfg.MemosAlbumTag, ",")
|
|
Template.WriteData(w, models.BuildViewData("Album", map[string]interface{}{
|
|
"url": config.Cfg.MemosURL,
|
|
"user": config.Cfg.MemosUser,
|
|
"image": tag[0],
|
|
"video": tag[1],
|
|
}))
|
|
default:
|
|
http.Error(w, "无法解析页面请求"+fun, http.StatusInternalServerError)
|
|
}
|
|
|
|
}
|