修改密码完成
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { Icon } from '@iconify/vue'
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { useRouterPush } from '@/hooks/common/router';
|
||||
import { changePasswordApi } from '@/service/api/user';
|
||||
import { changePasswordApi } from '@/service/api/auth';
|
||||
import { clearAuthStorage } from '@/store/modules/auth/shared';
|
||||
|
||||
const appStore = useAppStore();
|
||||
const themeStore = useThemeStore();
|
||||
const { toLogin } = useRouterPush();
|
||||
const gap = computed(() => (appStore.isMobile ? 0 : 16));
|
||||
|
||||
const formModel = ref<{oldPassword: string;password: string;confirmPassword: string;}>({
|
||||
oldPassword: '',
|
||||
@@ -37,11 +35,13 @@ const submitForm = async (e: MouseEvent) => {
|
||||
if (!errors) {
|
||||
btnLoading.value = true;
|
||||
const {error} = await changePasswordApi({
|
||||
oldPassword: formModel.value.oldPassword,
|
||||
password: formModel.value.password,
|
||||
old_password: formModel.value.oldPassword,
|
||||
new_password: formModel.value.password,
|
||||
confirm_password: formModel.value.confirmPassword,
|
||||
});
|
||||
if(!error){
|
||||
window.$message?.success('修改成功')
|
||||
window.$message?.success('修改成功,请重新登录')
|
||||
clearAuthStorage();
|
||||
toLogin();
|
||||
}
|
||||
btnLoading.value = false;
|
||||
@@ -61,7 +61,7 @@ onMounted(() => {
|
||||
<!-- 修改密码 -->
|
||||
<NCard :bordered="false" size="small" :style="{ borderRadius: themeStore.themeRadius + 'px' }">
|
||||
<div class="border mb-3 py-2 px-3" :style="{ borderRadius: themeStore.themeRadius + 'px' }">
|
||||
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
|
||||
<NGrid :x-gap="16" :y-gap="16" responsive="screen" item-responsive>
|
||||
<NGi span="24 s:24 m:24">
|
||||
<div class="h-100% flex items-center gap-2">
|
||||
<Icon icon="boxicons:lock-open" class="size-16px" :style="{ color: themeStore.themeColor }" />
|
||||
|
||||
Reference in New Issue
Block a user