mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
✨ 增加公共代码 js/css 片段 https://github.com/siyuan-note/siyuan/issues/6143
This commit is contained in:
parent
5aa5764974
commit
3c4af0fc85
2 changed files with 13 additions and 3 deletions
|
|
@ -42,7 +42,13 @@ func getSnippet(c *gin.Context) {
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
confSnippets := model.LoadSnippets()
|
confSnippets, err := model.LoadSnippets()
|
||||||
|
if nil != err {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "load snippets failed: " + err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var snippets []*conf.Snippet
|
var snippets []*conf.Snippet
|
||||||
for _, s := range confSnippets {
|
for _, s := range confSnippets {
|
||||||
if ("all" == typ || s.Type == typ) && (2 == enabledArg || s.Enabled == enabled) {
|
if ("all" == typ || s.Type == typ) && (2 == enabledArg || s.Enabled == enabled) {
|
||||||
|
|
|
||||||
|
|
@ -660,9 +660,13 @@ func clearWorkspaceTemp() {
|
||||||
logging.LogInfof("cleared workspace temp")
|
logging.LogInfof("cleared workspace temp")
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadSnippets() (ret []*conf.Snippet) {
|
var loadSnippetsLock = sync.Mutex{}
|
||||||
ret = []*conf.Snippet{}
|
|
||||||
|
|
||||||
|
func LoadSnippets() (ret []*conf.Snippet, err error) {
|
||||||
|
loadSnippetsLock.Lock()
|
||||||
|
defer loadSnippetsLock.Unlock()
|
||||||
|
|
||||||
|
ret = []*conf.Snippet{}
|
||||||
confPath := filepath.Join(util.DataDir, "snippets/conf.json")
|
confPath := filepath.Join(util.DataDir, "snippets/conf.json")
|
||||||
if !gulu.File.IsExist(confPath) {
|
if !gulu.File.IsExist(confPath) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue