Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions frontend/src/views/website/website/config/basic/domain/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>
<el-table-column width="30px">
<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>
</el-table-column>
<el-table-column :label="$t('website.domain')" prop="domain"></el-table-column>
Expand All @@ -31,6 +31,7 @@ import { computed, onMounted, ref } from 'vue';
import i18n from '@/lang';
import { Promotion } from '@element-plus/icons-vue';
import { GlobalStore } from '@/store';
import { CheckAppInstalled } from '@/api/modules/app';
const globalStore = GlobalStore();

const props = defineProps({
Expand All @@ -50,6 +51,8 @@ const data = ref<Website.Domain[]>([]);
const domainRef = ref();
const website = ref<Website.WebsiteDTO>();
const opRef = ref();
const httpPort = ref(80);
const httpsPort = ref(443);

const buttons = [
{
Expand All @@ -67,10 +70,14 @@ const openCreate = () => {
domainRef.value.acceptParams(id.value);
};

const openUrl = (domain: string, port: string) => {
let url = website.value.protocol.toLowerCase() + '://' + domain;
if (port != '80') {
url = url + ':' + port;
const openUrl = (domain: Website.Domain) => {
const protocol = website.value.protocol.toLowerCase();
let url = protocol + '://' + domain.domain;
if (protocol == 'http' && domain.port != 80) {
url = url + ':' + domain.port;
}
if (protocol == 'https') {
url = url + ':' + httpsPort.value;
}
window.open(url);
};
Expand All @@ -97,6 +104,7 @@ const search = (id: number) => {
.finally(() => {
loading.value = false;
});
onCheck();
};

const getWebsite = (id: number) => {
Expand All @@ -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(() => {
search(id.value);
getWebsite(id.value);
Expand Down
Loading