mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 04:01:23 +08:00
🐛 Fix NPE https://ld246.com/article/1739550445065
This commit is contained in:
parent
c3bc804fce
commit
4374859e04
@ -22,7 +22,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
@ -166,7 +165,7 @@ func getEmojiConf(c *gin.Context) {
|
|||||||
items := []map[string]interface{}{}
|
items := []map[string]interface{}{}
|
||||||
custom["items"] = items
|
custom["items"] = items
|
||||||
if gulu.File.IsDir(customConfDir) {
|
if gulu.File.IsDir(customConfDir) {
|
||||||
model.CustomEmojis = sync.Map{}
|
model.ClearCustomEmojis()
|
||||||
customEmojis, err := os.ReadDir(customConfDir)
|
customEmojis, err := os.ReadDir(customConfDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.LogErrorf("read custom emojis failed: %s", err)
|
logging.LogErrorf("read custom emojis failed: %s", err)
|
||||||
@ -224,7 +223,7 @@ func addCustomEmoji(name string, items *[]map[string]interface{}) {
|
|||||||
*items = append(*items, emoji)
|
*items = append(*items, emoji)
|
||||||
|
|
||||||
imgSrc := "/emojis/" + name
|
imgSrc := "/emojis/" + name
|
||||||
model.CustomEmojis.Store(nameWithoutExt, imgSrc)
|
model.AddCustomEmoji(nameWithoutExt, imgSrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkUpdate(c *gin.Context) {
|
func checkUpdate(c *gin.Context) {
|
||||||
|
@ -691,7 +691,15 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var CustomEmojis = sync.Map{}
|
var customEmojis = sync.Map{}
|
||||||
|
|
||||||
|
func AddCustomEmoji(emojiName, imgSrc string) {
|
||||||
|
customEmojis.Store(emojiName, imgSrc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearCustomEmojis() {
|
||||||
|
customEmojis.Clear()
|
||||||
|
}
|
||||||
|
|
||||||
func NewLute() (ret *lute.Lute) {
|
func NewLute() (ret *lute.Lute) {
|
||||||
ret = util.NewLute()
|
ret = util.NewLute()
|
||||||
@ -701,7 +709,7 @@ func NewLute() (ret *lute.Lute) {
|
|||||||
ret.SetSpellcheck(Conf.Editor.Spellcheck)
|
ret.SetSpellcheck(Conf.Editor.Spellcheck)
|
||||||
|
|
||||||
customEmojiMap := map[string]string{}
|
customEmojiMap := map[string]string{}
|
||||||
CustomEmojis.Range(func(key, value interface{}) bool {
|
customEmojis.Range(func(key, value interface{}) bool {
|
||||||
customEmojiMap[key.(string)] = value.(string)
|
customEmojiMap[key.(string)] = value.(string)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user