@@ -29,26 +29,31 @@ type {{.PluginTitle}} struct {
29
29
30
30
func init() {
31
31
plugins.Add(&{{.PluginTitle}}{
32
- Base: &plugins.Base{PlugName: "{{.PluginName}}"},
32
+ Base: &plugins.Base{PlugName: "{{.PluginName}}", URLPrefix: "{{.PluginName}}" },
33
33
// ....
34
34
})
35
35
}
36
36
37
37
func New{{.PluginTitle}}(/*...*/) *{{.PluginTitle}} {
38
38
return &{{.PluginTitle}}{
39
- Base: &plugins.Base{PlugName: "{{.PluginName}}"},
39
+ Base: &plugins.Base{PlugName: "{{.PluginName}}", URLPrefix: "{{.PluginName}}" },
40
40
// ...
41
41
}
42
42
}
43
43
44
44
func (plug *{{.PluginTitle}}) IsInstalled() bool {
45
- panic("implement it")
45
+ // ... implement it
46
+ return true
47
+ }
48
+
49
+ func (plug *{{.PluginTitle}}) GetIndexURL() string {
50
+ return config.Url("/{{.PluginName}}/example?param=helloworld")
46
51
}
47
52
48
53
func (plug *{{.PluginTitle}}) InitPlugin(srv service.List) {
49
54
50
55
// DO NOT DELETE
51
- plug.InitBase(srv)
56
+ plug.InitBase(srv, "{{.PluginName}}" )
52
57
53
58
plug.handler = controller.NewHandler(/*...*/)
54
59
plug.guard = guard.New(/*...*/)
@@ -59,7 +64,7 @@ func (plug *{{.PluginTitle}}) InitPlugin(srv service.List) {
59
64
language.Lang[language.CN].Combine(language2.CN)
60
65
language.Lang[language.EN].Combine(language2.EN)
61
66
62
- f .SetInfo(info)
67
+ plug .SetInfo(info)
63
68
}
64
69
65
70
var info = plugins.Info{
@@ -120,8 +125,8 @@ func (plug *{{.PluginTitle}}) GetSettingPage() table.Generator {
120
125
121
126
import (
122
127
"github.com/GoAdminGroup/go-admin/context"
123
- "github.com/GoAdminGroup/go-admin/plugins"
124
128
"github.com/GoAdminGroup/go-admin/template"
129
+ "github.com/GoAdminGroup/go-admin/template/types"
125
130
)
126
131
127
132
type Handler struct {
@@ -187,7 +192,7 @@ type ExampleParam struct {
187
192
188
193
func (g *Guardian) Example(ctx *context.Context) {
189
194
190
- param := ctx.FormValue ("param")
195
+ param := ctx.Query ("param")
191
196
192
197
ctx.SetUserValue("example", &ExampleParam{
193
198
Param: param,
@@ -212,17 +217,15 @@ test:
212
217
import (
213
218
"github.com/GoAdminGroup/go-admin/context"
214
219
"github.com/GoAdminGroup/go-admin/modules/auth"
215
- "github.com/GoAdminGroup/go-admin/modules/config"
216
220
"github.com/GoAdminGroup/go-admin/modules/service"
217
221
)
218
222
219
223
func (plug *{{.PluginTitle}}) initRouter(srv service.List) *context.App {
220
224
221
225
app := context.NewApp()
222
- route := app.Group(config.GetUrlPrefix())
223
- authRoute := route.Group("/", auth.Middleware(plug.Conn))
226
+ authRoute := app.Group("/", auth.Middleware(plug.Conn))
224
227
225
- authRoute.POST("/{{.PluginName}} /example", plug.guard.Example, plug.handler.Example)
228
+ authRoute.GET(" /example", plug.guard.Example, plug.handler.Example)
226
229
227
230
return app
228
231
}` ,
0 commit comments