fix(biji-qianduan): 优化私密笔记和回收站的访问控制

- 移除 HomePage 中重复的私密笔记提示逻辑
- 在 markdown-preview 中通过条件渲染显示私密笔记提示- 为未登录用户提供回收站访问限制
- 新增私密笔记提示内容的单独文件
This commit is contained in:
2025-08-06 15:13:01 +08:00
parent e3bc24bd9a
commit 4d2f65c23f
3 changed files with 78 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
<template>
<el-container>
<el-container v-if="userStore.isLoggedIn">
<el-header>
<h1>回收站</h1>
<el-button type="danger" @click="handleCleanTrash" :disabled="trashItems.length === 0">清空回收站</el-button>
@@ -26,6 +26,18 @@
<el-empty v-if="trashItems.length === 0" description="回收站是空的"></el-empty>
</el-main>
</el-container>
<div v-else class="login-required">
<el-result
icon="warning"
title="需要登录"
sub-title="请先登录后再访问回收站"
>
<template #extra>
<el-button type="primary" @click="goToLogin">去登录</el-button>
<el-button @click="goBack">返回首页</el-button>
</template>
</el-result>
</div>
</template>
<script setup>
@@ -33,8 +45,10 @@ import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { getTrash, restoreTrashItem, permanentlyDeleteItem, cleanTrash } from '@/api/CommonApi.js';
import { useUserStore } from '../stores/user';
const router = useRouter();
const userStore = useUserStore();
const trashItems = ref([]);
const fetchTrashItems = async () => {
@@ -86,12 +100,18 @@ const handleCleanTrash = async () => {
}
};
const goToLogin = () => {
router.push('/login');
};
const goBack = () => {
router.push('/home');
};
onMounted(() => {
fetchTrashItems();
if (userStore.isLoggedIn) {
fetchTrashItems();
}
});
</script>
@@ -101,4 +121,11 @@ onMounted(() => {
justify-content: space-between;
align-items: center;
}
.login-required {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>