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

fix(website): Fix Issue with Switching PHP Runtime Environment (#7203)

Refs https://github.com/1Panel-dev/1Panel/issues/7097
This commit is contained in:
zhengkunwang 2024-11-28 15:26:38 +08:00 committed by GitHub
parent 53e91a87b0
commit ae03b85a97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 12 deletions

View File

@ -1343,6 +1343,14 @@ func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error
if runtime.Resource == constant.ResourceLocal || oldRuntime.Resource == constant.ResourceLocal { if runtime.Resource == constant.ResourceLocal || oldRuntime.Resource == constant.ResourceLocal {
return buserr.New("ErrPHPResource") return buserr.New("ErrPHPResource")
} }
client, err := docker.NewDockerClient()
if err != nil {
return err
}
defer client.Close()
if !checkImageExist(client, runtime.Image) {
return buserr.WithName("ErrImageNotExist", runtime.Name)
}
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID))
if err != nil { if err != nil {
return err return err

View File

@ -2,7 +2,6 @@
<div v-loading="loading"> <div v-loading="loading">
<el-form :model="form" :rules="variablesRules" ref="phpFormRef" label-position="top"> <el-form :model="form" :rules="variablesRules" ref="phpFormRef" label-position="top">
<el-row v-loading="loading"> <el-row v-loading="loading">
<el-col :span="1"><br /></el-col>
<el-col :span="9"> <el-col :span="9">
<el-form-item label="short_open_tag" prop="short_open_tag"> <el-form-item label="short_open_tag" prop="short_open_tag">
<el-select v-model="form.short_open_tag"> <el-select v-model="form.short_open_tag">

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<el-row> <el-row>
<el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8" :offset="1"> <el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8">
<el-form :model="form" :rules="rules" ref="formRef"> <el-form :model="form" :rules="rules" ref="formRef">
<el-form-item prop="funcs"> <el-form-item prop="funcs">
<el-input <el-input

View File

@ -10,7 +10,7 @@
<Upload :id="id" v-if="index == '2'"></Upload> <Upload :id="id" v-if="index == '2'"></Upload>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('runtime.version')" name="3"> <el-tab-pane :label="$t('runtime.version')" name="3">
<Version :id="id" :runtimeID="runtimeID" v-if="index == '3'"></Version> <Version :id="id" v-if="index == '3'"></Version>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<el-row> <el-row>
<el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8" :offset="1"> <el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8">
<el-form :model="form" :rules="rules" ref="phpFormRef"> <el-form :model="form" :rules="rules" ref="phpFormRef">
<el-form-item prop="uploadSize"> <el-form-item prop="uploadSize">
<el-input clearable type="number" v-model.number="form.uploadSize" maxlength="15"> <el-input clearable type="number" v-model.number="form.uploadSize" maxlength="15">

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<el-row> <el-row>
<el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8" :offset="1"> <el-col :xs="20" :sm="12" :md="10" :lg="10" :xl="8">
<el-form> <el-form>
<el-form-item :label="$t('runtime.version')"> <el-form-item :label="$t('runtime.version')">
<el-select v-model="versionReq.runtimeID" style="width: 100%"> <el-select v-model="versionReq.runtimeID" style="width: 100%">
@ -33,7 +33,7 @@ import { SearchRuntimes } from '@/api/modules/runtime';
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { Runtime } from '@/api/interface/runtime'; import { Runtime } from '@/api/interface/runtime';
import { Website } from '@/api/interface/website'; import { Website } from '@/api/interface/website';
import { ChangePHPVersion } from '@/api/modules/website'; import { ChangePHPVersion, GetWebsite } from '@/api/modules/website';
import i18n from '@/lang'; import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
const props = defineProps({ const props = defineProps({
@ -41,10 +41,6 @@ const props = defineProps({
type: Number, type: Number,
default: 0, default: 0,
}, },
runtimeID: {
type: Number,
default: 0,
},
}); });
const runtimeReq = reactive<Runtime.RuntimeReq>({ page: 1, pageSize: 200, type: 'php' }); const runtimeReq = reactive<Runtime.RuntimeReq>({ page: 1, pageSize: 200, type: 'php' });
@ -92,16 +88,23 @@ const submit = async () => {
try { try {
await ChangePHPVersion(versionReq); await ChangePHPVersion(versionReq);
MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
getWebsiteDetail();
} catch (error) {} } catch (error) {}
loading.value = false; loading.value = false;
}); });
} catch (error) {} } catch (error) {}
}; };
const getWebsiteDetail = async () => {
const res = await GetWebsite(props.id);
versionReq.runtimeID = res.data.runtimeID;
oldRuntimeID.value = res.data.runtimeID;
};
onMounted(() => { onMounted(() => {
versionReq.runtimeID = props.runtimeID;
versionReq.websiteID = props.id; versionReq.websiteID = props.id;
oldRuntimeID.value = props.runtimeID;
getWebsiteDetail();
getRuntimes(); getRuntimes();
}); });
</script> </script>