Skip to content

Commit

Permalink
feat: 实现首页项目拖拽排序功能以及部分功能优化 (#955)
Browse files Browse the repository at this point in the history
* feat: 首页项目拖拽排序功能

* feat: 增加首页项目拖拽排序增加只能管理员进行, 排序失败元素回到原本位置

* perf: 新建文章以后直接进入到编辑文章页面

* perf: 优化文档打开时或刷新时样式闪动问题
  • Loading branch information
Zzhenping authored Jul 4, 2024
1 parent ad5e871 commit 710d5bc
Show file tree
Hide file tree
Showing 13 changed files with 337 additions and 30 deletions.
1 change: 1 addition & 0 deletions conf/lang/en-us.ini
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ ft_last_editor = Last editor:
ft_create_time = Create time:
ft_update_time = Update time:
view_count = Number of views
changetheme = Switch themes

[project]
prj_space_list = Project Space List
Expand Down
1 change: 1 addition & 0 deletions conf/lang/zh-cn.ini
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ ft_last_editor = 最后编辑:
ft_create_time = 创建时间:
ft_update_time = 更新时间:
view_count = 阅读次数
changetheme = 切换主题

[project]
prj_space_list = 项目空间列表
Expand Down
33 changes: 33 additions & 0 deletions controllers/BookController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params); 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()
Expand Down
30 changes: 26 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,58 @@ require (
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect
github.com/Unknwon/goconfig v1.0.0 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/astaxie/beego v1.12.1 // indirect
github.com/beego/bee v1.12.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cosiner/argv v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd01330766f // indirect
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
github.com/go-redis/redis/v7 v7.4.1 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.2 // indirect
github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.3.4 // indirect
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/smartwalle/pongo2render v1.0.1 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.starlark.net v0.0.0-20190702223751-32f345186213 // indirect
golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 // indirect
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect
golang.org/x/image v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/sqlite v1.5.5 // indirect
gorm.io/gorm v1.25.9 // indirect
)
Loading

0 comments on commit 710d5bc

Please sign in to comment.