-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script setup lang="ts"> | ||
import { useI18n } from '@/hooks/web/useI18n' | ||
import { ref, unref } from 'vue' | ||
import { Dialog } from '@/components/Dialog' | ||
import { Form } from '@/components/Form' | ||
import { useForm } from '@/hooks/web/useForm' | ||
import { reactive, computed } from 'vue' | ||
import { useValidator } from '@/hooks/web/useValidator' | ||
import { FormSchema } from '@/types/form' | ||
import { ElButton } from 'element-plus' | ||
import { useDesign } from '@/hooks/web/useDesign' | ||
import { useLockStore } from '@/store/modules/lock' | ||
const { getPrefixCls } = useDesign() | ||
const prefixCls = getPrefixCls('lock-dialog') | ||
const { required } = useValidator() | ||
const { t } = useI18n() | ||
const lockStore = useLockStore() | ||
const props = defineProps({ | ||
modelValue: { | ||
type: Boolean | ||
} | ||
}) | ||
const emit = defineEmits(['update:modelValue']) | ||
const dialogVisible = computed({ | ||
get: () => props.modelValue, | ||
set: (val) => { | ||
console.log('set: ', val) | ||
emit('update:modelValue', val) | ||
} | ||
}) | ||
const dialogTitle = ref(t('lock.lockScreen')) | ||
const rules = reactive({ | ||
password: [required()] | ||
}) | ||
const schema: FormSchema[] = reactive([ | ||
{ | ||
label: t('lock.lockPassword'), | ||
field: 'password', | ||
component: 'Input', | ||
componentProps: { | ||
type: 'password', | ||
showPassword: true | ||
} | ||
} | ||
]) | ||
const { register, formRef, methods } = useForm({ | ||
schema | ||
}) | ||
const { getFormData } = methods | ||
const handleLock = () => { | ||
unref(formRef)?.validate(async (valid) => { | ||
if (valid) { | ||
dialogVisible.value = false | ||
const formData = await getFormData() | ||
lockStore.setLockInfo({ | ||
isLock: true, | ||
...formData | ||
}) | ||
} | ||
}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<Dialog | ||
v-model="dialogVisible" | ||
width="500px" | ||
max-height="170px" | ||
:class="prefixCls" | ||
:title="dialogTitle" | ||
> | ||
<div class="flex flex-col items-center"> | ||
<img src="@/assets/imgs/avatar.jpg" alt="" class="w-70px h-70px rounded-[50%]" /> | ||
<span class="text-14px my-10px text-[var(--top-header-text-color)]">Archer</span> | ||
</div> | ||
<Form :is-col="false" :rules="rules" @register="register" /> | ||
<template #footer> | ||
<ElButton type="primary" @click="handleLock">{{ t('lock.lock') }}</ElButton> | ||
</template> | ||
</Dialog> | ||
</template> | ||
|
||
<style lang="less" scoped> | ||
:global(.v-lock-dialog) { | ||
@media (max-width: 767px) { | ||
max-width: calc(100vw - 16px); | ||
} | ||
} | ||
</style> |
Oops, something went wrong.