Files
EnuivTools/web/src/features/notice/NoticeView.vue
T

56 lines
1.8 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 } from "vue";
import { NButton } from "naive-ui";
const toolUrl = "https://euniv.asio.asia";
const urlEl = ref<HTMLElement | null>(null);
const copied = ref(false);
const copyFailed = ref(false);
let copiedTimer = 0;
async function copyUrl() {
copied.value = false;
copyFailed.value = false;
try {
await navigator.clipboard.writeText(toolUrl);
copied.value = true;
} catch {
copyFailed.value = true;
const node = urlEl.value;
if (!node) return;
const range = document.createRange();
range.selectNodeContents(node);
const selection = window.getSelection();
selection?.removeAllRanges();
selection?.addRange(range);
}
window.clearTimeout(copiedTimer);
copiedTimer = window.setTimeout(() => {
copied.value = false;
copyFailed.value = false;
}, 2000);
}
function openTool() {
const opened = window.open(toolUrl, "_blank", "noopener");
if (!opened) window.location.assign(toolUrl);
}
</script>
<template>
<main class="notice-page">
<section class="notice-card">
<h1>旧版工具已失效</h1>
<p>因目标平台升级,旧版工具已失效,无法登录使用。新版工具已上线。</p>
<p>请复制下面的地址,打开浏览器,粘贴到地址栏后访问。</p>
<p ref="urlEl" class="notice-url">{{ toolUrl }}</p>
<div class="notice-actions">
<n-button type="primary" @click="copyUrl">{{ copied ? "已复制" : "复制地址" }}</n-button>
<n-button @click="openTool">尝试打开</n-button>
</div>
<p v-if="copied" class="notice-done">已复制。请到浏览器地址栏粘贴后访问。</p>
<p v-else-if="copyFailed" class="notice-missed">没有复制成功,地址已选中,请手动使用CTRL+C复制。</p>
</section>
</main>
</template>