From 4072f42f1b1f6dfbc3e3707cd7e5ef70140d8522 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 29 Mar 2022 10:33:48 +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 | 2 +- routers/search.go | 20 +++++++++++++------- templates/base/head_navbar.tmpl | 4 ++-- templates/base/head_navbar_fluid.tmpl | 4 ++-- templates/base/head_navbar_pro.tmpl | 4 ++-- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/public/home/search.js b/public/home/search.js index 66dcce6c3..4ba0a5ced 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -376,7 +376,7 @@ function getTaskDesc(isZh,key){ function getActiveItem(sort_type){ console.log("currentSearchSortBy=" + currentSearchSortBy + " sort_type=" + sortBy[sort_type]); - if(currentSearchSortBy == sortBy[sort_type]){ + if(currentSearchSortBy == sortBy[sort_type] && currentSearchAscending == sortAscending[sort_type]){ return "active "; }else{ return ""; diff --git a/routers/search.go b/routers/search.go index 6433026d3..3b9035f5b 100644 --- a/routers/search.go +++ b/routers/search.go @@ -554,23 +554,23 @@ func truncLongText(text string, isNeedToDealText bool) string { if end >= stringlen { end = stringlen } - return string(trimFontHtml(textRune[start:end])) + "..." + return trimFontHtml(textRune[start:end]) + "..." } else { - return string(trimFontHtml(textRune[0:200])) + "..." + return trimFontHtml(textRune[0:200]) + "..." } } else { if stringlen > 200 { - return string(trimFontHtml(textRune[0:200])) + "..." + return trimFontHtml(textRune[0:200]) + "..." } else { return text } } } -func trimFontHtml(text []rune) []rune { +func trimFontHtml(text []rune) string { startRune := rune('<') endRune := rune('>') - + count := 0 for i := 0; i < len(text); i++ { if text[i] == startRune { //start < re := false @@ -583,12 +583,18 @@ func trimFontHtml(text []rune) []rune { } if re { //found > i = j + count++ } else { - return text[0:i] + if count%2 == 1 { + return string(text[0:i]) + "" + } else { + return string(text[0:i]) + } + } } } - return text + return string(text) } func trimHrefHtml(result string) string { diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index f895613e9..18cf3ce0e 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -97,7 +97,7 @@