Files
webup-cloud/frontend/src/views/ProjectIpEntry.vue
T
WebUp Cloud 2f93fb023a
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s
Add administrator-controlled IP project entry redirects
2026-11-08 12:25:01 +08:00

40 lines
1.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref, watch } from "vue";
import { api } from "../api";
const props = defineProps<{ projectId: string; deploymentStatus?: string }>();
const entry = ref<{ status: "ACTIVE" | "WAITING" | "DISABLED"; url: string }>();
const error = ref("");
const loading = ref(false);
let request = 0;
async function load() {
const id = props.projectId;
const current = ++request;
loading.value = true;
error.value = "";
try {
const result = await api<typeof entry.value>(`/projects/${id}/ip-entry`);
if (request === current && props.projectId === id) entry.value = result;
} catch (cause) {
if (request === current && props.projectId === id) error.value = (cause as Error).message;
} finally {
if (request === current) loading.value = false;
}
}
watch([() => props.projectId, () => props.deploymentStatus], load, { immediate: true });
</script>
<template>
<div class="alert info" aria-label="网站 IP 入口">
<strong>网站 IP 入口</strong>
<p v-if="error" role="alert">{{ error }}</p>
<p v-else-if="entry?.status === 'ACTIVE'">
<a class="link" :href="entry.url" target="_blank" rel="noopener noreferrer">{{ entry.url }}</a>
</p>
<p v-else-if="entry?.status === 'WAITING'">管理员已开启。项目发布并启用域名后,入口会显示在这里。</p>
<p v-else-if="entry?.status === 'DISABLED'">管理员尚未为此项目开启。</p>
<p v-else>正在读取 IP 入口…</p>
<button class="link" :disabled="loading" @click="load">刷新 IP 入口</button>
</div>
</template>