diff --git a/.gitignore b/.gitignore index 5ff62b68e0be..9e6e605606ce 100644 --- a/.gitignore +++ b/.gitignore @@ -41,20 +41,10 @@ core/cmd/server/web/index.html frontend/auto-imports.d.ts frontend/components.d.ts frontend/src/xpack +frontend/src/xpack-ee agent/xpack -agent/router/entry_xpack.go -agent/server/init_xpack.go -agent/utils/xpack/xpack.go -agent/utils/xpack/xpack_xpack.go core/xpack -core/router/entry_xpack.go -core/server/init_xpack.go -core/utils/xpack/xpack.go -core/utils/xpack/xpack_xpack.go core/xpack-ee -core/router/entry_xpackee.go -core/server/init_xpackee.go -core/utils/xpack/xpack_xpackee.go .history/ dist/ diff --git a/agent/router/entry.go b/agent/router/entry.go index 49ed25fd1d0c..f3b657c3e06b 100644 --- a/agent/router/entry.go +++ b/agent/router/entry.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package router diff --git a/agent/router/entry_xpack.go b/agent/router/entry_xpack.go new file mode 100644 index 000000000000..b311f38ec99e --- /dev/null +++ b/agent/router/entry_xpack.go @@ -0,0 +1,19 @@ +//go:build xpack + +package router + +import ( + xpackRouter "github.com/1Panel-dev/1Panel/agent/xpack/router" +) + +func RouterGroups() []CommonRouter { + baseRouter := commonGroups() + for _, ro := range xpackRouter.XpackGroups() { + if val, ok := ro.(CommonRouter); ok { + baseRouter = append(baseRouter, val) + } + } + return baseRouter +} + +var RouterGroupApp = RouterGroups() diff --git a/agent/server/init.go b/agent/server/init.go index b8ed30b470cc..4d71d0f1dd6c 100644 --- a/agent/server/init.go +++ b/agent/server/init.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package server diff --git a/agent/server/init_xpack.go b/agent/server/init_xpack.go new file mode 100644 index 000000000000..f771928e998e --- /dev/null +++ b/agent/server/init_xpack.go @@ -0,0 +1,11 @@ +//go:build xpack + +package server + +import ( + xpack "github.com/1Panel-dev/1Panel/agent/xpack" +) + +func InitOthers() { + xpack.Init() +} diff --git a/agent/utils/xpack/community.go b/agent/utils/xpack/community.go index 4d4f6f4a8220..f7d137ca990b 100644 --- a/agent/utils/xpack/community.go +++ b/agent/utils/xpack/community.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package xpack diff --git a/agent/utils/xpack/xpack.go b/agent/utils/xpack/xpack.go new file mode 100644 index 000000000000..ddc3031027ab --- /dev/null +++ b/agent/utils/xpack/xpack.go @@ -0,0 +1,74 @@ +//go:build xpack + +package xpack + +import ( + "net/http" + + "github.com/1Panel-dev/1Panel/agent/app/dto" + "github.com/1Panel-dev/1Panel/agent/app/model" + edition "github.com/1Panel-dev/1Panel/agent/xpack/edition" + "github.com/gin-gonic/gin" +) + +func RemoveTamper(website string) { + edition.RemoveTamper(website) +} + +func StartClam(startClam *model.Clam, isUpdate bool) (int, error) { + return edition.StartClam(startClam, isUpdate) +} + +func LoadNodeInfo(isBase bool) (model.NodeInfo, error) { + return edition.LoadNodeInfo(isBase) +} + +func GetImagePrefix() string { + return edition.GetImagePrefix() +} + +func IsUseCustomApp() bool { + return edition.IsUseCustomApp() +} + +func IsXpack() bool { + return edition.IsXpack() +} + +func CreateTaskScanSMSAlertLog(info dto.AlertDTO, alertType string, create dto.AlertLogCreate, pushAlert dto.PushAlert, method string) error { + return edition.CreateTaskScanSMSAlertLog(info, alertType, create, pushAlert, method) +} + +func CreateSMSAlertLog(alertType string, info dto.AlertDTO, create dto.AlertLogCreate, project string, params []dto.Param, method string) error { + return edition.CreateSMSAlertLog(alertType, info, create, project, params, method) +} + +func CreateTaskScanWebhookAlertLog(alert dto.AlertDTO, alertType string, create dto.AlertLogCreate, pushAlert dto.PushAlert, method string, transport *http.Transport, agentInfo *dto.AgentInfo) error { + return edition.CreateTaskScanWebhookAlertLog(alert, alertType, create, pushAlert, method, transport, agentInfo) +} + +func CreateWebhookAlertLog(alertType string, info dto.AlertDTO, create dto.AlertLogCreate, project string, params []dto.Param, method string, transport *http.Transport, agentInfo *dto.AgentInfo) error { + return edition.CreateWebhookAlertLog(alertType, info, create, project, params, method, transport, agentInfo) +} + +func GetLicenseErrorAlert() (uint, error) { + return edition.GetLicenseErrorAlert() +} + +func GetNodeErrorAlert() (uint, error) { + return edition.GetNodeErrorAlert() +} + +func LoadRequestTransport() *http.Transport { return edition.LoadRequestTransport() } + +func ValidateCertificate(c *gin.Context) bool { + return edition.ValidateCertificate(c) +} + +func PushSSLToNode(websiteSSL *model.WebsiteSSL) error { + return edition.PushSSLToNode(websiteSSL) +} + +func GetAgentInfo() (*dto.AgentInfo, error) { + return edition.GetAgentInfo() +} diff --git a/core/router/entry.go b/core/router/entry.go index 49ed25fd1d0c..f3b657c3e06b 100644 --- a/core/router/entry.go +++ b/core/router/entry.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package router diff --git a/core/router/entry_xpack.go b/core/router/entry_xpack.go new file mode 100644 index 000000000000..8b4e49688fb2 --- /dev/null +++ b/core/router/entry_xpack.go @@ -0,0 +1,19 @@ +//go:build xpack + +package router + +import ( + xpackRouter "github.com/1Panel-dev/1Panel/core/xpack/router" +) + +func RouterGroups() []CommonRouter { + baseRouter := commonGroups() + for _, ro := range xpackRouter.XpackGroups() { + if val, ok := ro.(CommonRouter); ok { + baseRouter = append(baseRouter, val) + } + } + return baseRouter +} + +var RouterGroupApp = RouterGroups() diff --git a/core/router/entry_xpackee.go b/core/router/entry_xpackee.go new file mode 100644 index 000000000000..7d4d501905c6 --- /dev/null +++ b/core/router/entry_xpackee.go @@ -0,0 +1,25 @@ +//go:build xpackee + +package router + +import ( + xpackEERouter "github.com/1Panel-dev/1Panel/core/xpack-ee/router" + xpackRouter "github.com/1Panel-dev/1Panel/core/xpack/router" +) + +func RouterGroups() []CommonRouter { + baseRouter := commonGroups() + for _, ro := range xpackRouter.XpackGroups() { + if val, ok := ro.(CommonRouter); ok { + baseRouter = append(baseRouter, val) + } + } + for _, ro := range xpackEERouter.XpackEEGroups() { + if val, ok := ro.(CommonRouter); ok { + baseRouter = append(baseRouter, val) + } + } + return baseRouter +} + +var RouterGroupApp = RouterGroups() diff --git a/core/server/init.go b/core/server/init.go index b8ed30b470cc..4d71d0f1dd6c 100644 --- a/core/server/init.go +++ b/core/server/init.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package server diff --git a/core/server/init_xpack.go b/core/server/init_xpack.go new file mode 100644 index 000000000000..404bc6b5baa0 --- /dev/null +++ b/core/server/init_xpack.go @@ -0,0 +1,11 @@ +//go:build xpack + +package server + +import ( + xpack "github.com/1Panel-dev/1Panel/core/xpack" +) + +func InitOthers() { + xpack.Init() +} diff --git a/core/server/init_xpackee.go b/core/server/init_xpackee.go new file mode 100644 index 000000000000..b8932cccff69 --- /dev/null +++ b/core/server/init_xpackee.go @@ -0,0 +1,13 @@ +//go:build xpackee + +package server + +import ( + xpack "github.com/1Panel-dev/1Panel/core/xpack" + xpackEE "github.com/1Panel-dev/1Panel/core/xpack-ee" +) + +func InitOthers() { + xpack.Init() + xpackEE.Init() +} diff --git a/core/utils/xpack/community.go b/core/utils/xpack/community.go index 8f79183654ed..90bbf2c0fc10 100644 --- a/core/utils/xpack/community.go +++ b/core/utils/xpack/community.go @@ -1,4 +1,4 @@ -//go:build !xpack +//go:build !xpack && !xpackee package xpack diff --git a/core/utils/xpack/xpack.go b/core/utils/xpack/xpack.go new file mode 100644 index 000000000000..155ebaf7ce7c --- /dev/null +++ b/core/utils/xpack/xpack.go @@ -0,0 +1,35 @@ +//go:build xpack + +package xpack + +import ( + "net/http" + + "github.com/1Panel-dev/1Panel/core/utils/ssh" + edition "github.com/1Panel-dev/1Panel/core/xpack/edition" + "github.com/gin-gonic/gin" +) + +func Proxy(c *gin.Context, currentNode string) { + edition.Proxy(c, currentNode) +} + +func ProxyDocker(proxyURL string) error { return edition.ProxyDocker(proxyURL) } + +func UpdateGroup(name string, group, newGroup uint) error { + return edition.UpdateGroup(name, group, newGroup) +} + +func CheckBackupUsed(name string) error { + return edition.CheckBackupUsed(name) +} + +func LoadRequestTransport() *http.Transport { return edition.LoadRequestTransport() } + +func LoadNodeInfo(currentNode string) (*ssh.ConnInfo, string, error) { + return edition.LoadNodeInfo(currentNode) +} + +func Sync(dataType string) error { return edition.Sync(dataType) } + +func AutoUpgradeWithMaster() { edition.AutoUpgradeWithMaster() } diff --git a/core/utils/xpack/xpackee.go b/core/utils/xpack/xpackee.go new file mode 100644 index 000000000000..aa6e5b64f92a --- /dev/null +++ b/core/utils/xpack/xpackee.go @@ -0,0 +1,44 @@ +//go:build xpackee + +package xpack + +import ( + "net/http" + + "github.com/1Panel-dev/1Panel/core/app/dto" + "github.com/1Panel-dev/1Panel/core/utils/ssh" + edition "github.com/1Panel-dev/1Panel/core/xpack-ee/edition" + "github.com/gin-gonic/gin" +) + +func Proxy(c *gin.Context, currentNode string) { + edition.Proxy(c, currentNode) +} + +func ProxyDocker(proxyURL string) error { return edition.ProxyDocker(proxyURL) } + +func UpdateGroup(name string, group, newGroup uint) error { + return edition.UpdateGroup(name, group, newGroup) +} + +func CheckBackupUsed(name string) error { + return edition.CheckBackupUsed(name) +} + +func LoadRequestTransport() *http.Transport { return edition.LoadRequestTransport() } + +func LoadNodeInfo(currentNode string) (*ssh.ConnInfo, string, error) { + return edition.LoadNodeInfo(currentNode) +} + +func Sync(dataType string) error { return edition.Sync(dataType) } + +func AutoUpgradeWithMaster() { edition.AutoUpgradeWithMaster() } + +func Login(c *gin.Context, info dto.Login, entrance string) (*dto.UserLoginInfo, string, error) { + return edition.Login(c, info, entrance) +} + +func MFALogin(c *gin.Context, info dto.MFALogin, entrance string) (*dto.UserLoginInfo, string, error) { + return edition.MFALogin(c, info, entrance) +} diff --git a/frontend/src/components/backup/index.vue b/frontend/src/components/backup/index.vue index e9313c457e94..d684d2ed83ab 100644 --- a/frontend/src/components/backup/index.vue +++ b/frontend/src/components/backup/index.vue @@ -191,18 +191,12 @@ import TaskLog from '@/components/log/task/index.vue'; import { routerToFileWithPath } from '@/utils/router'; import { useGlobalStore } from '@/composables/useGlobalStore'; import { mysqlArgs } from '@/views/cronjob/cronjob/helper'; +import { loadOptionalComponent } from '@/extensions/optional'; const { currentNode } = useGlobalStore(); const emit = defineEmits(['close']); -const PushApp = defineAsyncComponent(async () => { - const modules = import.meta.glob('@/xpack/views/appstore/push-app/index.vue'); - const loader = modules['/src/xpack/views/appstore/push-app/index.vue']; - if (loader) { - return ((await loader()) as any).default; - } - return { template: '
' }; -}); +const PushApp = defineAsyncComponent(() => loadOptionalComponent('/src/xpack/views/appstore/push-app/index.vue')); const selects = ref