mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-28 18:00:15 +01:00
✨ 增加公共代码 js/css 片段 https://github.com/siyuan-note/siyuan/issues/6143
This commit is contained in:
parent
ee413a6352
commit
5aa5764974
2 changed files with 6 additions and 8 deletions
|
|
@ -285,7 +285,6 @@ func InitConf() {
|
|||
}
|
||||
|
||||
util.SetNetworkProxy(Conf.System.NetworkProxy.String())
|
||||
loadSnippets()
|
||||
}
|
||||
|
||||
var langs = map[string]map[int]string{}
|
||||
|
|
@ -661,10 +660,8 @@ func clearWorkspaceTemp() {
|
|||
logging.LogInfof("cleared workspace temp")
|
||||
}
|
||||
|
||||
var Snippets []*conf.Snippet // js/css 代码片段配置
|
||||
|
||||
func loadSnippets() {
|
||||
Snippets = []*conf.Snippet{}
|
||||
func LoadSnippets() (ret []*conf.Snippet) {
|
||||
ret = []*conf.Snippet{}
|
||||
|
||||
confPath := filepath.Join(util.DataDir, "snippets/conf.json")
|
||||
if !gulu.File.IsExist(confPath) {
|
||||
|
|
@ -677,10 +674,10 @@ func loadSnippets() {
|
|||
return
|
||||
}
|
||||
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &Snippets); nil != err {
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
|
||||
logging.LogErrorf("unmarshal js snippets failed: %s", err)
|
||||
return
|
||||
}
|
||||
logging.LogInfof("loaded js snippets [%d]", len(Snippets))
|
||||
logging.LogInfof("loaded js snippets [%d]", len(ret))
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue