浏览代码

优化首页显示效果

Minho 7 年之前
父节点
当前提交
ddbd33a38e
共有 3 个文件被更改,包括 11 次插入2 次删除
  1. 5 0
      controllers/base.go
  2. 4 0
      static/css/main.css
  3. 2 2
      views/widgets/header.tpl

+ 5 - 0
controllers/base.go

@@ -23,6 +23,11 @@ type BaseController struct {
 func (c *BaseController) Prepare() {
 	c.Data["SiteName"] = "MinDoc"
 	c.Data["Member"] = models.Member{}
+	controller,action := c.GetControllerAndAction()
+
+	c.Data["ActionName"] = action
+	c.Data["ControllerName"] = controller
+
 	c.EnableAnonymous = false
 	c.EnableDocumentHistory = false
 

+ 4 - 0
static/css/main.css

@@ -65,6 +65,10 @@ textarea{
     white-space:nowrap;
     overflow: hidden;
 }
+.manual-header .navbar-nav li.active a{
+    background-color: #009a61;
+    color: #ffffff;
+}
 .manual-reader .slidebar {
     margin: 5px 10px 0 0;
 }

+ 2 - 2
views/widgets/header.tpl

@@ -10,10 +10,10 @@
             </a>
             <nav class="collapse navbar-collapse col-sm-10">
                 <ul class="nav navbar-nav">
-                    <li>
+                    <li {{if eq .ControllerName "HomeController"}}class="active"{{end}}>
                         <a href="{{urlfor "HomeController.Index" }}" title="首页">首页</a>
                     </li>
-                    <li>
+                    <li {{if eq .ControllerName "LabelController"}}class="active"{{end}}>
                         <a href="{{urlfor "LabelController.List" }}" title="标签">标签</a>
                     </li>
                 </ul>