Skip to content

Commit

Permalink
修正搜索bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ldqk committed Dec 2, 2021
1 parent 207726f commit d5d7c62
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Masuit.MyBlogs.Core/Controllers/PostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task<ActionResult> Details(int id, string kw)

if (!HttpContext.Request.IsRobot() && string.IsNullOrEmpty(HttpContext.Session.Get<string>("post" + id)))
{
HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.RecordPostVisit), args: new dynamic[] { id, ClientIP, Request.Headers[HeaderNames.Referer].ToString(), HttpUtility.UrlDecode(Request.Scheme + "://" + Request.Host + Request.Path + Request.QueryString), Request.Headers.ToJsonString() });
HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.RecordPostVisit), args: new dynamic[] { id, ClientIP, Request.Headers[HeaderNames.Referer].ToString(), HttpUtility.UrlDecode(Request.Scheme + "://" + Request.Host + Request.Path + Request.QueryString) });
HttpContext.Session.Set("post" + id, id.ToString());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Masuit.MyBlogs.Core/Controllers/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task<ActionResult> Save(string sets)
var dic = settings.ToDictionary(s => s.Name, s => s.Value); //同步设置
foreach (var (key, value) in dic)
{
CommonHelper.SystemSettings.AddOrUpdate(key, value);
CommonHelper.SystemSettings[key]= value;
}

return ResultData(null, b, b ? "设置保存成功!" : "设置保存失败!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void PublishPost(Post p)
/// <param name="refer"></param>
/// <param name="url"></param>
/// <param name="headers"></param>
public void RecordPostVisit(int pid, string ip, string refer, string url, string headers)
public void RecordPostVisit(int pid, string ip, string refer, string url)
{
var time = DateTime.Now.AddMonths(-3);
_recordService.GetQuery(b => b.Time < time).DeleteFromQuery();
Expand All @@ -130,7 +130,6 @@ public void RecordPostVisit(int pid, string ip, string refer, string url, string
Referer = refer,
Location = ip.GetIPLocation(),
Time = DateTime.Now,
RequestHeader = headers,
RequestUrl = url,
PostId = pid
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface IHangfireBackJob
/// <param name="ip"></param>
/// <param name="refer"></param>
/// <param name="url"></param><param name="headers"></param>
void RecordPostVisit(int pid, string ip, string refer, string url, string headers);
void RecordPostVisit(int pid, string ip, string refer, string url);

/// <summary>
/// 每日任务
Expand Down
2 changes: 0 additions & 2 deletions src/Masuit.MyBlogs.Core/Models/Entity/PostVisitRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class PostVisitRecord : BaseEntity

public string RequestUrl { get; set; }

public string RequestHeader { get; set; }

public DateTime Time { get; set; }
}
}
19 changes: 1 addition & 18 deletions src/Masuit.MyBlogs.Core/Views/Post/PostVisitRecordInsight.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
<link href="/Assets/layui/css/layui.min.css" media="all" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/abodelot/jquery.json-viewer@master/json-viewer/jquery.json-viewer.css" media="all" rel="stylesheet">
<style>
.mp-results.mp-bottomleft {
top: unset !important;
Expand All @@ -34,13 +33,8 @@
<mini-profiler max-traces="5" />
</body>
</html>
<script type="text/html" id="actionButton">
<a class="layui-btn layui-btn-xs" lay-event="showjson">查看</a>
</script>
<script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
<script src="/Assets/layui/layui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/abodelot/jquery.json-viewer@master/json-viewer/jquery.json-viewer.js" type="text/javascript"></script>
<script>
layui.use('table', function() {
var table = layui.table;
Expand All @@ -54,8 +48,7 @@
{ field: 'Location', title: '位置和网络', align: 'center'},
{ field: 'RequestUrl', title: '请求URL', align: 'center' },
{ field: 'Referer', title: '页面来源', align: 'center', event: 'visit' },
{ field: 'Time', title: '访问时间', align: 'center',width:180 },
{ title:'请求头', toolbar: '#actionButton',width:80 }
{ field: 'Time', title: '访问时间', align: 'center',width:180 }
]
],
page: true,
Expand All @@ -81,16 +74,6 @@
if(obj.event === 'visit'){
window.open(data.Referer);
}
if(obj.event === 'showjson'){
layer.open({
type: 1,
area: ['600px', '80%'], //宽高
content: ""+data.RequestHeader
});
$('.layui-layer-content').jsonViewer(eval("("+data.RequestHeader+")"), {withQuotes: true, withLinks: true});
$('.layui-layer-content').css("word-wrap"," break-word");
}
});
var $ = layui.$;
Expand Down
3 changes: 0 additions & 3 deletions src/Masuit.MyBlogs.Core/Views/Search/Search.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
<div class="col-md-6">
<a asp-controller="Post" asp-action="Details" asp-route-id="@p.Id" class="search-link" target="_blank">@(Context.Request.Scheme + "://" + Context.Request.Host + "/" + p.Id)</a>
</div>
<div class="col-md-6 pull-right text-right">
@p.CommentCount 评论 | @p.TotalViewCount 浏览
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Masuit.MyBlogs.Core/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
</ul>
</nav>
<div id="cd-search" class="cd-search">
<form method="get" asp-controller="Search" asp-action="Search">
<form method="get" action="/search">
<input type="search" name="wd" placeholder="请在此处输入您想要的搜索的关键词,支持部分指令:intitle,content,如:intitle:会声会影 content:懒得勤快,指令支持组合">
</form>
</div>
Expand Down

0 comments on commit d5d7c62

Please sign in to comment.