Browse Source

取消插件模式 不再对插件提供支持

main
QM303176530 4 years ago
parent
commit
8b00e8d6c2
  1. 26
      server/core/install_plugs.go
  2. 3
      server/core/server.go
  3. 2
      server/go.mod
  4. 23
      server/initialize/plug.go
  5. 1
      web/src/view/layout/aside/index.vue

26
server/core/install_plugs.go

@ -1,26 +0,0 @@
package core
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/initialize"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
"github.com/piexlmax/gvaplug"
)
func InstallPlugs(route *gin.Engine) {
GvaPlugsGroupBase := route.Group("") // 纯净路由 插件可通用 传递给插件的0号位置 为了不让插件的自动路由出问题 这里建议为 ""
/**安装一个插件需要的步骤 start**/
GvaPlugsGroupMiddle := route.Group("") // 携带中间件的路由 传递给插件的1号位置 为了不让插件的自动路由出问题 这里建议为 ""
GvaPlugsGroupMiddle.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
// 插件安装 暂时只是后台功能 添加model 添加路由 添加对数据库的操作 详细插件测试模板可看https://github.com/piexlmax/gvaplug 此处不建议投入生产
err := initialize.InstallPlug(global.GVA_DB, [2]*gin.RouterGroup{
GvaPlugsGroupBase,
GvaPlugsGroupMiddle,
}, gvaplug.GvaPlug{SomeConfig: "插件给用户提供的配置区域"})
if err != nil {
panic(fmt.Sprintf("插件安装失败: %v", err))
}
/**安装一个插件需要的步骤 end**/
}

3
server/core/server.go

@ -19,9 +19,6 @@ func RunWindowsServer() {
Router := initialize.Routers()
Router.Static("/form-generator", "./resource/page")
//InstallPlugs(Router)
// end 插件描述
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
s := initServer(address, Router)
// 保证文本顺序输出

2
server/go.mod

@ -31,10 +31,8 @@ require (
github.com/onsi/gomega v1.4.3 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/piexlmax/gvaplug v0.0.8
github.com/pkg/errors v0.9.1 // indirect
github.com/qiniu/api.v7/v7 v7.4.1
github.com/qiniu/x v1.10.5
github.com/satori/go.uuid v1.2.0
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect

23
server/initialize/plug.go

@ -1,23 +0,0 @@
package initialize
import (
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
)
type Plug interface {
InitRouter([2]*gin.RouterGroup) error
InitModel(*gorm.DB) error
}
func InstallPlug(db *gorm.DB, router [2]*gin.RouterGroup, p Plug) (err error) {
err = p.InitModel(db)
if err != nil {
return err
}
err = p.InitRouter(router)
if err != nil {
return err
}
return nil
}

1
web/src/view/layout/aside/index.vue

@ -45,7 +45,6 @@ export default {
params[item.key] = item.value;
}
});
console.log(query, params);
if (index === this.$route.name) return;
this.$router.push({ name: index, query, params });
}

Loading…
Cancel
Save