原来只发 reveal 事件,露出去就没有回头路,只有翻页 / 搜索才会回到打码状态 —— 看一眼就该关掉,不然一整页管理员密码那么摊着。改成 toggle,打码与否只看 revealed 这一个 prop,按钮文案跟着走。 密码列顺带从 150 拓到 180:露出明文后面还跟着「隐藏」按钮,150 挤不下。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xu912Rv5JUUuy6MqMcQW2
This commit is contained in:
1 parent
6a438872b9
commit
3a8f4fcd51
2 files changed
+17
-12
No files matched your search
@@ -9,11 +9,11 @@ interface Props {
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
defineEmits<{
|
||||
(e: "reveal", value: number): void
|
||||
(e: "toggle", value: number): void
|
||||
}>()
|
||||
|
||||
/**
|
||||
* 只有**管理员账号**的密码默认打码。
|
||||
* 只有**管理员账号**的密码需要打码。
|
||||
*
|
||||
* 学生的密码照旧直接显示 —— 老师查学生密码是日常动作(明文列 `raw_password` 就是为它
|
||||
* 保留的),挡一道只是添乱。要防的是管理员密码在投屏、或者旁人路过时被看到。
|
||||
@@ -21,18 +21,20 @@ defineEmits<{
|
||||
* `rawPassword` 为空时不打码:给一个点了什么也不显示的按钮没有意义,直接走原来的
|
||||
* TextCopy(渲染成空)。
|
||||
*/
|
||||
const masked = computed(
|
||||
const maskable = computed(
|
||||
() =>
|
||||
!props.revealed &&
|
||||
props.user.adminType !== USER_TYPE.REGULAR_USER &&
|
||||
!!props.user.rawPassword,
|
||||
)
|
||||
</script>
|
||||
<template>
|
||||
<n-flex v-if="masked" align="center" :size="6" :wrap="false">
|
||||
<span class="dots">••••••</span>
|
||||
<n-button size="tiny" secondary @click="$emit('reveal', props.user.id)">
|
||||
显示
|
||||
<!-- 显示出来之后要能再收回去:看一眼就该关掉,不然一整页管理员密码就那么摊着,
|
||||
只有翻页 / 搜索才会回到打码状态 -->
|
||||
<n-flex v-if="maskable" align="center" :size="6" :wrap="false">
|
||||
<span v-if="!props.revealed" class="dots">••••••</span>
|
||||
<TextCopy v-else>{{ props.user.rawPassword }}</TextCopy>
|
||||
<n-button size="tiny" secondary @click="$emit('toggle', props.user.id)">
|
||||
{{ props.revealed ? "隐藏" : "显示" }}
|
||||
</n-button>
|
||||
</n-flex>
|
||||
<TextCopy v-else>{{ props.user.rawPassword }}</TextCopy>
|
||||
|
||||
Reference in new issue
Block a user