2024-07-12 12:14:09 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed, reactive } from 'vue';
|
|
|
|
|
2024-08-25 23:40:52 +08:00
|
|
|
import { useVbenModal } from '@vben-core/popup-ui';
|
2024-07-12 12:14:09 +08:00
|
|
|
import {
|
|
|
|
VbenAvatar,
|
|
|
|
VbenButton,
|
|
|
|
VbenInputPassword,
|
|
|
|
} from '@vben-core/shadcn-ui';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
avatar?: string;
|
|
|
|
text?: string;
|
|
|
|
}
|
|
|
|
|
2024-08-11 21:01:22 +08:00
|
|
|
interface LockAndRegisterParams {
|
|
|
|
lockScreenPassword: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RegisterEmits {
|
|
|
|
submit: [LockAndRegisterParams];
|
|
|
|
}
|
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
defineOptions({
|
|
|
|
name: 'LockScreenModal',
|
|
|
|
});
|
2024-08-25 23:40:52 +08:00
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
withDefaults(defineProps<Props>(), {
|
|
|
|
avatar: '',
|
|
|
|
text: '',
|
|
|
|
});
|
2024-08-25 23:40:52 +08:00
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
const emit = defineEmits<{
|
|
|
|
submit: RegisterEmits['submit'];
|
|
|
|
}>();
|
2024-08-25 23:40:52 +08:00
|
|
|
|
|
|
|
const [Modal] = useVbenModal({
|
|
|
|
onConfirm() {
|
|
|
|
handleSubmit();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
const formState = reactive({
|
|
|
|
lockScreenPassword: '',
|
|
|
|
submitted: false,
|
|
|
|
});
|
2024-08-25 23:40:52 +08:00
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
const passwordStatus = computed(() => {
|
|
|
|
return formState.submitted && !formState.lockScreenPassword
|
|
|
|
? 'error'
|
|
|
|
: 'default';
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleSubmit() {
|
|
|
|
formState.submitted = true;
|
|
|
|
if (passwordStatus.value !== 'default') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
emit('submit', {
|
|
|
|
lockScreenPassword: formState.lockScreenPassword,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-08-25 23:40:52 +08:00
|
|
|
<Modal
|
|
|
|
:footer="false"
|
|
|
|
:fullscreen-button="false"
|
|
|
|
:title="$t('widgets.lockScreen.title')"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="mb-10 flex w-full flex-col items-center px-10"
|
|
|
|
@keypress.enter.prevent="handleSubmit"
|
|
|
|
>
|
|
|
|
<div class="w-full">
|
|
|
|
<div class="ml-2 flex w-full flex-col items-center">
|
|
|
|
<VbenAvatar
|
|
|
|
:src="avatar"
|
|
|
|
class="size-20"
|
|
|
|
dot-class="bottom-0 right-1 border-2 size-4 bg-green-500"
|
|
|
|
/>
|
|
|
|
<div class="text-foreground my-6 flex items-center font-medium">
|
|
|
|
{{ text }}
|
2024-07-12 12:14:09 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-08-25 23:40:52 +08:00
|
|
|
<VbenInputPassword
|
|
|
|
v-model="formState.lockScreenPassword"
|
|
|
|
:error-tip="$t('widgets.lockScreen.placeholder')"
|
|
|
|
:label="$t('widgets.lockScreen.password')"
|
|
|
|
:placeholder="$t('widgets.lockScreen.placeholder')"
|
|
|
|
:status="passwordStatus"
|
|
|
|
name="password"
|
|
|
|
required
|
|
|
|
type="password"
|
|
|
|
/>
|
|
|
|
<VbenButton class="w-full" @click="handleSubmit">
|
|
|
|
{{ $t('widgets.lockScreen.screenButton') }}
|
|
|
|
</VbenButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Modal>
|
2024-07-12 12:14:09 +08:00
|
|
|
</template>
|