mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
improve example for package gpage
This commit is contained in:
parent
e2c1e11f95
commit
41a9e91b4c
@ -6,6 +6,10 @@ import (
|
||||
"github.com/gogf/gf/text/gstr"
|
||||
)
|
||||
|
||||
const (
|
||||
TraceIdName = "trace-id"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
type Sender struct {
|
||||
|
@ -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(`
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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(`
|
||||
|
@ -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"
|
||||
|
@ -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 != "" {
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user