From 3c779296acda5ffdec10aa7e8984bc905c22425f Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 18 Mar 2022 11:38:16 +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 | 6 ++---- routers/search.go | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index 206ede251..fcae4abe6 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -391,8 +391,7 @@ function displayOrgResult(page,jsonResult,onlyReturnNum,keyword){ html +=" " + "" + recordMap["website"] + ""; } html +=" 加入于 "; - var userAddDate = new Date(recordMap["created_unix"]*1000); - html += monthDisplay[userAddDate.getMonth()] + " " + userAddDate.getDay() + " " + userAddDate.getFullYear(); + html += recordMap["add_time"] html +="

"; html +=" "; html +=" "; @@ -436,8 +435,7 @@ function displayUserResult(page,jsonResult,onlyReturnNum,keyword){ html +="

"; html +=" " + recordMap["email"]; html +=" 加入于 "; - var userAddDate = new Date(recordMap["created_unix"]*1000); - html += monthDisplay[userAddDate.getMonth()] + " " + userAddDate.getDay() + " " + userAddDate.getFullYear(); + html += recordMap["add_time"] html +="

"; html +=" "; html +=" "; diff --git a/routers/search.go b/routers/search.go index 9ca0a9ff0..92d3824bf 100644 --- a/routers/search.go +++ b/routers/search.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/timeutil" "github.com/olivere/elastic/v7" ) @@ -642,6 +643,7 @@ func makeUserOrOrgResult(sRes *elastic.SearchResult, Key string, ctx *context.Co record["avatar"] = strings.TrimRight(setting.AppSubURL, "/") + "/user/avatar/" + recordSource["name"].(string) + "/" + strconv.Itoa(-1) record["updated_unix"] = recordSource["updated_unix"] record["created_unix"] = recordSource["created_unix"] + record["add_time"] = getAddTime(recordSource["created_unix"].(int64)) result = append(result, record) } else { log.Info("deal user source error," + err.Error()) @@ -658,6 +660,11 @@ func makeUserOrOrgResult(sRes *elastic.SearchResult, Key string, ctx *context.Co return returnObj } +func getAddTime(time int64) string { + t := timeutil.TimeStamp(time) + return t.FormatShort() +} + func searchDataSet(ctx *context.Context, TableName string, Key string, Page int, PageSize int, OnlyReturnNum bool) { /* 数据集,ES名称:dataset-es-index