|
@@ -1,9 +1,19 @@
|
|
package front
|
|
package front
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
+ elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/jylabutil"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/public"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
|
+ "github.com/mozillazg/go-pinyin"
|
|
"jy/src/jfw/config"
|
|
"jy/src/jfw/config"
|
|
"jy/src/jfw/site/jySchool"
|
|
"jy/src/jfw/site/jySchool"
|
|
"jy/src/jfw/wx"
|
|
"jy/src/jfw/wx"
|
|
@@ -13,17 +23,6 @@ import (
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
- "unicode"
|
|
|
|
-
|
|
|
|
- util "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
|
- elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
|
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/jylabutil"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/public"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
const (
|
|
const (
|
|
@@ -929,7 +928,7 @@ func getLetterMap(nameArr []string) []*hotKeyWord {
|
|
if !isNormal {
|
|
if !isNormal {
|
|
nameArr2 = append(nameArr2, v1)
|
|
nameArr2 = append(nameArr2, v1)
|
|
nameArr3 = append(nameArr3, fmt.Sprintf(`"%s"`, v1))
|
|
nameArr3 = append(nameArr3, fmt.Sprintf(`"%s"`, v1))
|
|
- letter := getFirstLetter(v1)
|
|
|
|
|
|
+ letter := getFirstChar(v1)
|
|
nameArr4 = append(nameArr4, fmt.Sprintf(`("%s", "%s", 2)`, v1, letter))
|
|
nameArr4 = append(nameArr4, fmt.Sprintf(`("%s", "%s", 2)`, v1, letter))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -952,17 +951,33 @@ func getLetterMap(nameArr []string) []*hotKeyWord {
|
|
return data
|
|
return data
|
|
}
|
|
}
|
|
|
|
|
|
-// 获取字符串的首字母大写形式
|
|
|
|
-func getFirstLetter(s string) string {
|
|
|
|
- words := strings.Fields(s) // 将字符串分割成单词
|
|
|
|
- var result string
|
|
|
|
- for _, word := range words {
|
|
|
|
- firstChar := []rune(word)[0] // 获取单词的第一个字符
|
|
|
|
|
|
+// 获取单词的首字母大写
|
|
|
|
+func getFirstChar(word string) string {
|
|
|
|
+ firstChar := string(word[0])
|
|
|
|
|
|
- // 检查字符是否为汉字或英文字母
|
|
|
|
- if unicode.Is(unicode.Han, firstChar) || unicode.IsLetter(firstChar) {
|
|
|
|
- result += strings.ToUpper(string(firstChar))
|
|
|
|
- }
|
|
|
|
|
|
+ // 检查第一个字符是否是英文字母
|
|
|
|
+ if isEnglishLetter(firstChar) {
|
|
|
|
+ return strings.ToUpper(firstChar)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 转换为拼音并获取首字母大写
|
|
|
|
+ py := convertToPinyin(word)
|
|
|
|
+ return strings.ToUpper(string(py[0]))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 判断字符是否是英文字母
|
|
|
|
+func isEnglishLetter(char string) bool {
|
|
|
|
+ return len(char) == 1 && ((char >= "a" && char <= "z") || (char >= "A" && char <= "Z"))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 将中文单词转换为拼音
|
|
|
|
+func convertToPinyin(word string) string {
|
|
|
|
+ p := pinyin.NewArgs()
|
|
|
|
+ p.Style = pinyin.FirstLetter
|
|
|
|
+ pys := pinyin.Pinyin(word, p)
|
|
|
|
+ pinyinStr := ""
|
|
|
|
+ for _, py := range pys {
|
|
|
|
+ pinyinStr += py[0]
|
|
}
|
|
}
|
|
- return result
|
|
|
|
|
|
+ return pinyinStr
|
|
}
|
|
}
|