60 lines
2.7 KiB
Vue
60 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* features/user/components/UserPasswordDialog.vue
|
|
* 用途:呈现并提交当前用户的密码修改表单。
|
|
* 依赖:user-profile.context 提供的资料状态和操作方法。
|
|
* 逻辑:由工作台布局常驻渲染,用户资料页打开弹窗后在此完成密码修改。
|
|
*/
|
|
import { inject } from 'vue';
|
|
import { X } from 'lucide-vue-next';
|
|
import { USER_PROFILE_KEY } from '../composables/user-profile.context';
|
|
|
|
const userProfile = inject(USER_PROFILE_KEY)!;
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
v-if="userProfile.CHANGE_PASSWORD_ENABLED && userProfile.showPasswordModal"
|
|
class="dialog-overlay z-50 items-center"
|
|
>
|
|
<div class="dialog-panel max-w-md">
|
|
<div class="dialog-header">
|
|
<h3 class="section-title">{{ $t('profile.changePassword') || 'Change Password' }}</h3>
|
|
<button
|
|
type="button"
|
|
class="btn-icon-ds"
|
|
:aria-label="$t('admin.close')"
|
|
:disabled="userProfile.isChangingPassword"
|
|
@click="userProfile.showPasswordModal = false"
|
|
>
|
|
<X class="w-5 h-5" />
|
|
</button>
|
|
</div>
|
|
<form @submit.prevent="userProfile.handleChangePassword">
|
|
<div class="dialog-body">
|
|
<div>
|
|
<label class="label-field">{{ $t('profile.currentPassword') || 'Current Password' }}</label>
|
|
<input v-model="userProfile.passwordForm.current" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
|
</div>
|
|
<div>
|
|
<label class="label-field">{{ $t('profile.newPassword') || 'New Password' }}</label>
|
|
<input v-model="userProfile.passwordForm.new" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
|
</div>
|
|
<div>
|
|
<label class="label-field">{{ $t('profile.confirmPassword') || 'Confirm Password' }}</label>
|
|
<input v-model="userProfile.passwordForm.confirm" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
|
</div>
|
|
</div>
|
|
<div class="dialog-footer">
|
|
<button type="button" :disabled="userProfile.isChangingPassword" @click="userProfile.showPasswordModal = false" class="btn-secondary flex-1 disabled:opacity-50 disabled:cursor-not-allowed">
|
|
{{ $t('profile.cancel') || 'Cancel' }}
|
|
</button>
|
|
<button type="submit" :disabled="userProfile.isChangingPassword" class="btn-primary flex-1 disabled:opacity-50 disabled:cursor-not-allowed">
|
|
{{ userProfile.isChangingPassword ? $t('profile.changingPassword') : ($t('profile.changePassword') || 'Update') }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</template>
|