mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-12-21 19:29:53 +08:00
feat: 实现首页项目拖拽排序功能以及部分功能优化 (#955)
* feat: 首页项目拖拽排序功能 * feat: 增加首页项目拖拽排序增加只能管理员进行, 排序失败元素回到原本位置 * perf: 新建文章以后直接进入到编辑文章页面 * perf: 优化文档打开时或刷新时样式闪动问题
This commit is contained in:
@@ -773,6 +773,39 @@ func (c *BookController) Release() {
|
||||
c.JsonResult(0, i18n.Tr(c.Lang, "message.publish_to_queue"))
|
||||
}
|
||||
|
||||
// 更新项目排序
|
||||
func (c *BookController) UpdateBookOrder() {
|
||||
if !c.Member.IsAdministrator() {
|
||||
c.JsonResult(403, "权限不足")
|
||||
return
|
||||
}
|
||||
type Params struct {
|
||||
Ids string `form:"ids"`
|
||||
}
|
||||
var params Params
|
||||
if err := c.ParseForm(¶ms); err != nil {
|
||||
c.JsonResult(6003, "参数错误")
|
||||
return
|
||||
}
|
||||
idArray := strings.Split(params.Ids, ",")
|
||||
orderCount := len(idArray)
|
||||
for _, id := range idArray {
|
||||
bookId, _ := strconv.Atoi(id)
|
||||
orderCount--
|
||||
book, err := models.NewBook().Find(bookId)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
book.BookId = bookId
|
||||
book.OrderIndex = orderCount
|
||||
err = book.Update()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
|
||||
// 文档排序.
|
||||
func (c *BookController) SaveSort() {
|
||||
c.Prepare()
|
||||
|
||||
Reference in New Issue
Block a user