You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.3 KiB
61 lines
2.3 KiB
<template>
|
|
<!-- 新开账号的凭据回执:初始密码只在创建那一次拿得到(库里只存哈希),所以必须在这里显示一次,
|
|
邮件发失败时更是唯一的补救途径。 -->
|
|
<div v-if="info" class="modal modal-open">
|
|
<div class="modal-box max-w-md">
|
|
<h3 class="font-bold text-base mb-1">{{ info.title }}</h3>
|
|
<p class="text-xs text-slate-400 mb-3">初始密码仅在此显示一次,关闭后无法再查看(如需重设请到「后台账号」改密)。</p>
|
|
|
|
<div class="rounded-xl border border-slate-200 bg-slate-50 p-3 space-y-2">
|
|
<div class="flex items-center justify-between gap-3">
|
|
<span class="text-xs text-slate-500">登录用户名</span>
|
|
<span class="font-mono font-semibold text-sm">{{ info.username }}</span>
|
|
</div>
|
|
<div class="flex items-center justify-between gap-3">
|
|
<span class="text-xs text-slate-500">初始密码</span>
|
|
<span class="font-mono font-semibold text-sm">{{ info.password }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="info.mailTo" class="mt-3 text-xs text-emerald-600">
|
|
✓ 凭据已邮件发送至 {{ info.mailTo }}
|
|
</div>
|
|
<div v-else class="mt-3 text-xs text-amber-600">
|
|
⚠ 凭据未能邮件送达{{ info.mailError ? ':' + info.mailError : '' }},请手工转达上面的用户名和密码。
|
|
</div>
|
|
|
|
<div class="modal-action">
|
|
<button class="btn btn-ghost btn-sm" @click="copy">复制</button>
|
|
<button class="btn btn-primary btn-sm text-white" @click="$emit('close')">我已记录,关闭</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { useToast } from '~/composables/useToast'
|
|
|
|
export interface AccountCredential {
|
|
title: string
|
|
username: string
|
|
password: string
|
|
mailTo: string
|
|
mailError: string
|
|
}
|
|
|
|
const props = defineProps<{ info: AccountCredential | null }>()
|
|
defineEmits<{ (e: 'close'): void }>()
|
|
|
|
const { success, warn } = useToast()
|
|
|
|
async function copy() {
|
|
if (!props.info) return
|
|
const text = `用户名:${props.info.username}\n初始密码:${props.info.password}`
|
|
try {
|
|
await navigator.clipboard.writeText(text)
|
|
success('凭据已复制')
|
|
} catch {
|
|
warn('复制失败,请手工记录')
|
|
}
|
|
}
|
|
</script>
|
|
|