mirror of
https://github.com/acepanel/panel.git
synced 2026-02-05 12:23:35 +08:00
refactor: plugin dir
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package plugins
|
||||
package openresty
|
||||
|
||||
import (
|
||||
"os"
|
||||
@@ -14,22 +14,23 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/http/controllers"
|
||||
"panel/app/http/controllers/plugins"
|
||||
"panel/packages/helpers"
|
||||
)
|
||||
|
||||
type OpenRestyController struct {
|
||||
//Dependent services
|
||||
// Dependent services
|
||||
}
|
||||
|
||||
func NewOpenrestyController() *OpenRestyController {
|
||||
return &OpenRestyController{
|
||||
//Inject services
|
||||
// Inject services
|
||||
}
|
||||
}
|
||||
|
||||
// Status 获取运行状态
|
||||
func (r *OpenRestyController) Status(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ func (r *OpenRestyController) Status(ctx http.Context) {
|
||||
|
||||
// Reload 重载配置
|
||||
func (r *OpenRestyController) Reload(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ func (r *OpenRestyController) Reload(ctx http.Context) {
|
||||
|
||||
// Start 启动OpenResty
|
||||
func (r *OpenRestyController) Start(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ func (r *OpenRestyController) Start(ctx http.Context) {
|
||||
|
||||
// Stop 停止OpenResty
|
||||
func (r *OpenRestyController) Stop(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ func (r *OpenRestyController) Stop(ctx http.Context) {
|
||||
|
||||
// Restart 重启OpenResty
|
||||
func (r *OpenRestyController) Restart(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -195,7 +196,7 @@ func (r *OpenRestyController) Restart(ctx http.Context) {
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (r *OpenRestyController) GetConfig(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -210,7 +211,7 @@ func (r *OpenRestyController) GetConfig(ctx http.Context) {
|
||||
|
||||
// SaveConfig 保存配置
|
||||
func (r *OpenRestyController) SaveConfig(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -265,7 +266,7 @@ func (r *OpenRestyController) SaveConfig(ctx http.Context) {
|
||||
|
||||
// ErrorLog 获取错误日志
|
||||
func (r *OpenRestyController) ErrorLog(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -282,7 +283,7 @@ func (r *OpenRestyController) ErrorLog(ctx http.Context) {
|
||||
|
||||
// ClearErrorLog 清空错误日志
|
||||
func (r *OpenRestyController) ClearErrorLog(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -299,7 +300,7 @@ func (r *OpenRestyController) ClearErrorLog(ctx http.Context) {
|
||||
|
||||
// Load 获取负载
|
||||
func (r *OpenRestyController) Load(ctx http.Context) {
|
||||
if !Check(ctx, "openresty") {
|
||||
if !plugins.Check(ctx, "openresty") {
|
||||
return
|
||||
}
|
||||
|
||||
11
app/plugins/mysql57/mysql57.go
Normal file
11
app/plugins/mysql57/mysql57.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package mysql57
|
||||
|
||||
var (
|
||||
Name = "MySQL-5.7"
|
||||
Author = "耗子"
|
||||
Description = "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。"
|
||||
Slug = "mysql57"
|
||||
Version = "5.7.42"
|
||||
Requires = []string{}
|
||||
Excludes = []string{"mysql80"}
|
||||
)
|
||||
11
app/plugins/mysql80/mysql80.go
Normal file
11
app/plugins/mysql80/mysql80.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package mysql80
|
||||
|
||||
var (
|
||||
Name = "MySQL-8.0"
|
||||
Author = "耗子"
|
||||
Description = "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。"
|
||||
Slug = "mysql80"
|
||||
Version = "8.0.33"
|
||||
Requires = []string{}
|
||||
Excludes = []string{"mysql57"}
|
||||
)
|
||||
11
app/plugins/php80/php80.go
Normal file
11
app/plugins/php80/php80.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package php80
|
||||
|
||||
var (
|
||||
Name = "PHP-8.0"
|
||||
Author = "耗子"
|
||||
Description = "PHP 是世界上最好的语言!"
|
||||
Slug = "php80"
|
||||
Version = "8.0.29"
|
||||
Requires = []string{}
|
||||
Excludes = []string{}
|
||||
)
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/models"
|
||||
"panel/plugins/openresty"
|
||||
"panel/app/plugins/openresty"
|
||||
)
|
||||
|
||||
// PanelPlugin 插件元数据结构
|
||||
|
||||
@@ -4,14 +4,14 @@ import (
|
||||
"github.com/goravel/framework/contracts/route"
|
||||
"github.com/goravel/framework/facades"
|
||||
|
||||
"panel/app/http/controllers/plugins"
|
||||
"panel/app/http/controllers/plugins/openresty"
|
||||
"panel/app/http/middleware"
|
||||
)
|
||||
|
||||
// Plugin 加载插件路由
|
||||
func Plugin() {
|
||||
facades.Route().Prefix("api/plugins/openresty").Middleware(middleware.Jwt()).Group(func(route route.Route) {
|
||||
openRestyController := plugins.NewOpenrestyController()
|
||||
openRestyController := openresty.NewOpenrestyController()
|
||||
route.Get("status", openRestyController.Status)
|
||||
route.Post("reload", openRestyController.Reload)
|
||||
route.Post("start", openRestyController.Start)
|
||||
|
||||
Reference in New Issue
Block a user