mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-14 21:23:47 +08:00
插件增加静态文件目录自动映射,优化插件模板引擎与主模块的耦合关系
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package home
|
||||
|
||||
import (
|
||||
@@ -11,7 +10,6 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/hgexample/api/home/index"
|
||||
"hotgo/addons/hgexample/global"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/internal/model"
|
||||
@@ -39,7 +37,7 @@ func (a *cIndex) Index(ctx context.Context, req *index.TestReq) (res *index.Test
|
||||
return
|
||||
}
|
||||
|
||||
isc.View().RenderTpl(ctx, global.Tpl("home/index.html"), model.View{Data: g.Map{
|
||||
isc.View().RenderTpl(ctx, "home/index.html", model.View{Data: g.Map{
|
||||
"name": data.Name,
|
||||
"module": data.Module,
|
||||
"time": data.Time,
|
||||
|
||||
4
server/addons/hgexample/crons/crons.go
Normal file
4
server/addons/hgexample/crons/crons.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package crons
|
||||
|
||||
// 定时任务.
|
||||
// 插件中的定时任务可以统一在这里注册和处理
|
||||
@@ -20,7 +20,3 @@ func GetSkeleton() *addons.Skeleton {
|
||||
}
|
||||
return skeleton
|
||||
}
|
||||
|
||||
func Tpl(tpl string) string {
|
||||
return addons.Tpl(skeleton.Name, tpl)
|
||||
}
|
||||
|
||||
@@ -9,10 +9,13 @@ import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
_ "hotgo/addons/hgexample/crons"
|
||||
"hotgo/addons/hgexample/global"
|
||||
_ "hotgo/addons/hgexample/logic"
|
||||
_ "hotgo/addons/hgexample/queues"
|
||||
"hotgo/addons/hgexample/router"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -37,7 +40,6 @@ func newModule() {
|
||||
Description: "系统自带的功能使用示例及其说明,包含一些简单的交互",
|
||||
Author: "孟帅",
|
||||
Version: "v1.0.0", // 当该版本号高于已安装的版本号时,会提示可以更新
|
||||
RootPath: addons.GetModulePath("hgexample"),
|
||||
},
|
||||
ctx: gctx.New(),
|
||||
}
|
||||
@@ -54,6 +56,7 @@ func (m *module) Init(ctx context.Context) {
|
||||
// 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)
|
||||
|
||||
4
server/addons/hgexample/queues/queues.go
Normal file
4
server/addons/hgexample/queues/queues.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package queues
|
||||
|
||||
// 消息队列.
|
||||
// 插件中的消息队列消费者可以统一在这里注册和处理
|
||||
1
server/addons/hgexample/resource/public/default
Normal file
1
server/addons/hgexample/resource/public/default
Normal file
@@ -0,0 +1 @@
|
||||
Hello!这是创建插件 [功能案例] 时默认生成的一个静态目录文件,用于测试,当你看到这个提示时,说明已经联调成功啦!
|
||||
32
server/addons/hgexample/resource/template/home/index.html
Normal file
32
server/addons/hgexample/resource/template/home/index.html
Normal 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>
|
||||
Reference in New Issue
Block a user