mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-21 07:46:09 +01:00
🎨 Automatically apply code snippets after data synchronization https://github.com/siyuan-note/siyuan/issues/16736
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
aea569078b
commit
28c51981e4
3 changed files with 19 additions and 2 deletions
|
|
@ -1595,7 +1595,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
|||
var upserts, removes []string
|
||||
var upsertTrees int
|
||||
// 可能需要重新加载部分功能
|
||||
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin bool
|
||||
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin, needReloadSnippet bool
|
||||
upsertCodePluginSet := hashset.New() // 插件代码变更 data/plugins/
|
||||
upsertDataPluginSet := hashset.New() // 插件存储数据变更 data/storage/petal/
|
||||
needUnindexBoxes, needIndexBoxes := map[string]bool{}, map[string]bool{}
|
||||
|
|
@ -1640,6 +1640,10 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
|||
absPath := filepath.Join(util.DataDir, file.Path)
|
||||
HandleAssetsChangeEvent(absPath)
|
||||
}
|
||||
|
||||
if file.Path == "/snippets/conf.json" {
|
||||
needReloadSnippet = true
|
||||
}
|
||||
}
|
||||
|
||||
removeWidgetDirSet, unloadPluginSet, uninstallPluginSet := hashset.New(), hashset.New(), hashset.New()
|
||||
|
|
@ -1686,6 +1690,10 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
|||
absPath := filepath.Join(util.DataDir, file.Path)
|
||||
HandleAssetsRemoveEvent(absPath)
|
||||
}
|
||||
|
||||
if file.Path == "/snippets/conf.json" {
|
||||
needReloadSnippet = true
|
||||
}
|
||||
}
|
||||
|
||||
for _, upsertPetal := range mergeResult.UpsertPetals {
|
||||
|
|
@ -1710,6 +1718,10 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
|||
PushReloadPlugin(upsertCodePluginSet, upsertDataPluginSet, unloadPluginSet, uninstallPluginSet, "")
|
||||
}
|
||||
|
||||
if needReloadSnippet {
|
||||
PushReloadSnippet(Conf.Snippet)
|
||||
}
|
||||
|
||||
for _, widgetDir := range removeWidgetDirSet.Values() {
|
||||
widgetDirPath := filepath.Join(util.DataDir, "widgets", widgetDir.(string))
|
||||
gulu.File.RemoveEmptyDirs(widgetDirPath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue