1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat: 修改main路径,增加打包静态资源

This commit is contained in:
zhengkunwang223 2022-10-17 16:32:31 +08:00 committed by zhengkunwang223
parent 5f5a48041b
commit 115b75c1cb
120 changed files with 1357 additions and 414 deletions

6
.gitignore vendored
View File

@ -5,6 +5,12 @@
*.so *.so
*.dylib *.dylib
.idea .idea
cmd/server/web/assets/
cmd/server/web/monacoeditorwork
cmd/server/web/favicon.ico
cmd/server/web/index.html
build
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS )
BASE_PAH := $(shell pwd)
BUILD_PATH = $(BASE_PAH)/build
WEB_PATH=$(BASE_PAH)/frontend
SERVER_PATH=$(BASE_PAH)/backend
MAIN= $(BASE_PAH)/cmd/server/main.go
APP_NAME=1panel
build_web:
cd $(WEB_PATH) && npm install && npm run build:dev
build_bin:
cd $(SERVER_PATH) \
&& GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags "-s -w" -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
build_all: build_web build_bin

View File

@ -1,4 +1,4 @@
{ {
"version": "0.0.1", "version": "0.0.3",
"package": "" "package": ""
} }

View File

@ -1,5 +1,5 @@
{ {
"version": "0.1", "version": "0.0.2",
"tags": [ "tags": [
{ {
"key": "WebSite", "key": "WebSite",
@ -56,6 +56,20 @@
"limit": 0, "limit": 0,
"crossVersionUpdate": true, "crossVersionUpdate": true,
"source": "http://wordpress.org/" "source": "http://wordpress.org/"
},
{
"key": "redis",
"name": "redis",
"tags": ["Datastore"],
"versions": ["7.0.5","6.0.16"],
"short_desc": "缓存数据库",
"icon": "redis.png",
"author": "Salvatore Sanfilippo",
"type": "runtime",
"required": [""],
"limit": 0,
"crossVersionUpdate": true,
"source": "https://redis.io/"
} }
] ]
} }

View File

@ -20,3 +20,7 @@ services:
--collation-server=utf8mb4_general_ci --collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true --explicit_defaults_for_timestamp=true
--lower_case_table_names=1 --lower_case_table_names=1
networks:
1panel:
external: true

View File

@ -3,6 +3,8 @@ services:
container_name: ${CONTAINER_NAME} container_name: ${CONTAINER_NAME}
image: nginx:1.23.1 image: nginx:1.23.1
restart: always restart: always
networks:
- 1panel
ports: ports:
- ${PANEL_APP_PORT_HTTP}:80 - ${PANEL_APP_PORT_HTTP}:80
- ${PANEL_APP_PORT_HTTPS}:443 - ${PANEL_APP_PORT_HTTPS}:443
@ -12,3 +14,7 @@ services:
- ./log:/var/log/nginx - ./log:/var/log/nginx
- ./conf/conf.d:/etc/nginx/conf.d/ - ./conf/conf.d:/etc/nginx/conf.d/
- ./html:/usr/share/nginx/html - ./html:/usr/share/nginx/html
networks:
1panel:
external: true

View File

View File

@ -0,0 +1,20 @@
{
"formFields": [
{
"type": "text",
"labelZh": "密码",
"labelEn": "Password",
"required": true,
"default": "eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81",
"envKey": "PANEL_DB_ROOT_PASSWORD"
},
{
"type": "number",
"labelZh": "端口",
"labelEn": "Port",
"required": true,
"default": 6379,
"envKey": "PANEL_APP_PORT_HTTP"
}
]
}

View File

@ -0,0 +1,15 @@
version: '3'
services:
redis-6.0.16:
image: redis:6.0.16
restart: always
networks:
- 1panel
ports:
- ${PANEL_APP_PORT_HTTP}:6379
command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
volumes:
- ./data:/data
networks:
1panel:
external: true

View File

View File

@ -0,0 +1,20 @@
{
"formFields": [
{
"type": "text",
"labelZh": "密码",
"labelEn": "Password",
"required": true,
"default": "eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81",
"envKey": "PANEL_DB_ROOT_PASSWORD"
},
{
"type": "number",
"labelZh": "端口",
"labelEn": "Port",
"required": true,
"default": 6379,
"envKey": "PANEL_APP_PORT_HTTP"
}
]
}

