mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-23 18:49:21 +08:00
feat: 增加 xpack 相关代码 (#3407)
This commit is contained in:
parent
74dd3ce6c3
commit
326bcb5b3c
9
.gitignore
vendored
9
.gitignore
vendored
@ -21,13 +21,6 @@ build/1panel
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
# NetBeans
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
@ -44,6 +37,8 @@ cmd/server/web/monacoeditorwork
|
||||
cmd/server/web/index.html
|
||||
frontend/auto-imports.d.ts
|
||||
frontend/components.d.ts
|
||||
frontend/src/xpack
|
||||
backend/xpack
|
||||
|
||||
.history/
|
||||
dist/
|
||||
|
@ -2,20 +2,23 @@ package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-contrib/gzip"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/i18n"
|
||||
"github.com/1Panel-dev/1Panel/backend/middleware"
|
||||
rou "github.com/1Panel-dev/1Panel/backend/router"
|
||||
"github.com/1Panel-dev/1Panel/cmd/server/docs"
|
||||
"github.com/1Panel-dev/1Panel/cmd/server/web"
|
||||
"github.com/gin-contrib/gzip"
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerfiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
Router *gin.Engine
|
||||
)
|
||||
|
||||
func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
@ -35,7 +38,7 @@ func setWebStatic(rootRouter *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
func Routers() *gin.Engine {
|
||||
Router := gin.Default()
|
||||
Router = gin.Default()
|
||||
Router.Use(middleware.OperationLog())
|
||||
// Router.Use(middleware.CSRF())
|
||||
// Router.Use(middleware.LoadCsrfToken())
|
||||
@ -55,7 +58,6 @@ func Routers() *gin.Engine {
|
||||
"Localize": ginI18n.GetMessage,
|
||||
})
|
||||
|
||||
systemRouter := rou.RouterGroupApp
|
||||
swaggerRouter := Router.Group("1panel")
|
||||
docs.SwaggerInfo.BasePath = "/api/v1"
|
||||
swaggerRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
||||
@ -71,29 +73,8 @@ func Routers() *gin.Engine {
|
||||
PrivateGroup.Use(middleware.WhiteAllow())
|
||||
PrivateGroup.Use(middleware.BindDomain())
|
||||
PrivateGroup.Use(middleware.GlobalLoading())
|
||||
{
|
||||
systemRouter.InitBaseRouter(PrivateGroup)
|
||||
systemRouter.InitDashboardRouter(PrivateGroup)
|
||||
systemRouter.InitHostRouter(PrivateGroup)
|
||||
systemRouter.InitContainerRouter(PrivateGroup)
|
||||
systemRouter.InitTerminalRouter(PrivateGroup)
|
||||
systemRouter.InitMonitorRouter(PrivateGroup)
|
||||
systemRouter.InitLogRouter(PrivateGroup)
|
||||
systemRouter.InitFileRouter(PrivateGroup)
|
||||
systemRouter.InitCronjobRouter(PrivateGroup)
|
||||
systemRouter.InitSettingRouter(PrivateGroup)
|
||||
systemRouter.InitAppRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteGroupRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteDnsAccountRouter(PrivateGroup)
|
||||
systemRouter.InitDatabaseRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteSSLRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteAcmeAccountRouter(PrivateGroup)
|
||||
systemRouter.InitNginxRouter(PrivateGroup)
|
||||
systemRouter.InitRuntimeRouter(PrivateGroup)
|
||||
systemRouter.InitProcessRouter(PrivateGroup)
|
||||
systemRouter.InitToolboxRouter(PrivateGroup)
|
||||
systemRouter.InitWebsiteCARouter(PrivateGroup)
|
||||
for _, router := range rou.RouterGroupApp {
|
||||
router.InitRouter(PrivateGroup)
|
||||
}
|
||||
|
||||
return Router
|
||||
|
27
backend/router/common.go
Normal file
27
backend/router/common.go
Normal file
@ -0,0 +1,27 @@
|
||||
package router
|
||||
|
||||
func commonGroups() []CommonRouter {
|
||||
return []CommonRouter{
|
||||
&BaseRouter{},
|
||||
&DashboardRouter{},
|
||||
&HostRouter{},
|
||||
&ContainerRouter{},
|
||||
&MonitorRouter{},
|
||||
&LogRouter{},
|
||||
&FileRouter{},
|
||||
&ToolboxRouter{},
|
||||
&TerminalRouter{},
|
||||
&CronjobRouter{},
|
||||
&SettingRouter{},
|
||||
&AppRouter{},
|
||||
&WebsiteRouter{},
|
||||
&WebsiteGroupRouter{},
|
||||
&WebsiteDnsAccountRouter{},
|
||||
&WebsiteAcmeAccountRouter{},
|
||||
&WebsiteSSLRouter{},
|
||||
&DatabaseRouter{},
|
||||
&NginxRouter{},
|
||||
&RuntimeRouter{},
|
||||
&ProcessRouter{},
|
||||
}
|
||||
}
|
@ -1,27 +1,9 @@
|
||||
//go:build !xpack
|
||||
|
||||
package router
|
||||
|
||||
type RouterGroup struct {
|
||||
BaseRouter
|
||||
DashboardRouter
|
||||
HostRouter
|
||||
ContainerRouter
|
||||
MonitorRouter
|
||||
LogRouter
|
||||
FileRouter
|
||||
ToolboxRouter
|
||||
TerminalRouter
|
||||
CronjobRouter
|
||||
SettingRouter
|
||||
AppRouter
|
||||
WebsiteRouter
|
||||
WebsiteGroupRouter
|
||||
WebsiteDnsAccountRouter
|
||||
WebsiteAcmeAccountRouter
|
||||
WebsiteSSLRouter
|
||||
DatabaseRouter
|
||||
NginxRouter
|
||||
RuntimeRouter
|
||||
ProcessRouter
|
||||
func RouterGroups() []CommonRouter {
|
||||
return commonGroups()
|
||||
}
|
||||
|
||||
var RouterGroupApp = new(RouterGroup)
|
||||
var RouterGroupApp = RouterGroups()
|
||||
|
11
backend/router/entry_xpack.go
Normal file
11
backend/router/entry_xpack.go
Normal file
@ -0,0 +1,11 @@
|
||||
//go:build xpack
|
||||
|
||||
package router
|
||||
|
||||
import "github.com/1Panel-dev/1Panel/backend/xpack/router"
|
||||
|
||||
func RouterGroups() []CommonRouter {
|
||||
return append(commonGroups(), []CommonRouter{&router.WafRouter{}}...)
|
||||
}
|
||||
|
||||
var RouterGroupApp = RouterGroups()
|
@ -9,7 +9,7 @@ import (
|
||||
type AppRouter struct {
|
||||
}
|
||||
|
||||
func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) {
|
||||
func (a *AppRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
appRouter := Router.Group("apps")
|
||||
appRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type BaseRouter struct{}
|
||||
|
||||
func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) {
|
||||
func (s *BaseRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
baseRouter := Router.Group("auth")
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
type ContainerRouter struct{}
|
||||
|
||||
func (s *ContainerRouter) InitContainerRouter(Router *gin.RouterGroup) {
|
||||
func (s *ContainerRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
baRouter := Router.Group("containers").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type CronjobRouter struct{}
|
||||
|
||||
func (s *CronjobRouter) InitCronjobRouter(Router *gin.RouterGroup) {
|
||||
func (s *CronjobRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
cmdRouter := Router.Group("cronjobs").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type DashboardRouter struct{}
|
||||
|
||||
func (s *CronjobRouter) InitDashboardRouter(Router *gin.RouterGroup) {
|
||||
func (s *DashboardRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
cmdRouter := Router.Group("dashboard").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type DatabaseRouter struct{}
|
||||
|
||||
func (s *DatabaseRouter) InitDatabaseRouter(Router *gin.RouterGroup) {
|
||||
func (s *DatabaseRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
cmdRouter := Router.Group("databases").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type FileRouter struct {
|
||||
}
|
||||
|
||||
func (f *FileRouter) InitFileRouter(Router *gin.RouterGroup) {
|
||||
func (f *FileRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
fileRouter := Router.Group("files")
|
||||
fileRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WebsiteGroupRouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteGroupRouter) InitWebsiteGroupRouter(Router *gin.RouterGroup) {
|
||||
func (a *WebsiteGroupRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("groups")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type HostRouter struct{}
|
||||
|
||||
func (s *HostRouter) InitHostRouter(Router *gin.RouterGroup) {
|
||||
func (s *HostRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
hostRouter := Router.Group("hosts").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type LogRouter struct{}
|
||||
|
||||
func (s *LogRouter) InitLogRouter(Router *gin.RouterGroup) {
|
||||
func (s *LogRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
operationRouter := Router.Group("logs")
|
||||
operationRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type MonitorRouter struct{}
|
||||
|
||||
func (s *MonitorRouter) InitMonitorRouter(Router *gin.RouterGroup) {
|
||||
func (s *MonitorRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
monitorRouter := Router.Group("monitors").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type NginxRouter struct {
|
||||
}
|
||||
|
||||
func (a *NginxRouter) InitNginxRouter(Router *gin.RouterGroup) {
|
||||
func (a *NginxRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("openresty")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type ProcessRouter struct {
|
||||
}
|
||||
|
||||
func (f *ProcessRouter) InitProcessRouter(Router *gin.RouterGroup) {
|
||||
func (f *ProcessRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
processRouter := Router.Group("process")
|
||||
processRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
baseApi := v1.ApiGroupApp.BaseApi
|
||||
|
7
backend/router/ro_router.go
Normal file
7
backend/router/ro_router.go
Normal file
@ -0,0 +1,7 @@
|
||||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
type CommonRouter interface {
|
||||
InitRouter(Router *gin.RouterGroup)
|
||||
}
|
@ -9,7 +9,7 @@ import (
|
||||
type RuntimeRouter struct {
|
||||
}
|
||||
|
||||
func (r *RuntimeRouter) InitRuntimeRouter(Router *gin.RouterGroup) {
|
||||
func (r *RuntimeRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("runtimes")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
type SettingRouter struct{}
|
||||
|
||||
func (s *SettingRouter) InitSettingRouter(Router *gin.RouterGroup) {
|
||||
func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
router := Router.Group("settings").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth())
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type TerminalRouter struct{}
|
||||
|
||||
func (s *TerminalRouter) InitTerminalRouter(Router *gin.RouterGroup) {
|
||||
func (s *TerminalRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
terminalRouter := Router.Group("terminals").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
type ToolboxRouter struct{}
|
||||
|
||||
func (s *ToolboxRouter) InitToolboxRouter(Router *gin.RouterGroup) {
|
||||
func (s *ToolboxRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
toolboxRouter := Router.Group("toolbox").
|
||||
Use(middleware.JwtAuth()).
|
||||
Use(middleware.SessionAuth()).
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WebsiteRouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteRouter) InitWebsiteRouter(Router *gin.RouterGroup) {
|
||||
func (a *WebsiteRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("websites")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WebsiteAcmeAccountRouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteAcmeAccountRouter) InitWebsiteAcmeAccountRouter(Router *gin.RouterGroup) {
|
||||
func (a *WebsiteAcmeAccountRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("websites/acme")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -6,7 +6,10 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (a *WebsiteDnsAccountRouter) InitWebsiteCARouter(Router *gin.RouterGroup) {
|
||||
type WebsiteCARouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteCARouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("websites/ca")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WebsiteDnsAccountRouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteDnsAccountRouter) InitWebsiteDnsAccountRouter(Router *gin.RouterGroup) {
|
||||
func (a *WebsiteDnsAccountRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("websites/dns")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
type WebsiteSSLRouter struct {
|
||||
}
|
||||
|
||||
func (a *WebsiteSSLRouter) InitWebsiteSSLRouter(Router *gin.RouterGroup) {
|
||||
func (a *WebsiteSSLRouter) InitRouter(Router *gin.RouterGroup) {
|
||||
groupRouter := Router.Group("websites/ssl")
|
||||
groupRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
|
||||
|
||||
|
@ -16,3 +16,5 @@ VITE_BUILD_GZIP = false
|
||||
# 是否删除生产环境 console
|
||||
VITE_DROP_CONSOLE = true
|
||||
|
||||
|
||||
PANEL_XPACK = false
|
@ -5,9 +5,11 @@ NODE_ENV = 'development'
|
||||
VITE_API_URL = '/api/v1'
|
||||
|
||||
# 是否生成包预览文件
|
||||
VITE_REPORT = true
|
||||
VITE_REPORT = false
|
||||
|
||||
# 是否开启gzip压缩
|
||||
VITE_BUILD_GZIP = true
|
||||
|
||||
VITE_DROP_CONSOLE = true
|
||||
VITE_DROP_CONSOLE = true
|
||||
|
||||
PANEL_XPACK = true
|
@ -11,3 +11,5 @@ VITE_REPORT = true
|
||||
VITE_BUILD_GZIP = true
|
||||
|
||||
VITE_DROP_CONSOLE = true
|
||||
|
||||
PANEL_XPACK = true
|
||||
|
@ -1,4 +1,4 @@
|
||||
import axios, { AxiosInstance, AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import axios, { AxiosInstance, AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||
import { ResultData } from '@/api/interface';
|
||||
import { ResultEnum } from '@/enums/http-enum';
|
||||
import { checkStatus } from './helper/check-status';
|
||||
@ -32,7 +32,7 @@ class RequestHttp {
|
||||
}
|
||||
return {
|
||||
...config,
|
||||
};
|
||||
} as InternalAxiosRequestConfig<any>;
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
return Promise.reject(error);
|
||||
|
@ -1,7 +1,11 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
|
||||
import { Layout } from '@/routers/constant';
|
||||
|
||||
const modules = import.meta.globEager('./modules/*.ts');
|
||||
let modules = import.meta.globEager('./modules/*.ts');
|
||||
const xpackModules = import.meta.globEager('../xpack/frontend/routers/*.ts');
|
||||
modules = { ...modules, ...xpackModules };
|
||||
|
||||
console.log(modules);
|
||||
|
||||
const homeRouter: RouteRecordRaw = {
|
||||
path: '/',
|
||||
|
1
frontend/src/typings/global.d.ts
vendored
1
frontend/src/typings/global.d.ts
vendored
@ -20,6 +20,7 @@ declare interface ViteEnv {
|
||||
VITE_PROXY_URL: string;
|
||||
VITE_BUILD_GZIP: boolean;
|
||||
VITE_REPORT: boolean;
|
||||
PANEL_XPACK: boolean;
|
||||
}
|
||||
|
||||
declare interface RouterButton {
|
||||
|
Loading…
Reference in New Issue
Block a user