Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 3 years ago
parent
commit
4f929a1c4d
2 changed files with 26 additions and 15 deletions
  1. +23
    -7
      public/home/search.js
  2. +3
    -8
      routers/search.go

+ 23
- 7
public/home/search.js View File

@@ -188,7 +188,7 @@ function displayPrResult(page,jsonResult,onlyReturnNum,keyword){
$('#obj_desc').text("合并请求");
$('#child_total').text(total);

setIssueOrPrInnerHtml(data);
setIssueOrPrInnerHtml(data,"pulls");
}
}

@@ -235,6 +235,22 @@ var taskDesc={
"speech_synthesis":"语音合成"
};

function getCategoryDesc(key){
var re = categoryDesc[key];
if(isEmpty(re)){
return key;
}
return re;
}

function getTaskDesc(key){
var re = categoryDesc[key];
if(isEmpty(re)){
return key;
}
return re;
}

function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){
var data = jsonResult.Result;
var total = jsonResult.Total;
@@ -257,10 +273,10 @@ function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){
html += " <div class=\"content\">";
html += " <div class=\"ui right metas\">" ;
if(!isEmpty(recordMap["category"])){
html += " <span class=\"text grey\"><svg class=\"svg octicon-tasklist\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tasklist\" /></svg> " +recordMap["category"]+ "</span>";
html += " <span class=\"text grey\"><svg class=\"svg octicon-tasklist\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tasklist\" /></svg> " + getCategoryDesc(recordMap["category"]) + "</span>";
}
if(!isEmpty(recordMap["task"])){
html += " <span class=\"text grey\"><svg class=\"svg octicon-tag\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tag\" /></svg>" +recordMap["task"]+ "</span>";
html += " <span class=\"text grey\"><svg class=\"svg octicon-tag\" width=\"16\" height=\"16\" aria-hidden=\"true\"><use xlink:href=\"#octicon-tag\" /></svg>" + getTaskDesc(recordMap["task"]) + "</span>";
}
html += " <span class=\"text grey\"><i class=\"ri-fire-line\"></i> " +recordMap["download_times"] + "</span> ";
html +=" </div>";
@@ -370,7 +386,7 @@ function displayUserResult(page,jsonResult,onlyReturnNum,keyword){
}
}

function setIssueOrPrInnerHtml(data){
function setIssueOrPrInnerHtml(data,path){
var sortHtml = "";
sortHtml +="<a class=\"item\" href=\"javascript:searchItem(2,21);\" tabindex=\"-1\" role=\"menuitem\" id=\"menuitem_1\">最近更新</a>";
document.getElementById("sort_type").innerHTML=sortHtml;
@@ -388,7 +404,7 @@ function setIssueOrPrInnerHtml(data){
html += " <p class=\"has-emoji\"> " + recordMap["content"] + "</p>";
html +=" <p class=\"time\">";
html +=" <i class=\"ri-code-box-line\"></i>";
html +=" <a class=\"am-text grey\" href=\"/" + recordMap["repoUrl"] +"/" + recordMap["id"] + "\"> " + recordMap["repoUrl"] +"#" + recordMap["id"] + "</a>";
html +=" <a class=\"am-text grey\" href=\"/" + recordMap["repoUrl"] +"/" + path + "/" + recordMap["id"] + "\"> " + recordMap["repoUrl"] +"#" + recordMap["id"] + "</a>";
html +=" <i class=\"ri-information-line am-ml-10\"></i> ";
if(isEmpty(recordMap["is_closed"]) || recordMap["is_closed"]=="f"){
html += "关闭";
@@ -415,7 +431,7 @@ function displayIssueResult(page,jsonResult,onlyReturnNum,keyword){
$('#obj_desc').text("任务");
$('#child_total').text(total);

setIssueOrPrInnerHtml(data);
setIssueOrPrInnerHtml(data,"issues");
}
}

@@ -473,7 +489,7 @@ function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){
}
html +=" </div>";
html +=" <p class=\"time\">";
html +=" <i class=\"icon fa-eye\">" +recordMap["num_watches"] + "&nbsp;&nbsp;</i><i class=\"ri-star-line\"></i>" + recordMap["num_stars"] + "&nbsp;&nbsp;<i class=\"ri-git-branch-line am-ml-10\"></i>" + recordMap["num_forks"] +"&nbsp;&nbsp;";
html +=" <i class=\"icon fa-eye\">" +recordMap["num_watches"] + "</i>&nbsp;&nbsp;<i class=\"ri-star-line\"></i>" + recordMap["num_stars"] + "&nbsp;&nbsp;<i class=\"ri-git-branch-line am-ml-10\"></i>" + recordMap["num_forks"] +"&nbsp;&nbsp;";
html +="&nbsp;&nbsp;&nbsp;&nbsp;最后更新于 <span class=\"time-since poping up\" title=\"\" data-content=\"\" data-variation=\"inverted tiny\">" + getTime(recordMap["updated_unix"],currentTime) +"</span>";
if(!isEmpty(recordMap["lang"])){
html +=" <span class=\"text grey am-ml-10\"><i class=\"color-icon\" style=\"background-color: #3572A5\"></i>" + recordMap["lang"] + "</span>";


+ 3
- 8
routers/search.go View File

@@ -194,8 +194,6 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool)
}

record["hightTopics"] = jsonStrToArray(getLabelValue("topics", recordSource, hit.Highlight))
//log.Info("hight[\"topics\"]=" + getLabelValue("topics", recordSource, hit.Highlight))

record["num_watches"] = recordSource["num_watches"]
record["num_stars"] = recordSource["num_stars"]
record["num_forks"] = recordSource["num_forks"]
@@ -205,11 +203,6 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool)
log.Info("topicsStr=" + topicsStr)
if topicsStr != "null" {
record["topics"] = jsonStrToArray(topicsStr)
// topicsStr = strings.Replace(topicsStr, "\"", "", -1)
// topicsStr = topicsStr[1 : len(topicsStr)-1]
// log.Info("record[\"topics\"]=" + topicsStr)
// topicstmp := strings.Split(topicsStr, ",")
// record["topics"] = topicstmp
}
}
if recordSource["avatar"] != nil {
@@ -478,7 +471,7 @@ func makeDatasetResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum boo
} else {
record["description"] = ""
}
record["file_name"] = recordSource["file_name"]
record["file_name"] = getLabelValue("file_name", recordSource, hit.Highlight)
record["task"] = recordSource["task"]
record["download_times"] = recordSource["download_times"]
record["created_unix"] = recordSource["created_unix"]
@@ -660,6 +653,8 @@ func searchPR(ctx *context.Context, TableName string, Key string, Page int, Page
}
res, err := client.Search(TableName).Query(boolQ).Sort(SortBy, ascending).From((Page - 1) * PageSize).Size(PageSize).Highlight(queryHighlight("name", "content", "comment")).Do(ctx.Req.Context())
if err == nil {
searchJson, _ := json.Marshal(res)
log.Info("searchJson=" + string(searchJson))
result := makeIssueResult(res, Key, OnlyReturnNum)
ctx.JSON(200, result)
} else {


Loading…
Cancel
Save