This commit is contained in:
孟帅
2024-03-07 20:08:56 +08:00
parent 6dd8cbadad
commit 0fbc1ad47c
246 changed files with 9441 additions and 2293 deletions

View File

View File

@@ -0,0 +1 @@
Hello这是创建插件 [功能案例] 时默认生成的一个静态目录文件用于测试当你看到这个提示时说明已经联调成功啦

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
<meta name="keywords" content="@{.Keywords}"/>
<meta name="description" content="@{.Description}"/>
<title>@{.Title}</title>
<script type="text/javascript" src="/resource/home/js/jquery-3.6.0.min.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #f6f6f6;
}
</style>
</head>
<body>
<div style="padding-top: 100px;text-align:center;">
<h1><p>Hello@{.Data.name}!!</p></h1>
<h2><p>@{.Data.module}</p></h2>
<h2><p>服务器时间@{.Data.time}</p></h2>
</div>
</body>
<script>
</script>
</html>

View File

@@ -46,20 +46,25 @@ func newModule() {
addons.RegisterModule(m)
}
// Init 初始化
func (m *module) Init(ctx context.Context) {
global.Init(ctx, m.skeleton)
// ...
// Start 启动模块
func (m *module) Start(option *addons.Option) (err error) {
// 初始化模块
global.Init(m.ctx, m.skeleton)
// 注册插件路由
option.Server.Group("/", func(group *ghttp.RouterGroup) {
group.Middleware(service.Middleware().Addon)
router.Admin(m.ctx, group)
router.Api(m.ctx, group)
router.Home(m.ctx, group)
router.WebSocket(m.ctx, group)
})
return
}
// InitRouter 初始化WEB路由
func (m *module) InitRouter(ctx context.Context, group *ghttp.RouterGroup) {
m.Init(ctx)
group.Middleware(service.Middleware().Addon)
router.Admin(ctx, group)
router.Api(ctx, group)
router.Home(ctx, group)
router.WebSocket(ctx, group)
// Stop 停止模块
func (m *module) Stop() (err error) {
return
}
// Ctx 上下文
@@ -67,7 +72,7 @@ func (m *module) Ctx() context.Context {
return m.ctx
}
// GetSkeleton 架子
// GetSkeleton 获取模块
func (m *module) GetSkeleton() *addons.Skeleton {
return m.skeleton
}