mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
feat(homepage): custom app sort order
This commit is contained in:
parent
55bbcae911
commit
cf30fe6cfc
1 changed files with 10 additions and 0 deletions
|
@ -2,6 +2,7 @@ package homepage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/homepage/widgets"
|
"github.com/yusing/go-proxy/internal/homepage/widgets"
|
||||||
"github.com/yusing/go-proxy/internal/utils"
|
"github.com/yusing/go-proxy/internal/utils"
|
||||||
|
@ -61,4 +62,13 @@ func (c Homepage) Add(item *Item) {
|
||||||
c[item.Category] = make(Category, 0)
|
c[item.Category] = make(Category, 0)
|
||||||
}
|
}
|
||||||
c[item.Category] = append(c[item.Category], item)
|
c[item.Category] = append(c[item.Category], item)
|
||||||
|
slices.SortStableFunc(c[item.Category], func(a, b *Item) int {
|
||||||
|
if a.SortOrder < b.SortOrder {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
if a.SortOrder > b.SortOrder {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue