improve example for package gpage

This commit is contained in:
John 2020-03-21 23:13:31 +08:00
parent e2c1e11f95
commit 41a9e91b4c
10 changed files with 11 additions and 11 deletions

View File

@ -6,6 +6,10 @@ import (
"github.com/gogf/gf/text/gstr"
)
const (
TraceIdName = "trace-id"
)
func main() {
type Sender struct {

View File

@ -7,7 +7,7 @@ import (
)
func main() {
s := ghttp.GetServer()
s := g.Server()
s.BindHandler("/page/demo", func(r *ghttp.Request) {
page := r.GetPage(100, 10)
buffer, _ := gview.ParseContent(`

View File

@ -7,7 +7,7 @@ import (
)
func main() {
s := ghttp.GetServer()
s := g.Server()
s.BindHandler("/page/ajax", func(r *ghttp.Request) {
page := r.GetPage(100, 10)
page.AjaxActionName = "DoAjax"

View File

@ -8,7 +8,7 @@ import (
"github.com/gogf/gf/util/gpage"
)
// 分页标签使用li标签包裹
// wrapContent wraps each of the page tag with html li and ul.
func wrapContent(page *gpage.Page) string {
content := page.GetContent(4)
content = gstr.ReplaceByMap(content, map[string]string{
@ -21,7 +21,7 @@ func wrapContent(page *gpage.Page) string {
}
func main() {
s := ghttp.GetServer()
s := g.Server()
s.BindHandler("/page/custom1/*page", func(r *ghttp.Request) {
page := r.GetPage(100, 10)
content := wrapContent(page)

View File

@ -7,7 +7,7 @@ import (
"github.com/gogf/gf/util/gpage"
)
// 自定义分页名称
// pageContent customizes the page tag name.
func pageContent(page *gpage.Page) string {
page.NextPageTag = "NextPage"
page.PrevPageTag = "PrevPage"
@ -22,7 +22,7 @@ func pageContent(page *gpage.Page) string {
}
func main() {
s := ghttp.GetServer()
s := g.Server()
s.BindHandler("/page/custom2/*page", func(r *ghttp.Request) {
page := r.GetPage(100, 10)
buffer, _ := gview.ParseContent(`

View File

@ -8,7 +8,6 @@ package gbase64_test
import (
"github.com/gogf/gf/debug/gdebug"
"github.com/gogf/gf/os/gfile"
"testing"
"github.com/gogf/gf/encoding/gbase64"

View File

@ -53,7 +53,7 @@ func (r *Request) GetPage(totalSize, pageSize int) *gpage.Page {
values := url.Query()
values.Set(gpage.PAGE_NAME, gpage.PAGE_PLACE_HOLDER)
url.RawQuery = values.Encode()
// Replace the encodes "{.page}" to "{.page}".
// Replace the encoded "{.page}" to original "{.page}".
url.RawQuery = gstr.Replace(url.RawQuery, "%7B.page%7D", "{.page}")
}
if url.RawQuery != "" {

View File

@ -10,7 +10,6 @@ import (
"fmt"
"github.com/gogf/gf/container/garray"
"github.com/gogf/gf/debug/gdebug"
"github.com/gogf/gf/os/gfile"
"net/http"
"testing"
"time"

View File

@ -18,7 +18,6 @@ import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gfile"
"github.com/gogf/gf/test/gtest"
)

View File

@ -9,7 +9,6 @@ package gview_test
import (
"github.com/gogf/gf/debug/gdebug"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gfile"
"github.com/gogf/gf/os/gview"
"github.com/gogf/gf/test/gtest"
"testing"