View File

@ -0,0 +1,15 @@
version: '3'
services:
redis-7.0.5:
image: redis:7.0.5
restart: always
networks:
- 1panel
ports:
- ${PANEL_APP_PORT_HTTP}:6379
command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81
volumes:
- ./data:/data
networks:
1panel:
external: true

View File

@ -1,9 +1,9 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"strconv" "strconv"
) )

View File

@ -3,12 +3,12 @@ package v1
import ( import (
"errors" "errors"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/captcha" "github.com/1Panel-dev/1Panel/backend/utils/captcha"
"github.com/1Panel-dev/1Panel/utils/encrypt" "github.com/1Panel-dev/1Panel/backend/utils/encrypt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,10 +1,10 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,10 +1,10 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -4,10 +4,10 @@ import (
"os" "os"
"time" "time"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,6 +1,6 @@
package v1 package v1
import "github.com/1Panel-dev/1Panel/app/service" import "github.com/1Panel-dev/1Panel/backend/app/service"
type ApiGroup struct { type ApiGroup struct {
BaseApi BaseApi

View File

@ -2,11 +2,11 @@ package v1
import ( import (
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
websocket2 "github.com/1Panel-dev/1Panel/utils/websocket" websocket2 "github.com/1Panel-dev/1Panel/backend/utils/websocket"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"net/http" "net/http"

View File

@ -1,10 +1,10 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -6,9 +6,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/i18n" "github.com/1Panel-dev/1Panel/backend/i18n"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,12 +1,12 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/copier" "github.com/1Panel-dev/1Panel/backend/utils/copier"
"github.com/1Panel-dev/1Panel/utils/ssh" "github.com/1Panel-dev/1Panel/backend/utils/ssh"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,11 +3,11 @@ package v1
import ( import (
"time" "time"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/shirou/gopsutil/net" "github.com/shirou/gopsutil/net"
) )

View File

@ -1,10 +1,10 @@
package v1 package v1
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,12 +3,12 @@ package v1
import ( import (
"errors" "errors"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/mfa" "github.com/1Panel-dev/1Panel/backend/utils/mfa"
"github.com/1Panel-dev/1Panel/utils/ntp" "github.com/1Panel-dev/1Panel/backend/utils/ntp"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -5,12 +5,12 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/copier" "github.com/1Panel-dev/1Panel/backend/utils/copier"
"github.com/1Panel-dev/1Panel/utils/ssh" "github.com/1Panel-dev/1Panel/backend/utils/ssh"
"github.com/1Panel-dev/1Panel/utils/terminal" "github.com/1Panel-dev/1Panel/backend/utils/terminal"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@ -2,7 +2,7 @@ package dto
import ( import (
"encoding/json" "encoding/json"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
) )
type AppRes struct { type AppRes struct {

View File

@ -1,7 +1,7 @@
package dto package dto
import ( import (
"github.com/1Panel-dev/1Panel/utils/files" "github.com/1Panel-dev/1Panel/backend/utils/files"
) )
type FileOption struct { type FileOption struct {

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"path" "path"
) )

View File

@ -2,9 +2,10 @@ package model
type AppInstallBackup struct { type AppInstallBackup struct {
BaseModel BaseModel
Name string `gorm:"type:varchar(64);not null" json:"name"` Name string `gorm:"type:varchar(64);not null" json:"name"`
Path string `gorm:"type:varchar(64);not null" json:"path"` Path string `gorm:"type:varchar(64);not null" json:"path"`
Param string `gorm:"type:longtext;" json:"param"` Param string `gorm:"type:longtext;" json:"param"`
AppDetailId uint `gorm:"type:integer;not null" json:"app_detail_id"` AppDetailId uint `gorm:"type:integer;not null" json:"app_detail_id"`
AppInstallId uint `gorm:"type:integer;not null" json:"app_install_id"` AppInstallId uint `gorm:"type:integer;not null" json:"app_install_id"`
AppDetail AppDetail `json:"-"`
} }

View File

@ -2,7 +2,7 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )

View File

@ -2,7 +2,7 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,7 +2,7 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,7 +2,7 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
@ -20,12 +20,13 @@ func (a AppInstallBackupRepo) Create(ctx context.Context, backup model.AppInstal
return getTx(ctx).Omit(clause.Associations).Create(&backup).Error return getTx(ctx).Omit(clause.Associations).Create(&backup).Error
} }
func (a AppInstallBackupRepo) Delete(opts ...DBOption) error { func (a AppInstallBackupRepo) Delete(ctx context.Context, opts ...DBOption) error {
return getDb(opts...).Omit(clause.Associations).Delete(&model.AppInstallBackup{}).Error return getTx(ctx, opts...).Omit(clause.Associations).Delete(&model.AppInstallBackup{}).Error
} }
func (a AppInstallBackupRepo) GetBy(opts ...DBOption) ([]model.AppInstallBackup, error) { func (a AppInstallBackupRepo) GetBy(opts ...DBOption) ([]model.AppInstallBackup, error) {
var backups []model.AppInstallBackup var backups []model.AppInstallBackup
if err := getDb(opts...).Find(&backups); err != nil { if err := getDb(opts...).Preload("AppDetail").Find(&backups); err != nil {
return backups, nil return backups, nil
} }
return backups, nil return backups, nil
@ -34,7 +35,7 @@ func (a AppInstallBackupRepo) GetBy(opts ...DBOption) ([]model.AppInstallBackup,
func (a AppInstallBackupRepo) GetFirst(opts ...DBOption) (model.AppInstallBackup, error) { func (a AppInstallBackupRepo) GetFirst(opts ...DBOption) (model.AppInstallBackup, error) {
var backup model.AppInstallBackup var backup model.AppInstallBackup
db := getDb(opts...).Model(&model.AppInstallBackup{}) db := getDb(opts...).Model(&model.AppInstallBackup{})
err := db.First(&backup).Error err := db.Preload("AppDetail").First(&backup).Error
return backup, err return backup, err
} }
@ -43,6 +44,6 @@ func (a AppInstallBackupRepo) Page(page, size int, opts ...DBOption) (int64, []m
db := getDb(opts...).Model(&model.AppInstallBackup{}) db := getDb(opts...).Model(&model.AppInstallBackup{})
count := int64(0) count := int64(0)
db = db.Count(&count) db = db.Count(&count)
err := db.Debug().Limit(size).Offset(size * (page - 1)).Find(&backups).Error err := db.Limit(size).Offset(size * (page - 1)).Preload("AppDetail").Find(&backups).Error
return count, backups, err return count, backups, err
} }

View File

@ -2,8 +2,8 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,8 +2,8 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
) )
type BackupRepo struct{} type BackupRepo struct{}

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,7 +2,7 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -3,9 +3,9 @@ package repo
import ( import (
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,8 +2,8 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
) )
type OperationRepo struct{} type OperationRepo struct{}

View File

@ -1,8 +1,8 @@
package repo package repo
import ( import (
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -2,8 +2,8 @@ package repo
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -5,15 +5,15 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/app/repo" "github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/common" "github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/1Panel-dev/1Panel/utils/compose" "github.com/1Panel-dev/1Panel/backend/utils/compose"
"github.com/1Panel-dev/1Panel/utils/docker" "github.com/1Panel-dev/1Panel/backend/utils/docker"
"github.com/1Panel-dev/1Panel/utils/files" "github.com/1Panel-dev/1Panel/backend/utils/files"
"golang.org/x/net/context" "golang.org/x/net/context"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"os" "os"
@ -175,35 +175,9 @@ func (a AppService) OperateInstall(req dto.AppInstallOperate) error {
} }
install.Status = constant.Running install.Status = constant.Running
case dto.Delete: case dto.Delete:
op := files.NewFileOp() return deleteAppInstall(install)
appDir := install.GetPath()
dir, _ := os.Stat(appDir)
if dir != nil {
out, err := compose.Down(dockerComposePath)
if err != nil {
return handleErr(install, err, out)
}
if err := op.DeleteDir(appDir); err != nil {
return err
}
}
tx, ctx := getTxAndContext()
if err := appInstallRepo.Delete(ctx, install); err != nil {
tx.Rollback()
return err
}
if err := deleteLink(ctx, &install); err != nil {
tx.Rollback()
return err
}
tx.Commit()
return nil
case dto.Sync: case dto.Sync:
if err := a.SyncInstalled(install.ID); err != nil { return a.SyncInstalled(install.ID)
return err
}
return nil
case dto.Backup: case dto.Backup:
tx, ctx := getTxAndContext() tx, ctx := getTxAndContext()
if err := backupInstall(ctx, install); err != nil { if err := backupInstall(ctx, install); err != nil {
@ -213,11 +187,7 @@ func (a AppService) OperateInstall(req dto.AppInstallOperate) error {
tx.Commit() tx.Commit()
return nil return nil
case dto.Restore: case dto.Restore:
installBackup, err := appInstallBackupRepo.GetFirst(commonRepo.WithByID(req.BackupId)) return restoreInstall(install, req.BackupId)
if err != nil {
return err
}
return restoreInstall(install, installBackup)
case dto.Update: case dto.Update:
return updateInstall(install.ID, req.DetailId) return updateInstall(install.ID, req.DetailId)
default: default:
@ -344,7 +314,7 @@ func (a AppService) DeleteBackup(req dto.AppBackupDeleteRequest) error {
errStr.WriteString(err.Error()) errStr.WriteString(err.Error())
continue continue
} }
if err := appInstallBackupRepo.Delete(commonRepo.WithIdsIn(req.Ids)); err != nil { if err := appInstallBackupRepo.Delete(nil, commonRepo.WithIdsIn(req.Ids)); err != nil {
errStr.WriteString(err.Error()) errStr.WriteString(err.Error())
} }
} }

View File

@ -4,14 +4,14 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/cmd" "github.com/1Panel-dev/1Panel/backend/utils/cmd"
"github.com/1Panel-dev/1Panel/utils/common" "github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/1Panel-dev/1Panel/utils/compose" "github.com/1Panel-dev/1Panel/backend/utils/compose"
"github.com/1Panel-dev/1Panel/utils/files" "github.com/1Panel-dev/1Panel/backend/utils/files"
"github.com/joho/godotenv" "github.com/joho/godotenv"
"github.com/pkg/errors" "github.com/pkg/errors"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
@ -140,6 +140,37 @@ func createLink(ctx context.Context, app model.App, appInstall *model.AppInstall
return nil return nil
} }
func deleteAppInstall(install model.AppInstall) error {
op := files.NewFileOp()
appDir := install.GetPath()
dir, _ := os.Stat(appDir)
if dir != nil {
out, err := compose.Down(install.GetComposePath())
if err != nil {
return handleErr(install, err, out)
}
if err := op.DeleteDir(appDir); err != nil {
return err
}
}
tx, ctx := getTxAndContext()
if err := appInstallRepo.Delete(ctx, install); err != nil {
tx.Rollback()
return err
}
if err := deleteLink(ctx, &install); err != nil {
tx.Rollback()
return err
}
if err := appInstallBackupRepo.Delete(ctx, appInstallBackupRepo.WithAppInstallID(install.ID)); err != nil {
tx.Rollback()
return err
}
tx.Commit()
return nil
}
func deleteLink(ctx context.Context, install *model.AppInstall) error { func deleteLink(ctx context.Context, install *model.AppInstall) error {
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID)) resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
if len(resources) == 0 { if len(resources) == 0 {
@ -171,12 +202,20 @@ func updateInstall(installId uint, detailId uint) error {
if err != nil { if err != nil {
return err return err
} }
oldDetail, err := appDetailRepo.GetFirst(commonRepo.WithByID(install.AppDetailId))
if err != nil {
return err
}
detail, err := appDetailRepo.GetFirst(commonRepo.WithByID(detailId)) detail, err := appDetailRepo.GetFirst(commonRepo.WithByID(detailId))
if err != nil { if err != nil {
return err return err
} }
if oldDetail.LastVersion == detail.Version {
install.CanUpdate = false
}
if install.Version == detail.Version { if install.Version == detail.Version {
return errors.New("two version is save") return errors.New("two version is same")
} }
tx, ctx := getTxAndContext() tx, ctx := getTxAndContext()
if err := backupInstall(ctx, install); err != nil { if err := backupInstall(ctx, install); err != nil {
@ -188,6 +227,7 @@ func updateInstall(installId uint, detailId uint) error {
} }
install.DockerCompose = detail.DockerCompose install.DockerCompose = detail.DockerCompose
install.Version = detail.Version install.Version = detail.Version
fileOp := files.NewFileOp() fileOp := files.NewFileOp()
if err := fileOp.WriteFile(install.GetComposePath(), strings.NewReader(install.DockerCompose), 0775); err != nil { if err := fileOp.WriteFile(install.GetComposePath(), strings.NewReader(install.DockerCompose), 0775); err != nil {
return err return err
@ -221,7 +261,11 @@ func backupInstall(ctx context.Context, install model.AppInstall) error {
return nil return nil
} }
func restoreInstall(install model.AppInstall, backup model.AppInstallBackup) error { func restoreInstall(install model.AppInstall, backupId uint) error {
backup, err := appInstallBackupRepo.GetFirst(commonRepo.WithByID(backupId))
if err != nil {
return err
}
if _, err := compose.Down(install.GetComposePath()); err != nil { if _, err := compose.Down(install.GetComposePath()); err != nil {
return err return err
} }
@ -284,6 +328,7 @@ func restoreInstall(install model.AppInstall, backup model.AppInstallBackup) err
return handleErr(install, err, out) return handleErr(install, err, out)
} }
install.AppDetailId = backup.AppDetailId install.AppDetailId = backup.AppDetailId
install.Version = backup.AppDetail.Version
install.Status = constant.Running install.Status = constant.Running
return appInstallRepo.Save(&install) return appInstallRepo.Save(&install)
} }

View File

@ -3,11 +3,11 @@ package service
import ( import (
"strconv" "strconv"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/encrypt" "github.com/1Panel-dev/1Panel/backend/utils/encrypt"
"github.com/1Panel-dev/1Panel/utils/jwt" "github.com/1Panel-dev/1Panel/backend/utils/jwt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/pkg/errors" "github.com/pkg/errors"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"

View File

@ -3,10 +3,10 @@ package service
import ( import (
"encoding/json" "encoding/json"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/utils/cloud_storage" "github.com/1Panel-dev/1Panel/backend/utils/cloud_storage"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -1,9 +1,9 @@
package service package service
import ( import (
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -8,11 +8,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/cloud_storage" "github.com/1Panel-dev/1Panel/backend/utils/cloud_storage"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"

View File

@ -11,10 +11,10 @@ import (
"strings" "strings"
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/cloud_storage" "github.com/1Panel-dev/1Panel/backend/utils/cloud_storage"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
) )

View File

@ -1,6 +1,6 @@
package service package service
import "github.com/1Panel-dev/1Panel/app/repo" import "github.com/1Panel-dev/1Panel/backend/app/repo"
type ServiceGroup struct { type ServiceGroup struct {
AuthService AuthService

View File

@ -2,10 +2,10 @@ package service
import ( import (
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/common" "github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/1Panel-dev/1Panel/utils/files" "github.com/1Panel-dev/1Panel/backend/utils/files"
"github.com/pkg/errors" "github.com/pkg/errors"
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"
"io/fs" "io/fs"

View File

@ -1,8 +1,8 @@
package service package service
import ( import (
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -2,7 +2,7 @@ package service
import ( import (
"context" "context"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -3,9 +3,9 @@ package service
import ( import (
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -3,10 +3,10 @@ package service
import ( import (
"encoding/json" "encoding/json"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View File

@ -5,10 +5,10 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/utils/encrypt" "github.com/1Panel-dev/1Panel/backend/utils/encrypt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,11 +3,11 @@ package cron
import ( import (
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/app/service" "github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/cron/job" "github.com/1Panel-dev/1Panel/backend/cron/job"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
) )

View File

@ -4,9 +4,9 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/app/repo" "github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk" "github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/load" "github.com/shirou/gopsutil/load"

View File

@ -1,9 +1,9 @@
package global package global
import ( import (
"github.com/1Panel-dev/1Panel/configs" "github.com/1Panel-dev/1Panel/backend/configs"
"github.com/1Panel-dev/1Panel/init/cache/badger_db" "github.com/1Panel-dev/1Panel/backend/init/cache/badger_db"
"github.com/1Panel-dev/1Panel/init/session/psession" "github.com/1Panel-dev/1Panel/backend/init/session/psession"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"

View File

@ -1,8 +1,8 @@
package cache package cache
import ( import (
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/init/cache/badger_db" "github.com/1Panel-dev/1Panel/backend/init/cache/badger_db"
"github.com/dgraph-io/badger/v3" "github.com/dgraph-io/badger/v3"
"time" "time"
) )

View File

@ -1,6 +1,6 @@
package db package db
import "github.com/1Panel-dev/1Panel/global" import "github.com/1Panel-dev/1Panel/backend/global"
func Init() { func Init() {
switch global.CONF.System.DbType { switch global.CONF.System.DbType {

View File

@ -1,7 +1,7 @@
package db package db
import ( import (
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"

View File

@ -1,7 +1,7 @@
package db package db
import ( import (
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"gorm.io/driver/sqlite" "gorm.io/driver/sqlite"
"gorm.io/gorm" "gorm.io/gorm"

View File

@ -6,8 +6,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/1Panel-dev/1Panel/configs" "github.com/1Panel-dev/1Panel/backend/configs"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/natefinch/lumberjack" "github.com/natefinch/lumberjack"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -45,7 +45,7 @@ func (s *MineFormatter) Format(entry *logrus.Entry) ([]byte, error) {
var cstSh, _ = time.LoadLocation(global.CONF.LogConfig.TimeZone) var cstSh, _ = time.LoadLocation(global.CONF.LogConfig.TimeZone)
detailInfo := "" detailInfo := ""
if entry.Caller != nil { if entry.Caller != nil {
funcion := strings.ReplaceAll(entry.Caller.Function, "github.com/1Panel-dev/1Panel/", "") funcion := strings.ReplaceAll(entry.Caller.Function, "github.com/1Panel-dev/1Panel/backend/", "")
detailInfo = fmt.Sprintf("(%s: %d)", funcion, entry.Caller.Line) detailInfo = fmt.Sprintf("(%s: %d)", funcion, entry.Caller.Line)
} }
if len(entry.Data) == 0 { if len(entry.Data) == 0 {

View File

@ -1,8 +1,8 @@
package migration package migration
import ( import (
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/init/migration/migrations" "github.com/1Panel-dev/1Panel/backend/init/migration/migrations"
"github.com/go-gormigrate/gormigrate/v2" "github.com/go-gormigrate/gormigrate/v2"
) )

View File

@ -3,7 +3,7 @@ package migrations
import ( import (
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/go-gormigrate/gormigrate/v2" "github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm" "gorm.io/gorm"

View File

@ -1,17 +1,16 @@
package router package router
import ( import (
"html/template" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/backend/docs"
v1 "github.com/1Panel-dev/1Panel/app/api/v1" "github.com/1Panel-dev/1Panel/backend/i18n"
"github.com/1Panel-dev/1Panel/docs" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/1Panel-dev/1Panel/i18n" rou "github.com/1Panel-dev/1Panel/backend/router"
"github.com/1Panel-dev/1Panel/middleware"
rou "github.com/1Panel-dev/1Panel/router"
ginI18n "github.com/gin-contrib/i18n" ginI18n "github.com/gin-contrib/i18n"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
swaggerfiles "github.com/swaggo/files" swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"html/template"
) )
func Routers() *gin.Engine { func Routers() *gin.Engine {

View File

@ -2,7 +2,7 @@ package psession
import ( import (
"encoding/json" "encoding/json"
"github.com/1Panel-dev/1Panel/init/cache/badger_db" "github.com/1Panel-dev/1Panel/backend/init/cache/badger_db"
"time" "time"
) )

View File

@ -1,8 +1,8 @@
package session package session
import ( import (
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/init/session/psession" "github.com/1Panel-dev/1Panel/backend/init/session/psession"
) )
func Init() { func Init() {

View File

@ -4,7 +4,7 @@ import (
"regexp" "regexp"
"unicode" "unicode"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
) )

View File

@ -2,9 +2,9 @@ package viper
import ( import (
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/configs" "github.com/1Panel-dev/1Panel/backend/configs"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"path" "path"
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"

View File

@ -1,7 +0,0 @@
package main
import "github.com/1Panel-dev/1Panel/server"
func main() {
server.Start()
}

View File

@ -3,8 +3,8 @@ package middleware
import ( import (
"net/http" "net/http"
"github.com/1Panel-dev/1Panel/configs" "github.com/1Panel-dev/1Panel/backend/configs"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,7 +3,7 @@ package middleware
import ( import (
"net/http" "net/http"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/csrf" "github.com/gorilla/csrf"
adapter "github.com/gwatts/gin-adapter" adapter "github.com/gwatts/gin-adapter"

View File

@ -4,11 +4,11 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/repo" "github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
jwtUtils "github.com/1Panel-dev/1Panel/utils/jwt" jwtUtils "github.com/1Panel-dev/1Panel/backend/utils/jwt"
"github.com/golang-jwt/jwt/v4" "github.com/golang-jwt/jwt/v4"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"

View File

@ -9,9 +9,9 @@ import (
"strings" "strings"
"time" "time"
"github.com/1Panel-dev/1Panel/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/app/service" "github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package middleware package middleware
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,9 +1,9 @@
package middleware package middleware
import ( import (
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/service" "github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,10 +3,10 @@ package middleware
import ( import (
"strconv" "strconv"
"github.com/1Panel-dev/1Panel/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/app/repo" "github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -1,8 +1,8 @@
package router package router
import ( import (
v1 "github.com/1Panel-dev/1Panel/app/api/v1" v1 "github.com/1Panel-dev/1Panel/backend/app/api/v1"
"github.com/1Panel-dev/1Panel/middleware" "github.com/1Panel-dev/1Panel/backend/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -3,20 +3,22 @@ package server
import ( import (
"encoding/gob" "encoding/gob"
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/cmd/server/web"
"net/http"
"time" "time"
"github.com/1Panel-dev/1Panel/cron" "github.com/1Panel-dev/1Panel/backend/cron"
"github.com/1Panel-dev/1Panel/init/cache" "github.com/1Panel-dev/1Panel/backend/init/cache"
"github.com/1Panel-dev/1Panel/init/session" "github.com/1Panel-dev/1Panel/backend/init/session"
"github.com/1Panel-dev/1Panel/init/session/psession" "github.com/1Panel-dev/1Panel/backend/init/session/psession"
"github.com/1Panel-dev/1Panel/global" "github.com/1Panel-dev/1Panel/backend/global"
"github.com/1Panel-dev/1Panel/init/db" "github.com/1Panel-dev/1Panel/backend/init/db"
"github.com/1Panel-dev/1Panel/init/log" "github.com/1Panel-dev/1Panel/backend/init/log"
"github.com/1Panel-dev/1Panel/init/migration" "github.com/1Panel-dev/1Panel/backend/init/migration"
"github.com/1Panel-dev/1Panel/init/router" "github.com/1Panel-dev/1Panel/backend/init/router"
"github.com/1Panel-dev/1Panel/init/validator" "github.com/1Panel-dev/1Panel/backend/init/validator"
"github.com/1Panel-dev/1Panel/init/viper" "github.com/1Panel-dev/1Panel/backend/init/viper"
"github.com/fvbock/endless" "github.com/fvbock/endless"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -34,9 +36,17 @@ func Start() {
gin.SetMode(global.CONF.System.Level) gin.SetMode(global.CONF.System.Level)
cron.Run() cron.Run()
routers := router.Routers() rootRouter := router.Routers()
address := fmt.Sprintf(":%d", global.CONF.System.Port) address := fmt.Sprintf(":%d", global.CONF.System.Port)
s := initServer(address, routers) rootRouter.StaticFS("/login/onepanel", http.FS(web.IndexHtml))
rootRouter.StaticFS("/1panel", http.FS(web.IndexHtml))
rootRouter.GET("/assets/*filepath", func(c *gin.Context) {
staticServer := http.FileServer(http.FS(web.Assets))
staticServer.ServeHTTP(c.Writer, c.Request)
})
s := initServer(address, rootRouter)
global.LOG.Infof("server run success on %d", global.CONF.System.Port) global.LOG.Infof("server run success on %d", global.CONF.System.Port)
if err := s.ListenAndServe(); err != nil { if err := s.ListenAndServe(); err != nil {
global.LOG.Error(err) global.LOG.Error(err)

View File

@ -3,8 +3,8 @@ package captcha
import ( import (
"strings" "strings"
"github.com/1Panel-dev/1Panel/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/mojocn/base64Captcha" "github.com/mojocn/base64Captcha"
) )

View File

@ -8,7 +8,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/credentials"
) )

View File

@ -1,7 +1,7 @@
package client package client
import ( import (
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
osssdk "github.com/aliyun/aliyun-oss-go-sdk/oss" osssdk "github.com/aliyun/aliyun-oss-go-sdk/oss"
) )

View File

@ -3,7 +3,7 @@ package client
import ( import (
"os" "os"
"github.com/1Panel-dev/1Panel/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials"

Some files were not shown because too many files have changed in this diff Show More