70 lines
4.7 KiB
Vue
70 lines
4.7 KiB
Vue
<template>
|
||
<div class="hn-welcome-lines">
|
||
<div class="hn-welcome-notice">
|
||
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="hn-warning">
|
||
<path d="M11 3h2l9 16-1 2H3l-1-2 9-16Z" fill="currentColor" fill-opacity=".1" stroke="currentColor" stroke-width="1.6" />
|
||
<path d="M12 8v6" stroke="currentColor" stroke-width="2" stroke-linecap="square" />
|
||
<path d="M11 16h2v2h-2z" fill="currentColor" />
|
||
</svg>
|
||
<p v-if="parts.length > 1">{{ parts[0] }}<span class="hn-email-wrap"><button type="button" class="hn-email" aria-label="复制邮箱地址 [email protected]" @click="copyEmail"><svg class="hn-copy-icon" width="15" height="15" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M8 8h9l3 3v10H8V8Z" stroke="currentColor" stroke-width="1.7" stroke-linejoin="miter"/><path d="M15 8V3H3v13h5" stroke="currentColor" stroke-width="1.7" stroke-linejoin="miter"/></svg>{{ email }}</button><span v-if="feedback" class="hn-copy-feedback" role="status">{{ feedback }}</span></span>{{ parts.slice(1).join(email) }}</p>
|
||
<p v-else>{{ t('dashboard.welcomeDesc') }}</p>
|
||
</div>
|
||
<div class="hn-welcome-notice hn-tutorial-row">
|
||
<svg width="19" height="19" viewBox="0 0 24 24" fill="none" aria-hidden="true" class="hn-signpost">
|
||
<path d="M8 16v-2L4 10V7l4-4h8l4 4v3l-4 4v2H8Z" fill="currentColor" fill-opacity=".1" stroke="currentColor" stroke-width="1.6" stroke-linejoin="miter" />
|
||
<path d="M9 18.5h6M10 21h4M10 9l2 2 2-2M12 11v5" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" />
|
||
</svg>
|
||
<p>新手不会使用?请查看<RouterLink class="hn-tutorial-link" to="/docs/1"><svg class="hn-tutorial-icon" width="15" height="15" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 2v20M3 5h15l4 4-4 4H3V5Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="miter"/><path d="M6 9h10M10 22h4" stroke="currentColor" stroke-width="1.6"/></svg>新手指引</RouterLink>。</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { RouterLink } from 'vue-router';
|
||
const { t } = useI18n();
|
||
const email = '[email protected]';
|
||
const parts = computed(() => t('dashboard.welcomeDesc').split(email));
|
||
const feedback = ref('');
|
||
let timer;
|
||
async function copyEmail() {
|
||
let copied = false;
|
||
if (navigator.clipboard?.writeText) {
|
||
try { await navigator.clipboard.writeText(email); copied = true; } catch { /* Use the local HTTP fallback. */ }
|
||
}
|
||
if (!copied) {
|
||
const previous = document.activeElement;
|
||
const field = document.createElement('textarea');
|
||
field.value = email;
|
||
field.setAttribute('readonly', '');
|
||
field.style.cssText = 'position:fixed;left:-9999px;top:0';
|
||
document.body.appendChild(field);
|
||
try { field.focus({ preventScroll: true }); field.select(); field.setSelectionRange(0, email.length); copied = document.execCommand('copy'); } catch { copied = false; }
|
||
finally { field.remove(); previous?.focus?.({ preventScroll: true }); }
|
||
}
|
||
feedback.value = copied ? '已复制' : '复制失败,请手动复制';
|
||
clearTimeout(timer);
|
||
timer = setTimeout(() => { feedback.value = ''; }, 2200);
|
||
}
|
||
onBeforeUnmount(() => clearTimeout(timer));
|
||
</script>
|
||
|
||
<style scoped>
|
||
.hn-welcome-lines { display:grid; gap:9px; }
|
||
.hn-signpost { flex:0 0 19px; margin-bottom:5px; color:var(--theme-color,#a3cc4b); }
|
||
.hn-tutorial-icon { flex:0 0 15px; }
|
||
.hn-tutorial-link { display:inline-flex; align-items:center; gap:4px; vertical-align:baseline; margin-left:4px; color:var(--theme-color,#a3cc4b); font-weight:600; text-decoration:none; }
|
||
.hn-tutorial-link:hover { text-decoration:underline; text-underline-offset:3px; }
|
||
.hn-tutorial-link:focus-visible { outline:2px solid var(--theme-color,#a3cc4b); outline-offset:3px; }
|
||
.hn-welcome-notice { display:flex; align-items:flex-end; gap:7px; line-height:1.8; }
|
||
.hn-warning { flex:0 0 19px; margin-bottom:5px; color:#e4bc58; }
|
||
p { margin:0; }
|
||
.hn-email-wrap { position:relative; display:inline-block; }
|
||
.hn-copy-icon { flex:0 0 15px; }
|
||
.hn-email { display:inline-flex; align-items:center; gap:4px; vertical-align:baseline; padding:0; border:0; border-radius:2px; background:none; color:var(--theme-color,#a3cc4b); font:inherit; font-weight:600; cursor:pointer; }
|
||
.hn-email:hover { text-decoration:underline; text-underline-offset:3px; }
|
||
.hn-email:focus-visible { outline:2px solid var(--theme-color,#a3cc4b); outline-offset:3px; }
|
||
.hn-copy-feedback { position:absolute; left:50%; bottom:calc(100% + 5px); transform:translateX(-50%); padding:2px 8px; border:1px solid var(--theme-color,#a3cc4b); border-radius:4px; background:var(--card-bg,#202429); color:var(--theme-color,#a3cc4b); font-size:12px; font-weight:500; white-space:nowrap; pointer-events:none; }
|
||
</style>
|