🎨 Add a kernel API /api/system/getWorkspaceInfo
https://github.com/siyuan-note/siyuan/issues/13300
This commit is contained in:
parent
cc629041f9
commit
691290a7be
3 changed files with 11 additions and 1 deletions
|
@ -65,6 +65,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/system/getNetwork", model.CheckAuth, model.CheckAdminRole, getNetwork)
|
||||
ginServer.Handle("POST", "/api/system/exportConf", model.CheckAuth, model.CheckAdminRole, exportConf)
|
||||
ginServer.Handle("POST", "/api/system/importConf", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importConf)
|
||||
ginServer.Handle("POST", "/api/system/getWorkspaceInfo", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getWorkspaceInfo)
|
||||
|
||||
ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setLocalStorage)
|
||||
ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)
|
||||
|
|
|
@ -35,6 +35,15 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func getWorkspaceInfo(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
ret.Data = map[string]any{
|
||||
"workspaceDir": util.WorkspaceDir,
|
||||
}
|
||||
}
|
||||
|
||||
func getNetwork(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
@ -232,7 +232,7 @@ func CheckAuth(c *gin.Context) {
|
|||
c.Next()
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") {
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") || strings.HasPrefix(c.Request.RequestURI, "/api/system/getWorkspaceInfo") {
|
||||
c.Set(RoleContextKey, RoleAdministrator)
|
||||
c.Next()
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue