An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: 数据仓库支持云端备份 https://github.com/siyuan-note/siyuan/issues/5336
Liang Ding4bfe4490a7f5
diff --git a/app/src/util/history.ts b/app/src/util/history.tsindex 43bf2af19f..7002c2ffe8 100644--- a/app/src/util/history.ts+++ b/app/src/util/history.ts@@ -114,13 +114,13 @@ const renderRepo = (element: Element, currentPage: number) => {} else {previousElement.setAttribute("disabled", "disabled");}- fetchPost("/api/repo/getRepoIndexLogs", {page: currentPage}, (response) => {+ fetchPost("/api/repo/getRepoSnapshots", {page: currentPage}, (response) => {if (currentPage < response.data.pageCount) {nextElement.removeAttribute("disabled");} else {nextElement.setAttribute("disabled", "disabled");}- if (response.data.logs.length === 0) {+ if (response.data.snapshots.length === 0) {element.lastElementChild.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;return;}diff --git a/kernel/api/repo.go b/kernel/api/repo.goindex 106c8b7342..58a544aeb8 100644--- a/kernel/api/repo.go+++ b/kernel/api/repo.go@@ -43,7 +43,7 @@ func checkoutRepo(c *gin.Context) {}}-func getRepoIndexLogs(c *gin.Context) {+func getRepoSnapshots(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)@@ -66,6 +66,22 @@ func getRepoIndexLogs(c *gin.Context) {}}+func getRepoTagSnapshots(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ snapshots, err := model.GetTagSnapshots()+ if nil != err {+ ret.Code = -1+ ret.Msg = err.Error()+ return+ }++ ret.Data = map[string]interface{}{+ "snapshots": snapshots,+ }+}+func createSnapshot(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex 6aec42864f..90f187eb28 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -257,7 +257,8 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/repo/createSnapshot", model.CheckAuth, createSnapshot)ginServer.Handle("POST", "/api/repo/tagSnapshot", model.CheckAuth, tagSnapshot)ginServer.Handle("POST", "/api/repo/checkoutRepo", model.CheckAuth, checkoutRepo)- ginServer.Handle("POST", "/api/repo/getRepoIndexLogs", model.CheckAuth, getRepoIndexLogs)+ ginServer.Handle("POST", "/api/repo/getRepoSnapshots", model.CheckAuth, getRepoSnapshots)+ ginServer.Handle("POST", "/api/repo/getRepoTagSnapshots", model.CheckAuth, getRepoTagSnapshots)ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)diff --git a/kernel/go.mod b/kernel/go.modindex 1693b7f65d..efac5681ac 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -112,7 +112,7 @@ require (replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220412041952-88c3aaa8595e-//replace github.com/siyuan-note/dejavu => D:\88250\dejavu+replace github.com/siyuan-note/dejavu => D:\88250\dejavu//replace github.com/siyuan-note/httpclient => D:\88250\httpclient//replace github.com/siyuan-note/filelock => D:\88250\filelock//replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lutediff --git a/kernel/model/repository.go b/kernel/model/repository.goindex f48057a1fd..4f93d86a30 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -27,7 +27,6 @@ import ("github.com/88250/gulu""github.com/siyuan-note/dejavu"- "github.com/siyuan-note/dejavu/entity""github.com/siyuan-note/encryption""github.com/siyuan-note/eventbus""github.com/siyuan-note/filelock"@@ -194,6 +193,21 @@ func CheckoutRepo(id string) (err error) {return}+func GetTagSnapshots() (ret []*dejavu.Log, err error) {+ if 1 > len(Conf.Repo.Key) {+ err = errors.New(Conf.Language(26))+ return+ }++ repo, err := newRepository()+ if nil != err {+ return+ }++ ret, err = repo.GetTagLogs()+ return+}+func TagSnapshot(id, name string) (err error) {if 1 > len(Conf.Repo.Key) {err = errors.New(Conf.Language(26))@@ -452,36 +466,25 @@ func subscribeEvents() {contextPushMsg(context, msg)})- eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudLatest, func(context map[string]interface{}) {+ eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudIndex, func(context map[string]interface{}) {msg := "Downloading data repository latest..."util.SetBootDetails(msg)contextPushMsg(context, msg)})- eventbus.Subscribe(dejavu.EvtSyncAfterDownloadCloudLatest, func(context map[string]interface{}, latest *entity.Index) {- msg := fmt.Sprintf("Downloaded latest [%s]", latest.ID[:7])- util.SetBootDetails(msg)- contextPushMsg(context, msg)-- //util.LogInfof(msg)- //for _, index := range indexes {- // util.LogInfof(" [%s]", index.ID)- //}- })-- eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudFile, func(context map[string]interface{}, id string) {+ eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudFile, func(context map[string]interface{}, id string) {msg := "Downloading data repository object [" + id + "]"util.SetBootDetails(msg)contextPushMsg(context, msg)})- eventbus.Subscribe(dejavu.EvtSyncBeforeDownloadCloudChunk, func(context map[string]interface{}, id string) {+ eventbus.Subscribe(dejavu.EvtBeforeDownloadCloudChunk, func(context map[string]interface{}, id string) {msg := "Downloading data repository object [" + id + "]"util.SetBootDetails(msg)contextPushMsg(context, msg)})- eventbus.Subscribe(dejavu.EvtSyncBeforeUploadObject, func(context map[string]interface{}, id string) {+ eventbus.Subscribe(dejavu.EvtBeforeUploadObject, func(context map[string]interface{}, id string) {msg := "Uploading data repository object [" + id + "]"util.SetBootDetails(msg)contextPushMsg(context, msg)