mirror of https://github.com/1Panel-dev/1Panel
feat: OpenResty 升级提示转到创建网站处 (#647)
parent
059c3a0b80
commit
02577ef746
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
<LayoutContent :title="$t('runtime.runtime')" v-loading="loading" :class="{ mask: !versionExist }">
|
<LayoutContent :title="$t('runtime.runtime')" v-loading="loading">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<el-button type="primary" @click="openCreate">
|
<el-button type="primary" @click="openCreate">
|
||||||
{{ $t('runtime.create') }}
|
{{ $t('runtime.create') }}
|
||||||
|
@ -65,15 +65,6 @@
|
||||||
</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>
|
||||||
|
@ -90,8 +81,6 @@ 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,
|
||||||
|
@ -122,7 +111,6 @@ 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;
|
||||||
|
@ -151,44 +139,11 @@ 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(() => {
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</template>
|
</template>
|
||||||
</DrawerHeader>
|
</DrawerHeader>
|
||||||
</template>
|
</template>
|
||||||
<el-row v-loading="loading">
|
<el-row v-loading="loading" :class="{ mask: !versionExist }">
|
||||||
<el-col :span="22" :offset="1">
|
<el-col :span="22" :offset="1">
|
||||||
<el-alert
|
<el-alert
|
||||||
v-if="website.type == 'deployment'"
|
v-if="website.type == 'deployment'"
|
||||||
|
@ -227,13 +227,25 @@
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<Check ref="preCheckRef"></Check>
|
<Check ref="preCheckRef"></Check>
|
||||||
|
<el-card width="30%" v-if="!versionExist" class="mask-prompt">
|
||||||
|
<span>
|
||||||
|
{{ $t('runtime.openrestryWarn') }}
|
||||||
|
</span>
|
||||||
|
</el-card>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="CreateWebSite">
|
<script lang="ts" setup name="CreateWebSite">
|
||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { App } from '@/api/interface/app';
|
import { App } from '@/api/interface/app';
|
||||||
import { GetApp, GetAppDetail, SearchApp, GetAppInstalled, GetAppDetailByID } from '@/api/modules/app';
|
import {
|
||||||
|
GetApp,
|
||||||
|
GetAppDetail,
|
||||||
|
SearchApp,
|
||||||
|
GetAppInstalled,
|
||||||
|
GetAppDetailByID,
|
||||||
|
CheckAppInstalled,
|
||||||
|
} from '@/api/modules/app';
|
||||||
import { CreateWebsite, PreCheck } from '@/api/modules/website';
|
import { CreateWebsite, PreCheck } from '@/api/modules/website';
|
||||||
import { Rules } from '@/global/form-rules';
|
import { Rules } from '@/global/form-rules';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
|
@ -270,7 +282,7 @@ const website = ref({
|
||||||
proxyType: 'tcp',
|
proxyType: 'tcp',
|
||||||
port: 9000,
|
port: 9000,
|
||||||
});
|
});
|
||||||
let rules = ref<any>({
|
const rules = ref<any>({
|
||||||
primaryDomain: [Rules.domain],
|
primaryDomain: [Rules.domain],
|
||||||
alias: [Rules.linuxName],
|
alias: [Rules.linuxName],
|
||||||
type: [Rules.requiredInput],
|
type: [Rules.requiredInput],
|
||||||
|
@ -288,31 +300,31 @@ let rules = ref<any>({
|
||||||
port: [Rules.port],
|
port: [Rules.port],
|
||||||
});
|
});
|
||||||
|
|
||||||
let open = ref(false);
|
const open = ref(false);
|
||||||
let loading = ref(false);
|
const loading = ref(false);
|
||||||
let groups = ref<Group.GroupInfo[]>([]);
|
const groups = ref<Group.GroupInfo[]>([]);
|
||||||
|
|
||||||
let appInstalles = ref<App.AppInstalled[]>([]);
|
const appInstalles = ref<App.AppInstalled[]>([]);
|
||||||
let appReq = reactive({
|
const appReq = reactive({
|
||||||
type: 'website',
|
type: 'website',
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
});
|
});
|
||||||
let apps = ref<App.App[]>([]);
|
const apps = ref<App.App[]>([]);
|
||||||
let appVersions = ref<string[]>([]);
|
const appVersions = ref<string[]>([]);
|
||||||
let appDetail = ref<App.AppDetail>();
|
const appDetail = ref<App.AppDetail>();
|
||||||
let appParams = ref<App.AppParams>();
|
const appParams = ref<App.AppParams>();
|
||||||
let paramKey = ref(1);
|
const paramKey = ref(1);
|
||||||
let preCheckRef = ref();
|
const preCheckRef = ref();
|
||||||
let staticPath = ref('');
|
const staticPath = ref('');
|
||||||
let runtimeResource = ref('appstore');
|
const runtimeResource = ref('appstore');
|
||||||
const runtimeReq = ref<Runtime.RuntimeReq>({
|
const runtimeReq = ref<Runtime.RuntimeReq>({
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
status: 'normal',
|
status: 'normal',
|
||||||
});
|
});
|
||||||
const runtimes = ref<Runtime.RuntimeDTO[]>([]);
|
const runtimes = ref<Runtime.RuntimeDTO[]>([]);
|
||||||
|
const versionExist = ref(true);
|
||||||
const em = defineEmits(['close']);
|
const em = defineEmits(['close']);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
@ -326,11 +338,24 @@ const changeType = (type: string) => {
|
||||||
website.value.appInstallId = appInstalles.value[0].id;
|
website.value.appInstallId = appInstalles.value[0].id;
|
||||||
}
|
}
|
||||||
} else if (type == 'runtime') {
|
} else if (type == 'runtime') {
|
||||||
|
checkNginxVersion();
|
||||||
getRuntimes();
|
getRuntimes();
|
||||||
} else {
|
} else {
|
||||||
website.value.appInstallId = undefined;
|
website.value.appInstallId = undefined;
|
||||||
}
|
}
|
||||||
website.value.type = type;
|
website.value.type = type;
|
||||||
|
versionExist.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkNginxVersion = async () => {
|
||||||
|
try {
|
||||||
|
const res = await CheckAppInstalled('openresty');
|
||||||
|
if (res.data && res.data.version) {
|
||||||
|
if (!compareVersions(res.data.version, '1.21.4')) {
|
||||||
|
versionExist.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchAppInstalled = () => {
|
const searchAppInstalled = () => {
|
||||||
|
@ -474,6 +499,23 @@ const changeAlias = (value: string) => {
|
||||||
website.value.alias = value;
|
website.value.alias = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue