🎨 Cloud inbox support preview audio and video https://github.com/siyuan-note/siyuan/issues/9780

This commit is contained in:
Daniel 2023-11-29 23:08:10 +08:00
parent 3d8d1ef544
commit a1827d1f50
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -498,6 +498,7 @@ func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
luteEngine := NewLute() luteEngine := NewLute()
audioRegexp := regexp.MustCompile("<audio.*>.*</audio>") audioRegexp := regexp.MustCompile("<audio.*>.*</audio>")
videoRegexp := regexp.MustCompile("<video.*>.*</video>") videoRegexp := regexp.MustCompile("<video.*>.*</video>")
fileRegexp := regexp.MustCompile("\\[文件]\\(.*\\)")
shorthands := result["data"].(map[string]interface{})["shorthands"].([]interface{}) shorthands := result["data"].(map[string]interface{})["shorthands"].([]interface{})
for _, item := range shorthands { for _, item := range shorthands {
shorthand := item.(map[string]interface{}) shorthand := item.(map[string]interface{})
@ -509,6 +510,7 @@ func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
desc := shorthand["shorthandDesc"].(string) desc := shorthand["shorthandDesc"].(string)
desc = audioRegexp.ReplaceAllString(desc, " 语音 ") desc = audioRegexp.ReplaceAllString(desc, " 语音 ")
desc = videoRegexp.ReplaceAllString(desc, " 视频 ") desc = videoRegexp.ReplaceAllString(desc, " 视频 ")
desc = fileRegexp.ReplaceAllString(desc, " 文件 ")
desc = strings.ReplaceAll(desc, "\n\n", "") desc = strings.ReplaceAll(desc, "\n\n", "")
desc = strings.TrimSpace(desc) desc = strings.TrimSpace(desc)
shorthand["shorthandDesc"] = desc shorthand["shorthandDesc"] = desc