mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-18 03:13:48 +08:00
feat: PHP 运行环境,限制 Openresty 版本 (#611)
This commit is contained in:
parent
6115ffe0fc
commit
d151e98fab
@ -1300,6 +1300,8 @@ const message = {
|
|||||||
versionHelper: 'PHP version, e.g. v8.0',
|
versionHelper: 'PHP version, e.g. v8.0',
|
||||||
buildHelper:
|
buildHelper:
|
||||||
'The more extensions you select, the more CPU will be occupied during the image making process, so avoid selecting all extensions',
|
'The more extensions you select, the more CPU will be occupied during the image making process, so avoid selecting all extensions',
|
||||||
|
openrestryWarn: 'PHP needs to be upgraded to OpenResty to version 1.21.4.1 or later to use',
|
||||||
|
toupgrade: 'To Upgrade',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1284,6 +1284,8 @@ const message = {
|
|||||||
status: '状态',
|
status: '状态',
|
||||||
versionHelper: 'PHP的版本,例如 v8.0',
|
versionHelper: 'PHP的版本,例如 v8.0',
|
||||||
buildHelper: '选择的扩展越多,制作镜像过程中占用 CPU 越多,请尽量避免选择全部扩展',
|
buildHelper: '选择的扩展越多,制作镜像过程中占用 CPU 越多,请尽量避免选择全部扩展',
|
||||||
|
openrestryWarn: 'PHP 需要升级 OpenResty 至 1.21.4.1 版本以上才能使用',
|
||||||
|
toupgrade: '去升级',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export default {
|
export default {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
<LayoutContent :title="$t('runtime.runtime')" v-loading="loading">
|
<LayoutContent :title="$t('runtime.runtime')" v-loading="loading" :class="{ mask: !versionExist }">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<el-button type="primary" @click="openCreate">
|
<el-button type="primary" @click="openCreate">
|
||||||
{{ $t('runtime.create') }}
|
{{ $t('runtime.create') }}
|
||||||
@ -65,6 +65,15 @@
|
|||||||
</ComplexTable>
|
</ComplexTable>
|
||||||
</template>
|
</template>
|
||||||
</LayoutContent>
|
</LayoutContent>
|
||||||
|
<el-card width="30%" v-if="!versionExist" class="mask-prompt">
|
||||||
|
<span>
|
||||||
|
{{ $t('runtime.openrestryWarn') }}
|
||||||
|
<span class="open-warn" @click="goRouter()">
|
||||||
|
<el-icon><Position /></el-icon>
|
||||||
|
{{ $t('runtime.toupgrade') }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</el-card>
|
||||||
<CreateRuntime ref="createRef" @close="search" />
|
<CreateRuntime ref="createRef" @close="search" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -81,6 +90,8 @@ import CreateRuntime from '@/views/website/runtime/create/index.vue';
|
|||||||
import Status from '@/components/status/index.vue';
|
import Status from '@/components/status/index.vue';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||||
|
import { CheckAppInstalled } from '@/api/modules/app';
|
||||||
|
import router from '@/routers';
|
||||||
|
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
@ -111,6 +122,7 @@ const buttons = [
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const items = ref<Runtime.RuntimeDTO[]>([]);
|
const items = ref<Runtime.RuntimeDTO[]>([]);
|
||||||
const createRef = ref();
|
const createRef = ref();
|
||||||
|
const versionExist = ref(false);
|
||||||
|
|
||||||
const search = async () => {
|
const search = async () => {
|
||||||
req.page = paginationConfig.currentPage;
|
req.page = paginationConfig.currentPage;
|
||||||
@ -139,11 +151,44 @@ const openDelete = async (row: Runtime.Runtime) => {
|
|||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onCheck = async () => {
|
||||||
|
try {
|
||||||
|
const res = await CheckAppInstalled('openresty');
|
||||||
|
if (res.data && res.data.version) {
|
||||||
|
if (compareVersions(res.data.version, '1.21.4')) {
|
||||||
|
versionExist.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
function compareVersions(version1: string, version2: string): boolean {
|
||||||
|
const v1 = version1.split('.');
|
||||||
|
const v2 = version2.split('.');
|
||||||
|
const len = Math.max(v1.length, v2.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
const num1 = parseInt(v1[i] || '0');
|
||||||
|
const num2 = parseInt(v2[i] || '0');
|
||||||
|
|
||||||
|
if (num1 !== num2) {
|
||||||
|
return num1 > num2 ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const goRouter = async () => {
|
||||||
|
router.push({ name: 'AppUpgrade' });
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
search();
|
search();
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
search();
|
search();
|
||||||
}, 10000 * 3);
|
}, 10000 * 3);
|
||||||
|
onCheck();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@ -151,3 +196,10 @@ onUnmounted(() => {
|
|||||||
timer = null;
|
timer = null;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.open-warn {
|
||||||
|
color: $primary-color;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user