From 77a2cb0cdbdb4bb0f6887f80e2e13dc05a982d7c Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 18 Mar 2022 15:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/search.js | 18 +++++++++++------- routers/search.go | 5 +++++ templates/explore/search_new.tmpl | 2 ++ web_src/less/openi.less | 11 ++++++++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index 98d8dae67..948f8f2ee 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -139,8 +139,8 @@ function search(){ if(currentSearchTableName != "dataset"){ doSearch("dataset",currentSearchKeyword,1,pageSize,true,"",false); } - if(currentSearchTableName != "dataset"){ - doSearch("dataset",currentSearchKeyword,1,pageSize,true,"",false); + if(currentSearchTableName != "pr"){ + doSearch("pr",currentSearchKeyword,1,pageSize,true,"",false); } } } @@ -487,7 +487,7 @@ function setIssueOrPrInnerHtml(data,path){ if(recordMap["is_closed"] != null && (!(recordMap["is_closed"]) || recordMap["is_closed"]=="f")){ html += "开启中"; }else{ - html += "关闭"; + html += "已关闭"; } html +="      " + recordMap["num_comments"]; html +="     最后更新于 " + getTime(recordMap["updated_unix"],currentTime) +""; @@ -640,7 +640,7 @@ var repoAndOrgZH={ "5":"分钟前", "6":"秒前", "7":"天前", - "8":"月前", + "8":"个月前", "9":"年前" }; @@ -691,18 +691,22 @@ function page(current){ function goPage(){ var goNum = $('#inputpage').val(); - if (goNum<=0){ - alert("请输入大于0的数值"); + showTip("请输入大于0的数值","warning"); } else if(goNum<=totalPage){ page(goNum); } else{ - alert("不能超出总页数!"); + showTip("不能超出总页数!","warning"); } } + function showTip(tip, type) { + var $tip = $('#tipmsg'); + $tip.stop(true).prop('class', 'alert alert-' + type).html(tip).css('margin-left', - $tip.outerWidth() / 2).fadeIn(500).delay(2000).fadeOut(500); + } + function setPage(currentPage){ console.log("totalPage=" + totalPage); var html =""; diff --git a/routers/search.go b/routers/search.go index f76b1ca19..f1732a674 100644 --- a/routers/search.go +++ b/routers/search.go @@ -350,6 +350,7 @@ func makePrivateRepo(repos models.RepositoryList, res *SearchRes, keyword string record["avatar"] = setting.RepositoryAvatarFallbackImage } record["updated_unix"] = repo.UpdatedUnix + record["updated_html"] = timeutil.TimeSinceUnix(repo.UpdatedUnix, "zh-CN") lang, err := repo.GetTopLanguageStats(1) if err == nil && len(lang) > 0 { record["lang"] = lang[0].Language @@ -440,6 +441,10 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool) } } record["updated_unix"] = recordSource["updated_unix"] + timeInt, err := strconv.ParseInt(recordSource["updated_unix"].(string), 10, 64) + if err == nil { + record["updated_html"] = timeutil.TimeSinceUnix(timeutil.TimeStamp(timeInt), "zh-CN") + } record["lang"] = recordSource["lang"] record["is_private"] = false result = append(result, record) diff --git a/templates/explore/search_new.tmpl b/templates/explore/search_new.tmpl index ad0537b5a..7d043f102 100644 --- a/templates/explore/search_new.tmpl +++ b/templates/explore/search_new.tmpl @@ -102,4 +102,6 @@
+
+ {{template "base/footer" .}} \ No newline at end of file diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 947cc32a2..4bca15af5 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -876,4 +876,13 @@ display: block; font-size: 24px; text-align: left; font-family: SourceHanSansSC-medium; - } \ No newline at end of file + } + + + #tipmsg { + position: absolute; + top: 50px; + left: 50%; + display: none; + z-index: 9999; +} \ No newline at end of file