Skip to content

Commit 710d5bc

Browse files
authored
feat: 实现首页项目拖拽排序功能以及部分功能优化 (#955)
* feat: 首页项目拖拽排序功能 * feat: 增加首页项目拖拽排序增加只能管理员进行, 排序失败元素回到原本位置 * perf: 新建文章以后直接进入到编辑文章页面 * perf: 优化文档打开时或刷新时样式闪动问题
1 parent ad5e871 commit 710d5bc

File tree

13 files changed

+337
-30
lines changed

13 files changed

+337
-30
lines changed

conf/lang/en-us.ini

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ ft_last_editor = Last editor:
439439
ft_create_time = Create time:
440440
ft_update_time = Update time:
441441
view_count = Number of views
442+
changetheme = Switch themes
442443

443444
[project]
444445
prj_space_list = Project Space List

conf/lang/zh-cn.ini

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ ft_last_editor = 最后编辑:
439439
ft_create_time = 创建时间:
440440
ft_update_time = 更新时间:
441441
view_count = 阅读次数
442+
changetheme = 切换主题
442443

443444
[project]
444445
prj_space_list = 项目空间列表

controllers/BookController.go

+33
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,39 @@ func (c *BookController) Release() {
773773
c.JsonResult(0, i18n.Tr(c.Lang, "message.publish_to_queue"))
774774
}
775775

776+
// 更新项目排序
777+
func (c *BookController) UpdateBookOrder() {
778+
if !c.Member.IsAdministrator() {
779+
c.JsonResult(403, "权限不足")
780+
return
781+
}
782+
type Params struct {
783+
Ids string `form:"ids"`
784+
}
785+
var params Params
786+
if err := c.ParseForm(&params); err != nil {
787+
c.JsonResult(6003, "参数错误")
788+
return
789+
}
790+
idArray := strings.Split(params.Ids, ",")
791+
orderCount := len(idArray)
792+
for _, id := range idArray {
793+
bookId, _ := strconv.Atoi(id)
794+
orderCount--
795+
book, err := models.NewBook().Find(bookId)
796+
if err != nil {
797+
continue
798+
}
799+
book.BookId = bookId
800+
book.OrderIndex = orderCount
801+
err = book.Update()
802+
if err != nil {
803+
continue
804+
}
805+
}
806+
c.JsonResult(0, "ok")
807+
}
808+
776809
// 文档排序.
777810
func (c *BookController) SaveSort() {
778811
c.Prepare()

go.mod

+26-4
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,58 @@ require (
2222
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect
2323
github.com/Unknwon/goconfig v1.0.0 // indirect
2424
github.com/andybalholm/cascadia v1.3.1 // indirect
25+
github.com/astaxie/beego v1.12.1 // indirect
26+
github.com/beego/bee v1.12.3 // indirect
2527
github.com/beorn7/perks v1.0.1 // indirect
2628
github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect
2729
github.com/cespare/xxhash/v2 v2.1.2 // indirect
30+
github.com/cosiner/argv v0.1.0 // indirect
31+
github.com/davecgh/go-spew v1.1.1 // indirect
32+
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 // indirect
33+
github.com/fsnotify/fsnotify v1.4.9 // indirect
34+
github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd01330766f // indirect
2835
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
2936
github.com/go-redis/redis/v7 v7.4.1 // indirect
3037
github.com/go-sql-driver/mysql v1.6.0 // indirect
3138
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
3239
github.com/golang/protobuf v1.5.2 // indirect
3340
github.com/gomodule/redigo v2.0.0+incompatible // indirect
41+
github.com/gorilla/websocket v1.4.2 // indirect
3442
github.com/hashicorp/golang-lru v0.5.4 // indirect
35-
github.com/jinzhu/inflection v1.0.0 // indirect
36-
github.com/jinzhu/now v1.1.5 // indirect
43+
github.com/hashicorp/hcl v1.0.0 // indirect
44+
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
45+
github.com/magiconair/properties v1.8.1 // indirect
46+
github.com/mattn/go-colorable v0.0.9 // indirect
47+
github.com/mattn/go-isatty v0.0.3 // indirect
3748
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
3849
github.com/mitchellh/mapstructure v1.5.0 // indirect
50+
github.com/pelletier/go-toml v1.9.2 // indirect
51+
github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b // indirect
3952
github.com/pkg/errors v0.9.1 // indirect
4053
github.com/prometheus/client_golang v1.13.0 // indirect
4154
github.com/prometheus/client_model v0.2.0 // indirect
4255
github.com/prometheus/common v0.37.0 // indirect
4356
github.com/prometheus/procfs v0.8.0 // indirect
4457
github.com/rivo/uniseg v0.3.4 // indirect
4558
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
59+
github.com/sirupsen/logrus v1.6.0 // indirect
60+
github.com/smartwalle/pongo2render v1.0.1 // indirect
4661
github.com/smartystreets/goconvey v1.7.2 // indirect
62+
github.com/spf13/afero v1.1.2 // indirect
63+
github.com/spf13/cast v1.3.0 // indirect
64+
github.com/spf13/jwalterweatherman v1.0.0 // indirect
65+
github.com/spf13/pflag v1.0.3 // indirect
66+
github.com/spf13/viper v1.7.0 // indirect
67+
github.com/subosito/gotenv v1.2.0 // indirect
68+
go.starlark.net v0.0.0-20190702223751-32f345186213 // indirect
69+
golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 // indirect
4770
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d // indirect
4871
golang.org/x/image v0.5.0 // indirect
4972
golang.org/x/net v0.7.0 // indirect
5073
golang.org/x/sys v0.5.0 // indirect
5174
golang.org/x/text v0.7.0 // indirect
5275
google.golang.org/protobuf v1.28.1 // indirect
76+
gopkg.in/ini.v1 v1.51.0 // indirect
5377
gopkg.in/yaml.v2 v2.4.0 // indirect
5478
gopkg.in/yaml.v3 v3.0.1 // indirect
55-
gorm.io/driver/sqlite v1.5.5 // indirect
56-
gorm.io/gorm v1.25.9 // indirect
5779
)

0 commit comments

Comments
 (0)