From d151e98fab37dd4392919946efdee0507b9692f5 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:28:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20PHP=20=E8=BF=90=E8=A1=8C=E7=8E=AF?= =?UTF-8?q?=E5=A2=83,=E9=99=90=E5=88=B6=20Openresty=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=20(#611)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/modules/en.ts | 2 + frontend/src/lang/modules/zh.ts | 2 + frontend/src/views/website/runtime/index.vue | 54 +++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index b54c2a89b..291d75e20 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -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', }, }; diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index bf5b1f093..db4de1068 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1284,6 +1284,8 @@ const message = { status: '状态', versionHelper: 'PHP的版本,例如 v8.0', buildHelper: '选择的扩展越多,制作镜像过程中占用 CPU 越多,请尽量避免选择全部扩展', + openrestryWarn: 'PHP 需要升级 OpenResty 至 1.21.4.1 版本以上才能使用', + toupgrade: '去升级', }, }; export default { diff --git a/frontend/src/views/website/runtime/index.vue b/frontend/src/views/website/runtime/index.vue index 50d5af581..6fb6a28e8 100644 --- a/frontend/src/views/website/runtime/index.vue +++ b/frontend/src/views/website/runtime/index.vue @@ -8,7 +8,7 @@ }, ]" /> - + + + + {{ $t('runtime.openrestryWarn') }} + + + {{ $t('runtime.toupgrade') }} + + + @@ -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([]); 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; }); + +