fix: 解决域名非 80 端口时快速跳转地址错误的问题 (#3281)

pull/3284/head
zhengkunwang 12 months ago committed by GitHub
parent d60e8167b0
commit d567491770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@
</template> </template>
<el-table-column width="30px"> <el-table-column width="30px">
<template #default="{ row }"> <template #default="{ row }">
<el-button link :icon="Promotion" @click="openUrl(row.domain, row.port)"></el-button> <el-button link :icon="Promotion" @click="openUrl(row)"></el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('website.domain')" prop="domain"></el-table-column> <el-table-column :label="$t('website.domain')" prop="domain"></el-table-column>
@ -31,6 +31,7 @@ import { computed, onMounted, ref } from 'vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { Promotion } from '@element-plus/icons-vue'; import { Promotion } from '@element-plus/icons-vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { CheckAppInstalled } from '@/api/modules/app';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const props = defineProps({ const props = defineProps({
@ -50,6 +51,8 @@ const data = ref<Website.Domain[]>([]);
const domainRef = ref(); const domainRef = ref();
const website = ref<Website.WebsiteDTO>(); const website = ref<Website.WebsiteDTO>();
const opRef = ref(); const opRef = ref();
const httpPort = ref(80);
const httpsPort = ref(443);
const buttons = [ const buttons = [
{ {
@ -67,10 +70,14 @@ const openCreate = () => {
domainRef.value.acceptParams(id.value); domainRef.value.acceptParams(id.value);
}; };
const openUrl = (domain: string, port: string) => { const openUrl = (domain: Website.Domain) => {
let url = website.value.protocol.toLowerCase() + '://' + domain; const protocol = website.value.protocol.toLowerCase();
if (port != '80') { let url = protocol + '://' + domain.domain;
url = url + ':' + port; if (protocol == 'http' && domain.port != 80) {
url = url + ':' + domain.port;
}
if (protocol == 'https') {
url = url + ':' + httpsPort.value;
} }
window.open(url); window.open(url);
}; };
@ -97,6 +104,7 @@ const search = (id: number) => {
.finally(() => { .finally(() => {
loading.value = false; loading.value = false;
}); });
onCheck();
}; };
const getWebsite = (id: number) => { const getWebsite = (id: number) => {
@ -105,6 +113,15 @@ const getWebsite = (id: number) => {
}); });
}; };
const onCheck = async () => {
await CheckAppInstalled('openresty', '')
.then((res) => {
httpPort.value = res.data.httpPort;
httpsPort.value = res.data.httpsPort;
})
.catch(() => {});
};
onMounted(() => { onMounted(() => {
search(id.value); search(id.value);
getWebsite(id.value); getWebsite(id.value);

Loading…
Cancel
Save