Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2026-01-29 23:05:41 +08:00
commit 6492c141a9
4 changed files with 38 additions and 3 deletions

View file

@ -580,9 +580,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
historyPath: target.parentElement.getAttribute("data-path")
});
} else if (dataType === "av") {
// TODO
fetchPost("/api/history/rollbackDocHistory", {
notebook: target.parentElement.getAttribute("data-notebook-id"),
fetchPost("/api/history/rollbackAttributeViewHistory", {
historyPath: target.parentElement.getAttribute("data-path")
});
} else if (dataType === "notebook") {

View file

@ -222,3 +222,21 @@ func rollbackNotebookHistory(c *gin.Context) {
return
}
}
func rollbackAttributeViewHistory(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
historyPath := arg["historyPath"].(string)
err := model.RollbackAttributeViewHistory(historyPath)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
return
}
}

View file

@ -146,6 +146,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/format/netImg2LocalAssets", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, netImg2LocalAssets)
ginServer.Handle("POST", "/api/format/netAssets2LocalAssets", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, netAssets2LocalAssets)
ginServer.Handle("POST", "/api/history/rollbackAttributeViewHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, rollbackAttributeViewHistory)
ginServer.Handle("POST", "/api/history/getNotebookHistory", model.CheckAuth, model.CheckAdminRole, getNotebookHistory)
ginServer.Handle("POST", "/api/history/rollbackNotebookHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, rollbackNotebookHistory)
ginServer.Handle("POST", "/api/history/rollbackAssetsHistory", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, rollbackAssetsHistory)

View file

@ -426,6 +426,24 @@ func RollbackNotebookHistory(historyPath string) (err error) {
return nil
}
func RollbackAttributeViewHistory(historyPath string) (err error) {
if !gulu.File.IsExist(historyPath) {
logging.LogWarnf("av history [%s] not exist", historyPath)
return
}
from := historyPath
to := filepath.Join(util.DataDir, "storage", "av", filepath.Base(historyPath))
if err = filelock.CopyNewtimes(from, to); err != nil {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", from, to, err)
return
}
IncSync()
util.PushMsg(Conf.Language(102), 3000)
return nil
}
type History struct {
HCreated string `json:"hCreated"`
Items []*HistoryItem `json:"items"`