feat: 运行环境样式修改 (#519)

This commit is contained in:
zhengkunwang223 2023-04-06 16:38:16 +08:00 committed by GitHub
parent 281cf48aaa
commit 1b5387dc5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 51 additions and 24 deletions

View file

@ -402,14 +402,12 @@ func (a *AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, erro
if err != nil {
return nil, err
}
if app.Type == "website" {
websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(appInstall.ID))
for _, website := range websites {
res = append(res, dto.AppResource{
Type: "website",
Name: website.PrimaryDomain,
})
}
websites, _ := websiteRepo.GetBy(websiteRepo.WithAppInstallId(appInstall.ID))
for _, website := range websites {
res = append(res, dto.AppResource{
Type: "website",
Name: website.PrimaryDomain,
})
}
if app.Key == constant.AppOpenresty {
websites, _ := websiteRepo.GetBy()

View file

@ -390,9 +390,13 @@ func upApp(ctx context.Context, composeFilePath string, appInstall model.AppInst
appInstall.Message = err.Error()
}
appInstall.Status = constant.Error
_ = appInstallRepo.Save(ctx, &appInstall)
} else {
appInstall.Status = constant.Running
}
exist, _ := appInstallRepo.GetFirst(commonRepo.WithByID(appInstall.ID))
if exist.ID > 0 {
_ = appInstallRepo.Save(context.Background(), &appInstall)
} else {
_ = appInstallRepo.Save(ctx, &appInstall)
}
}

View file

@ -6,7 +6,6 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"github.com/1Panel-dev/1Panel/backend/utils/common"
"os"
"path"
"reflect"
@ -184,9 +183,6 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
if err != nil {
return err
}
if common.ScanPort(create.Port) {
return buserr.WithDetail(constant.ErrPortInUsed, create.Port, nil)
}
if runtime.Resource == constant.ResourceAppstore {
var req request.AppInstallCreate
reg, _ := regexp.Compile("[^a-z0-9_\\-]+")

View file

@ -249,7 +249,7 @@ var AddDefaultGroup = &gormigrate.Migration{
}
var AddTableRuntime = &gormigrate.Migration{
ID: "20230330-add-table-runtime",
ID: "20230406-add-table-runtime",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&model.Runtime{}, &model.Website{})
},

View file

@ -1,7 +1,7 @@
<template>
<el-tag :type="getType(status)" round effect="light">
{{ $t('commons.status.' + status) }}
<el-icon v-if="status === 'installing'" class="is-loading">
<el-icon v-if="loadingIcon(status)" class="is-loading">
<Loading />
</el-icon>
</el-tag>
@ -31,6 +31,12 @@ const getType = (status: string) => {
}
};
const loadingStatus = ['installing', 'building', 'restarting'];
const loadingIcon = (status: string): boolean => {
return loadingStatus.indexOf(status) > -1;
};
onMounted(() => {
status.value = props.status.toLocaleLowerCase();
});

View file

@ -97,6 +97,8 @@ import MdEditor from 'md-editor-v3';
import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import Install from './install/index.vue';
import router from '@/routers';
const language = useI18n().locale.value;
interface OperateProps {
@ -147,7 +149,12 @@ const openInstall = () => {
params: appDetail.value.params,
appDetailId: appDetail.value.id,
};
installRef.value.acceptParams(params);
console.log(app.value);
if (app.value.type === 'php') {
router.push({ path: '/websites/runtime/php' });
} else {
installRef.value.acceptParams(params);
}
};
onMounted(() => {

View file

@ -244,7 +244,11 @@ const getRuntime = async (id: number) => {
version: data.version,
};
editParams.value = data.appParams;
searchApp(data.appId);
if (mode.value == 'create') {
searchApp(data.appId);
} else {
initParam.value = true;
}
} catch (error) {}
};

View file

@ -68,7 +68,7 @@
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import { onMounted, onUnmounted, reactive, ref } from 'vue';
import { Runtime } from '@/api/interface/runtime';
import { DeleteRuntime, SearchRuntimes } from '@/api/modules/runtime';
import { dateFormat, toLowerCase } from '@/utils/util';
@ -82,14 +82,15 @@ import { useDeleteData } from '@/hooks/use-delete-data';
const paginationConfig = reactive({
currentPage: 1,
pageSize: 15,
pageSize: 10,
total: 0,
});
let req = reactive<Runtime.RuntimeReq>({
name: '',
page: 1,
pageSize: 15,
pageSize: 40,
});
let timer: NodeJS.Timer | null = null;
const buttons = [
{
@ -138,5 +139,13 @@ const openDelete = async (row: Runtime.Runtime) => {
onMounted(() => {
search();
timer = setInterval(() => {
search();
}, 10000 * 3);
});
onUnmounted(() => {
clearInterval(Number(timer));
timer = null;
});
</script>

View file

@ -102,7 +102,7 @@ import { MsgSuccess } from '@/utils/message';
const paginationConfig = reactive({
currentPage: 1,
pageSize: 20,
pageSize: 10,
total: 0,
});
const acmeAccountRef = ref();

View file

@ -393,6 +393,9 @@ const changeRuntime = (runID: number) => {
runtimes.value.forEach((item) => {
if (item.id === runID) {
runtimeResource.value = item.resource;
if (item.type === 'appstore') {
getAppDetailByID(item.appDetailId);
}
}
});
};
@ -405,7 +408,7 @@ const getRuntimes = async () => {
const first = runtimes.value[0];
website.value.runtimeID = first.id;
runtimeResource.value = first.resource;
if (first.type === 'appstore') {
if (first.resource === 'appstore') {
getAppDetailByID(first.appDetailId);
}
}

View file

@ -217,13 +217,13 @@ let groups = ref<Group.GroupInfo[]>([]);
const paginationConfig = reactive({
currentPage: 1,
pageSize: 15,
pageSize: 10,
total: 0,
});
let req = reactive({
name: '',
page: 1,
pageSize: 15,
pageSize: 10,
websiteGroupId: 0,
});