mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat(appstore): Optimize Custom Application Logic (#7603)
This commit is contained in:
parent
79fea272aa
commit
68698217ee
@ -18,6 +18,7 @@ type IAppRepo interface {
|
|||||||
OrderByRecommend() DBOption
|
OrderByRecommend() DBOption
|
||||||
GetRecommend() DBOption
|
GetRecommend() DBOption
|
||||||
WithResource(resource string) DBOption
|
WithResource(resource string) DBOption
|
||||||
|
WithNotLocal() DBOption
|
||||||
WithByLikeName(name string) DBOption
|
WithByLikeName(name string) DBOption
|
||||||
WithArch(arch string) DBOption
|
WithArch(arch string) DBOption
|
||||||
WithPanelVersion(panelVersion string) DBOption
|
WithPanelVersion(panelVersion string) DBOption
|
||||||
@ -76,6 +77,12 @@ func (a AppRepo) WithResource(resource string) DBOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a AppRepo) WithNotLocal() DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
return g.Where("resource != local")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppRepo) WithArch(arch string) DBOption {
|
func (a AppRepo) WithArch(arch string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("architectures like ?", fmt.Sprintf("%%%s%%", arch))
|
return g.Where("architectures like ?", fmt.Sprintf("%%%s%%", arch))
|
||||||
|
@ -843,6 +843,9 @@ var InitTypes = map[string]struct{}{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
|
||||||
|
if xpack.IsUseCustomApp() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
syncTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("App"), task.TaskSync, task.TaskScopeAppStore, taskID, 0)
|
syncTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("App"), task.TaskSync, task.TaskScopeAppStore, taskID, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -125,13 +125,9 @@ func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
installDTOs, err := handleInstalled(installs, req.Update, req.Sync)
|
installDTOs, err := handleInstalled(installs, req.Update, req.Sync)
|
||||||
if err != nil {
|
|
||||||
return 0, nil, err
|
|
||||||
}
|
|
||||||
if req.Update {
|
if req.Update {
|
||||||
total = int64(len(installDTOs))
|
total = int64(len(installDTOs))
|
||||||
}
|
}
|
||||||
|
|
||||||
return total, installDTOs, nil
|
return total, installDTOs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,6 +935,9 @@ func copyData(task *task.Task, app model.App, appDetail model.AppDetail, appInst
|
|||||||
appKey = strings.TrimPrefix(app.Key, "local")
|
appKey = strings.TrimPrefix(app.Key, "local")
|
||||||
installAppDir = path.Join(constant.LocalAppInstallDir, appKey)
|
installAppDir = path.Join(constant.LocalAppInstallDir, appKey)
|
||||||
}
|
}
|
||||||
|
if app.Resource == constant.AppResourceCustom {
|
||||||
|
appResourceDir = path.Join(constant.AppResourceDir, "custom")
|
||||||
|
}
|
||||||
resourceDir := path.Join(appResourceDir, appKey, appDetail.Version)
|
resourceDir := path.Join(appResourceDir, appKey, appDetail.Version)
|
||||||
|
|
||||||
if !fileOp.Stat(installAppDir) {
|
if !fileOp.Stat(installAppDir) {
|
||||||
@ -1094,9 +1097,11 @@ func upApp(task *task.Task, appInstall *model.AppInstall, pullImages bool) error
|
|||||||
appInstall.Message = err.Error()
|
appInstall.Message = err.Error()
|
||||||
}
|
}
|
||||||
appInstall.Status = constant.UpErr
|
appInstall.Status = constant.UpErr
|
||||||
|
_ = appInstallRepo.Save(context.Background(), appInstall)
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
appInstall.Status = constant.Running
|
appInstall.Status = constant.Running
|
||||||
|
_ = appInstallRepo.Save(context.Background(), appInstall)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
|
||||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/1Panel-dev/1Panel/agent/global"
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
"github.com/1Panel-dev/1Panel/agent/utils/encrypt"
|
"github.com/1Panel-dev/1Panel/agent/utils/encrypt"
|
||||||
@ -81,7 +80,6 @@ func (u *SettingService) ReloadConn() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
settingRepo := repo.NewISettingRepo()
|
|
||||||
itemKey, _ := encrypt.StringEncrypt(nodeInfo.ServerKey)
|
itemKey, _ := encrypt.StringEncrypt(nodeInfo.ServerKey)
|
||||||
if err := settingRepo.Update("ServerKey", itemKey); err != nil {
|
if err := settingRepo.Update("ServerKey", itemKey); err != nil {
|
||||||
global.LOG.Errorf("update server key failed, err: %v", err)
|
global.LOG.Errorf("update server key failed, err: %v", err)
|
||||||
@ -112,6 +110,9 @@ func (u *SettingService) ReloadConn() error {
|
|||||||
global.CONF.System.BaseDir = nodeInfo.BaseDir
|
global.CONF.System.BaseDir = nodeInfo.BaseDir
|
||||||
global.CONF.System.Version = nodeInfo.Version
|
global.CONF.System.Version = nodeInfo.Version
|
||||||
global.CONF.System.Port = fmt.Sprintf("%v", nodeInfo.NodePort)
|
global.CONF.System.Port = fmt.Sprintf("%v", nodeInfo.NodePort)
|
||||||
|
if global.CONF.System.Port == "0" {
|
||||||
|
global.CONF.System.Port = "9999"
|
||||||
|
}
|
||||||
global.IsMaster = nodeInfo.Scope == "master"
|
global.IsMaster = nodeInfo.Scope == "master"
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ const (
|
|||||||
|
|
||||||
AppResourceLocal = "local"
|
AppResourceLocal = "local"
|
||||||
AppResourceRemote = "remote"
|
AppResourceRemote = "remote"
|
||||||
|
AppResourceCustom = "custom"
|
||||||
|
|
||||||
CPUS = "CPUS"
|
CPUS = "CPUS"
|
||||||
MemoryLimit = "MEMORY_LIMIT"
|
MemoryLimit = "MEMORY_LIMIT"
|
||||||
|
@ -14,6 +14,7 @@ var (
|
|||||||
LocalAppResourceDir = path.Join(AppResourceDir, "local")
|
LocalAppResourceDir = path.Join(AppResourceDir, "local")
|
||||||
LocalAppInstallDir = path.Join(AppInstallDir, "local")
|
LocalAppInstallDir = path.Join(AppInstallDir, "local")
|
||||||
RemoteAppResourceDir = path.Join(AppResourceDir, "remote")
|
RemoteAppResourceDir = path.Join(AppResourceDir, "remote")
|
||||||
|
CustomAppResourceDir = path.Join(AppResourceDir, "custom")
|
||||||
RuntimeDir = path.Join(DataDir, "runtime")
|
RuntimeDir = path.Join(DataDir, "runtime")
|
||||||
RecycleBinDir = "/.1panel_clash"
|
RecycleBinDir = "/.1panel_clash"
|
||||||
SSLLogDir = path.Join(global.CONF.System.DataDir, "log", "ssl")
|
SSLLogDir = path.Join(global.CONF.System.DataDir, "log", "ssl")
|
||||||
|
@ -21,12 +21,17 @@ func Init() {
|
|||||||
constant.LocalAppResourceDir = path.Join(constant.AppResourceDir, "local")
|
constant.LocalAppResourceDir = path.Join(constant.AppResourceDir, "local")
|
||||||
constant.LocalAppInstallDir = path.Join(constant.AppInstallDir, "local")
|
constant.LocalAppInstallDir = path.Join(constant.AppInstallDir, "local")
|
||||||
constant.RemoteAppResourceDir = path.Join(constant.AppResourceDir, "remote")
|
constant.RemoteAppResourceDir = path.Join(constant.AppResourceDir, "remote")
|
||||||
|
constant.CustomAppResourceDir = path.Join(constant.AppResourceDir, "custom")
|
||||||
|
|
||||||
constant.LogDir = path.Join(global.CONF.System.DataDir, "log")
|
constant.LogDir = path.Join(global.CONF.System.DataDir, "log")
|
||||||
constant.SSLLogDir = path.Join(constant.LogDir, "ssl")
|
constant.SSLLogDir = path.Join(constant.LogDir, "ssl")
|
||||||
|
|
||||||
dirs := []string{constant.DataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir,
|
dirs := []string{
|
||||||
global.CONF.System.Backup, constant.RuntimeDir, constant.LocalAppResourceDir, constant.RemoteAppResourceDir, constant.SSLLogDir}
|
constant.DataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir,
|
||||||
|
global.CONF.System.Backup, constant.RuntimeDir, constant.LocalAppResourceDir,
|
||||||
|
constant.RemoteAppResourceDir, constant.SSLLogDir,
|
||||||
|
constant.CustomAppResourceDir,
|
||||||
|
}
|
||||||
|
|
||||||
fileOp := files.NewFileOp()
|
fileOp := files.NewFileOp()
|
||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
|
@ -66,3 +66,7 @@ func loadParams(param string) string {
|
|||||||
func GetImagePrefix() string {
|
func GetImagePrefix() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsUseCustomApp() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -90,7 +90,7 @@ const stopSignals = [
|
|||||||
'[TASK-END]',
|
'[TASK-END]',
|
||||||
];
|
];
|
||||||
const emit = defineEmits(['update:loading', 'update:hasContent', 'update:isReading']);
|
const emit = defineEmits(['update:loading', 'update:hasContent', 'update:isReading']);
|
||||||
const tailLog = ref(false);
|
const tailLog = ref(true);
|
||||||
const loading = ref(props.loading);
|
const loading = ref(props.loading);
|
||||||
const readReq = reactive({
|
const readReq = reactive({
|
||||||
id: 0,
|
id: 0,
|
||||||
@ -117,7 +117,7 @@ const logHeight = 20;
|
|||||||
const logCount = ref(0);
|
const logCount = ref(0);
|
||||||
const totalHeight = computed(() => logHeight * logCount.value);
|
const totalHeight = computed(() => logHeight * logCount.value);
|
||||||
const containerHeight = ref(500);
|
const containerHeight = ref(500);
|
||||||
const visibleCount = computed(() => Math.ceil(containerHeight.value / logHeight)); // 计算可见日志条数(容器高度 / 日志高度)
|
const visibleCount = computed(() => Math.ceil(containerHeight.value / logHeight));
|
||||||
const startIndex = ref(0);
|
const startIndex = ref(0);
|
||||||
|
|
||||||
const visibleLogs = computed(() => {
|
const visibleLogs = computed(() => {
|
||||||
|
@ -37,7 +37,7 @@ const config = reactive({
|
|||||||
taskOperate: '',
|
taskOperate: '',
|
||||||
resourceID: 0,
|
resourceID: 0,
|
||||||
taskType: '',
|
taskType: '',
|
||||||
tail: false,
|
tail: true,
|
||||||
});
|
});
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const showTail = ref(true);
|
const showTail = ref(true);
|
||||||
@ -45,10 +45,10 @@ const showTail = ref(true);
|
|||||||
const openWithTaskID = (id: string, tail: boolean) => {
|
const openWithTaskID = (id: string, tail: boolean) => {
|
||||||
console.log('openWithTaskID', id, tail);
|
console.log('openWithTaskID', id, tail);
|
||||||
config.taskID = id;
|
config.taskID = id;
|
||||||
if (!tail) {
|
if (tail === undefined) {
|
||||||
config.tail = false;
|
|
||||||
} else {
|
|
||||||
config.tail = true;
|
config.tail = true;
|
||||||
|
} else {
|
||||||
|
config.tail = tail;
|
||||||
}
|
}
|
||||||
open.value = true;
|
open.value = true;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user