feat(user): 修改OTP登录验证码为"1234"以增强安全性

feat(main): 添加种子命令以初始化数据库数据
feat(consts): 添加创作者角色常量
feat(profile): 更新用户资料页面以支持从API获取用户信息
feat(library): 实现用户库页面以获取已购内容并显示状态
feat(contents): 更新内容编辑页面以支持文件上传和自动保存
feat(topnavbar): 优化用户头像显示逻辑以支持动态加载
This commit is contained in:
2025-12-30 21:55:48 +08:00
parent ff22ca1264
commit 7a8c5c4427
9 changed files with 466 additions and 157 deletions

View File

@@ -44,15 +44,14 @@
<!-- Avatar Dropdown -->
<div class="relative group h-full flex items-center">
<button class="w-9 h-9 rounded-full overflow-hidden border border-slate-200 focus:ring-2 ring-primary-100">
<img src="https://api.dicebear.com/7.x/avataaars/svg?seed=Felix" alt="User" class="w-full h-full object-cover">
<img :src="user.avatar || `https://api.dicebear.com/7.x/avataaars/svg?seed=${user.id}`" alt="User" class="w-full h-full object-cover">
</button>
<!-- Dropdown Menu (Mock) -->
<!-- Added pt-2 to create a safe hover zone bridge -->
<!-- Dropdown Menu -->
<div class="absolute right-0 top-full pt-2 w-48 hidden group-hover:block">
<div class="bg-white rounded-xl shadow-lg border border-slate-100 py-1">
<div class="px-4 py-3 border-b border-slate-50">
<p class="text-sm font-bold text-slate-900">Felix Demo</p>
<p class="text-xs text-slate-500 truncate">felix@example.com</p>
<p class="text-sm font-bold text-slate-900">{{ user.nickname }}</p>
<p class="text-xs text-slate-500 truncate">{{ user.phone }}</p>
</div>
<router-link to="/me" class="block px-4 py-2 text-sm text-slate-700 hover:bg-slate-50">个人中心</router-link>
<router-link to="/creator" class="block px-4 py-2 text-sm text-slate-700 hover:bg-slate-50">创作者中心</router-link>
@@ -64,8 +63,7 @@
</template>
<template v-else>
<router-link to="/auth/login" class="text-slate-600 font-medium hover:text-primary-600 px-3 py-2">登录</router-link>
<router-link to="/auth/login" class="bg-primary-600 text-white px-5 py-2 rounded-full font-medium hover:bg-primary-700 transition-colors">注册</router-link>
<router-link to="/auth/login" class="bg-primary-600 text-white px-6 py-2 rounded-full font-medium hover:bg-primary-700 transition-all shadow-sm shadow-primary-100 active:scale-95">登录 / 注册</router-link>
</template>
<!-- Mobile Menu Button -->
@@ -78,14 +76,43 @@
</template>
<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { ref, onMounted, watch } from 'vue';
import { useRouter, useRoute } from 'vue-router';
const isLoggedIn = ref(true); // Mock login state
const isLoggedIn = ref(false);
const user = ref({});
const router = useRouter();
const route = useRoute();
const checkAuth = () => {
const token = localStorage.getItem('token');
const userStr = localStorage.getItem('user');
if (token && userStr) {
isLoggedIn.value = true;
try {
user.value = JSON.parse(userStr);
} catch (e) {
isLoggedIn.value = false;
}
} else {
isLoggedIn.value = false;
}
};
onMounted(() => {
checkAuth();
});
// Watch route changes to refresh auth state (e.g. after login redirect)
watch(() => route.path, () => {
checkAuth();
});
const logout = () => {
localStorage.removeItem('token');
localStorage.removeItem('user');
isLoggedIn.value = false;
user.value = {};
router.push('/');
};
</script>