更新搜索框
parent
6e70a1d4df
commit
9c0d18a6d0
|
@ -14,6 +14,6 @@
|
||||||
"documentGitUrl": "https://github.com/jixishi/blog_docs.git",
|
"documentGitUrl": "https://github.com/jixishi/blog_docs.git",
|
||||||
"themePath": "/blog",
|
"themePath": "/blog",
|
||||||
"themeColor": "#2196f3",
|
"themeColor": "#2196f3",
|
||||||
"dashboard": "adminjxs",
|
"dashboard": "/adminjxs",
|
||||||
"themeOption": ["#673ab7","#f44336","#9c27b0","#2196f3","#607d8b","#795548"]
|
"themeOption": ["#673ab7","#f44336","#9c27b0","#2196f3","#607d8b","#795548"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ func Index(w http.ResponseWriter, r *http.Request) {
|
||||||
search := r.Form.Get("search")
|
search := r.Form.Get("search")
|
||||||
category := r.Form.Get("category")
|
category := r.Form.Get("category")
|
||||||
tag := r.Form.Get("tag")
|
tag := r.Form.Get("tag")
|
||||||
|
|
||||||
if search != "" || category != "" || tag != "" {
|
if search != "" || category != "" || tag != "" {
|
||||||
articles = models.ArticleSearch(&articles, search, category, tag)
|
articles = models.ArticleSearch(&articles, search, category, tag)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<span>{{ .Config.Icp }}</span><span class="footer-divider"> | </span>
|
<span>{{ .Config.Icp }}</span><span class="footer-divider"> | </span>
|
||||||
<span>
|
<span>
|
||||||
© 2018 - 2022 {{ .Config.Author }}
|
© 2018 - <script>document.write(new Date().getFullYear())</script> {{ .Config.Author }}
|
||||||
Powered By <a href="{{ .Config.AppRepository }}" target="_blank"> {{ .Config.AppName }} </a>
|
Powered By <a href="{{ .Config.AppRepository }}" target="_blank"> {{ .Config.AppName }} </a>
|
||||||
</span>
|
</span>
|
||||||
<span id="busuanzi_container_site_pv" style='display:none'>
|
<span id="busuanzi_container_site_pv" style='display:none'>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{{define "header"}}
|
{{define "header"}}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-cn">
|
<html lang="zh-cn">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
@ -10,19 +9,12 @@
|
||||||
<meta name="Keywords" content="{{ .Config.HtmlKeywords }}" />
|
<meta name="Keywords" content="{{ .Config.HtmlKeywords }}" />
|
||||||
<meta name="description" content="{{ .Config.HtmlDescription }}" />
|
<meta name="description" content="{{ .Config.HtmlDescription }}" />
|
||||||
<title>{{ .Title }} - {{ .Config.SiteName }}</title>
|
<title>{{ .Title }} - {{ .Config.SiteName }}</title>
|
||||||
<style>
|
<style>:root{--primary: {{ .Config.ThemeColor }}}</style>
|
||||||
:root {
|
|
||||||
--primary: {
|
|
||||||
{
|
|
||||||
.Config.ThemeColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<link rel="stylesheet" href="/public/css/app.css">
|
<link rel="stylesheet" href="/public/css/app.css">
|
||||||
<link href="/public/css/prism.css" rel="stylesheet" />
|
<link href="/public/css/prism.css" rel="stylesheet" />
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css">
|
||||||
<script src="/public/js/marked.min.js"></script>
|
<script src="/public/js/marked.min.js"></script>
|
||||||
|
<script async src="https://umami.starss.cc/script.js" data-website-id="594ff1a5-e8ce-47b1-8558-88cb3f9d7704"></script>
|
||||||
<script async src="https://busuanzi.icodeq.com/busuanzi.pure.mini.js"></script>
|
<script async src="https://busuanzi.icodeq.com/busuanzi.pure.mini.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function obj2StrParams(obj,firstStr = '?') {
|
function obj2StrParams(obj,firstStr = '?') {
|
||||||
|
@ -34,7 +26,6 @@
|
||||||
}
|
}
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentUrlToParams(key = null) {
|
function currentUrlToParams(key = null) {
|
||||||
let paramsUrl = (window.location.href).split('?');
|
let paramsUrl = (window.location.href).split('?');
|
||||||
|
|
||||||
|
@ -49,13 +40,23 @@
|
||||||
if(key)return paramsData.hasOwnProperty(key) ? paramsData[key] : null;
|
if(key)return paramsData.hasOwnProperty(key) ? paramsData[key] : null;
|
||||||
return paramsData;
|
return paramsData;
|
||||||
}
|
}
|
||||||
|
function searchArticle() {
|
||||||
|
var searchKey = document.getElementById('search-input').value;
|
||||||
|
searchKey = searchKey.replace(/^\s+|\s+$/g,"")
|
||||||
|
if("" === searchKey){return}
|
||||||
|
|
||||||
|
window.location.href = '/?search=' + searchKey
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="theme{{ .Config.ThemeColor }}">
|
<body class="theme{{ .Config.ThemeColor }}">
|
||||||
<nav class="head">
|
<nav class="head">
|
||||||
<div class="container head-content">
|
<div class="container head-content">
|
||||||
<div class="logo">{{ .Config.SiteName }}</div>
|
<div class="logo">{{ .Config.SiteName }}</div>
|
||||||
|
<div class="search-box">
|
||||||
|
<input id="search-input" class="search-input" type="text" placeholder="搜索...">
|
||||||
|
<img onclick="searchArticle()" class="search-icon" src="/public/img/search.svg" alt="">
|
||||||
|
</div>
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
<a href="/blog">Blog</a>
|
<a href="/blog">Blog</a>
|
||||||
<a href="/categories">Categories</a>
|
<a href="/categories">Categories</a>
|
||||||
|
|
Loading…
Reference in New Issue