1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

feat: 解决创建网站切换类型显示错误的问题 (#2451)

This commit is contained in:
zhengkunwang 2023-10-07 21:50:16 -05:00 committed by GitHub
parent 455e379ff4
commit b09c423bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 46 deletions

View File

@ -106,7 +106,7 @@ export namespace App {
export interface AppInstalled extends CommonModel { export interface AppInstalled extends CommonModel {
name: string; name: string;
appId: string; appId: number;
appDetailId: string; appDetailId: string;
env: string; env: string;
status: string; status: string;

View File

@ -332,14 +332,7 @@
<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 { import { GetApp, GetAppDetail, SearchApp, GetAppInstalled, GetAppDetailByID } from '@/api/modules/app';
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, checkNumberRange } from '@/global/form-rules'; import { Rules, checkNumberRange } from '@/global/form-rules';
import i18n from '@/lang'; import i18n from '@/lang';
@ -442,31 +435,24 @@ const handleClose = () => {
}; };
const changeType = (type: string) => { const changeType = (type: string) => {
if (type == 'deployemnt') { switch (type) {
if (appInstalles.value && appInstalles.value.length > 0) { case 'deployment':
website.value.appInstallId = appInstalles.value[0].id; website.value.appType = 'installed';
} if (appInstalles.value && appInstalles.value.length > 0) {
} else if (type == 'runtime') { website.value.appInstallId = appInstalles.value[0].id;
checkNginxVersion(); }
getRuntimes(); break;
} else { case 'runtime':
website.value.appInstallId = undefined; getRuntimes();
break;
default:
website.value.appInstallId = undefined;
break;
} }
website.value.type = type; website.value.type = type;
versionExist.value = true; 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 = () => {
GetAppInstalled({ type: 'website', unused: true }).then((res) => { GetAppInstalled({ type: 'website', unused: true }).then((res) => {
appInstalles.value = res.data; appInstalles.value = res.data;
@ -531,6 +517,7 @@ const changeRuntimeType = () => {
} else { } else {
runtimeReq.value.status = 'running'; runtimeReq.value.status = 'running';
} }
website.value.runtimeID = undefined;
getRuntimes(); getRuntimes();
}; };
@ -622,23 +609,6 @@ const changeAlias = (value: string) => {
website.value.alias = domain; website.value.alias = domain;
}; };
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,
}); });