Merge pull request #14 from fthvgb1/dev

优化
This commit is contained in:
2023-02-05 18:45:50 +08:00 committed by GitHub
commit a75c48cdb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/fthvgb1/wp-go
go 1.18
go 1.19
require (
github.com/dlclark/regexp2 v1.7.0

View File

@ -165,12 +165,14 @@ func (h handle) bodyClass() string {
case plugins.Detail:
s = fmt.Sprintf("postid-%d", h.ginH["post"].(models.Posts).Id)
}
return map[int]string{
plugins.Home: "home blog ",
plugins.Archive: "archive date page-two-column",
plugins.Category: str.Join("archive category page-two-column ", s),
plugins.Tag: str.Join("archive category page-two-column ", s),
plugins.Search: str.Join("search ", s),
plugins.Detail: str.Join("post-template-default single single-post single-format-standard ", s),
}[h.scene]
return str.Join(class[h.scene], s)
}
var class = map[int]string{
plugins.Home: "home blog ",
plugins.Archive: "archive date page-two-column",
plugins.Category: "archive category page-two-column",
plugins.Tag: "archive category page-two-column ",
plugins.Search: "search ",
plugins.Detail: "post-template-default single single-post single-format-standard ",
}

View File

@ -6,7 +6,6 @@ import (
"golang.org/x/exp/constraints"
"math/rand"
"strings"
"time"
)
func SimplePagination[T Model](ctx context.Context, where ParseWhere, fields, group string, page, pageSize int, order SqlBuilder, join SqlBuilder, having SqlBuilder, in ...[]any) (r []T, total int, err error) {
@ -59,7 +58,6 @@ func SimplePagination[T Model](ctx context.Context, where ParseWhere, fields, gr
err = globalBb.Get(ctx, &n, sq, args...)
} else {
tpx := "select count(*) n from (select %s from %s %s %s %s %s ) %s"
rand.Seed(int64(time.Now().Nanosecond()))
sq := fmt.Sprintf(tpx, group, rr.Table(), j, w, groupBy, h, fmt.Sprintf("table%d", rand.Int()))
err = globalBb.Get(ctx, &n, sq, args...)
}