mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-24 02:59:16 +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',
|
||||
buildHelper:
|
||||
'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: '状态',
|
||||
versionHelper: 'PHP的版本,例如 v8.0',
|
||||
buildHelper: '选择的扩展越多,制作镜像过程中占用 CPU 越多,请尽量避免选择全部扩展',
|
||||
openrestryWarn: 'PHP 需要升级 OpenResty 至 1.21.4.1 版本以上才能使用',
|
||||
toupgrade: '去升级',
|
||||
},
|
||||
};
|
||||
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>
|
||||
<el-button type="primary" @click="openCreate">
|
||||
{{ $t('runtime.create') }}
|
||||
@ -65,6 +65,15 @@
|
||||
</ComplexTable>
|
||||
</template>
|
||||
</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" />
|
||||
</div>
|
||||
</template>
|
||||
@ -81,6 +90,8 @@ import CreateRuntime from '@/views/website/runtime/create/index.vue';
|
||||
import Status from '@/components/status/index.vue';
|
||||
import i18n from '@/lang';
|
||||
import { useDeleteData } from '@/hooks/use-delete-data';
|
||||
import { CheckAppInstalled } from '@/api/modules/app';
|
||||
import router from '@/routers';
|
||||
|
||||
const paginationConfig = reactive({
|
||||
currentPage: 1,
|
||||
@ -111,6 +122,7 @@ const buttons = [
|
||||
const loading = ref(false);
|
||||
const items = ref<Runtime.RuntimeDTO[]>([]);
|
||||
const createRef = ref();
|
||||
const versionExist = ref(false);
|
||||
|
||||
const search = async () => {
|
||||
req.page = paginationConfig.currentPage;
|
||||
@ -139,11 +151,44 @@ const openDelete = async (row: Runtime.Runtime) => {
|
||||
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(() => {
|
||||
search();
|
||||
timer = setInterval(() => {
|
||||
search();
|
||||
}, 10000 * 3);
|
||||
onCheck();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@ -151,3 +196,10 @@ onUnmounted(() => {
|
||||
timer = null;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.open-warn {
|
||||
color: $primary-color;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user