57 lines
1.7 KiB
Vue
57 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import { reactive, ref } from 'vue';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
import { Alert, Button, Card, Form, FormItem, Input, message } from 'ant-design-vue';
|
|
|
|
import { changeMyPassword } from '#/api/console';
|
|
|
|
const router = useRouter();
|
|
const submitting = ref(false);
|
|
const form = reactive({ current_password: '', new_password: '', confirm: '' });
|
|
|
|
async function submit() {
|
|
if (form.new_password !== form.confirm) {
|
|
message.warning('两次输入的新密码不一致');
|
|
return;
|
|
}
|
|
submitting.value = true;
|
|
try {
|
|
await changeMyPassword({
|
|
current_password: form.current_password,
|
|
new_password: form.new_password,
|
|
});
|
|
message.success('密码已修改');
|
|
await router.push('/');
|
|
} finally {
|
|
submitting.value = false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="mx-auto max-w-xl p-5">
|
|
<Alert
|
|
class="mb-4"
|
|
type="warning"
|
|
show-icon
|
|
message="首次登录必须修改初始密码"
|
|
description="初始密码是公开的默认值,不改等于没有密码。改完才能进入其他页面。"
|
|
/>
|
|
<Card title="修改密码">
|
|
<Form :model="form" layout="vertical">
|
|
<FormItem label="当前密码">
|
|
<Input.Password v-model:value="form.current_password" />
|
|
</FormItem>
|
|
<FormItem label="新密码(至少 10 位,需同时含字母和数字)">
|
|
<Input.Password v-model:value="form.new_password" />
|
|
</FormItem>
|
|
<FormItem label="确认新密码">
|
|
<Input.Password v-model:value="form.confirm" />
|
|
</FormItem>
|
|
<Button type="primary" :loading="submitting" @click="submit">提交</Button>
|
|
</Form>
|
|
</Card>
|
|
</div>
|
|
</template>
|