Compare commits

...

2 Commits

Author SHA1 Message Date
tao
3b68a6af49 增加退出登录功能
优化登录界面验证码显示
2025-12-16 15:32:16 +08:00
tao
29f80a48ef 默认初始界面改为 1 号线界面 2025-12-15 16:39:50 +08:00
2 changed files with 36 additions and 4 deletions

View File

@@ -11,13 +11,19 @@
<a-col :span="16" class="modal-value">{{ item.value }}</a-col>
</template>
</a-row>
<div class="actions">
<a-button size="large" @click="handleLogout">退出登录</a-button>
</div>
</a-modal>
</template>
<script setup>
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { useDialog } from '@/utils/useDialog';
import { useRealTime } from '@/utils/dateUtils';
import { Modal } from 'ant-design-vue';
import { removeToken } from '@/utils/auth';
// 实时时间
const { currentTime } = useRealTime('HH:mm:ss');
@@ -38,6 +44,21 @@ const modalItems = ref([
{ label: '内存使用', value: '2.1GB / 8GB' }
]);
const router = useRouter();
const handleLogout = () => {
Modal.confirm({
title: '提示',
content: '确认退出登录?',
onOk() {
removeToken();
return router.push(`/login`);
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
onCancel() {},
});
}
defineExpose({
show,
hide
@@ -73,4 +94,15 @@ defineExpose({
color: $text-light;
}
}
.actions {
margin: 20px 0 10px;
display: flex;
gap: 10px;
justify-content: space-between;
.ant-btn {
flex: 1;
}
}
</style>

View File

@@ -23,7 +23,7 @@ const loading = ref(false)
const captchaLoading = ref(false)
// 表单验证规则
const rules: Record<string, Rule[]> = {
const rules: Record<string, Rule[]> = reactive({
username: [
{ required: true, message: '请输入用户名', trigger: 'change' }
],
@@ -33,7 +33,7 @@ const rules: Record<string, Rule[]> = {
code: [
{ required: true, message: '请输入验证码', trigger: 'change' }
]
}
})
// 获取验证码
const refreshCaptcha = async () => {
@@ -67,7 +67,7 @@ const handleLogin = async () => {
setToken(res.token)
// 可以在这里保存用户信息到store
// 跳转到主页
router.push('/')
router.push('/lms')
} else {
message.error(res.msg || '登录失败')
// 登录失败后重新获取验证码