fix: 加载优化、vip状态优化、apikey优化

This commit is contained in:
Gsh
2025-08-04 23:11:42 +08:00
parent 0a2710b865
commit 65d5f5ae86
11 changed files with 172 additions and 93 deletions

View File

@@ -5,16 +5,12 @@ import Popover from '@/components/Popover/index.vue';
import SvgIcon from '@/components/SvgIcon/index.vue';
import { useUserStore } from '@/stores';
import { useSessionStore } from '@/stores/modules/session';
import { userProfilePicture } from '@/utils/user';
import { getUserProfilePicture, isUserVip } from '@/utils/user';
const router = useRouter();
const userStore = useUserStore();
const sessionStore = useSessionStore();
const userRole = computed(() => {
const roles = userStore.userInfo?.roles ?? [];
return roles.some(role => role.roleCode === 'YiXinAi-Vip') ? 'vip' : 'user';
});
// const src = computed(
// () => userStore.userInfo?.avatar ?? 'https://avatars.githubusercontent.com/u/76239030',
@@ -126,26 +122,25 @@ function handleClick(item: any) {
}
function openVipGuide() {
const isVip = userRole.value === 'vip' || userStore.userInfo?.user?.userName === 'cc';
ElMessageBox.confirm(
`
<div class="text-center leading-relaxed">
<h3 class="text-lg font-bold mb-3">${isVip ? 'YiXinAI-VIP 会员' : '成为 YiXinAI-VIP'}</h3>
<h3 class="text-lg font-bold mb-3">${isUserVip() ? 'YiXinAI-VIP 会员' : '成为 YiXinAI-VIP'}</h3>
<p class="mb-2">
${
isVip
isUserVip()
? '您已是尊贵会员,享受全部 AI 模型与专属服务。感谢支持!'
: '解锁所有 AI 模型,无限加速,专属客服,尽享尊贵体验。'
}
</p>
${
isVip
isUserVip()
? '<p class="text-sm text-gray-500">您可随时访问产品页面查看更多特权内容。</p>'
: '<p class="text-sm text-gray-500">点击下方按钮,立即升级为 VIP 会员!</p>'
}
</div>
`,
isVip ? '会员状态' : '会员尊享',
isUserVip() ? '会员状态' : '会员尊享',
{
confirmButtonText: '前往产品页面',
cancelButtonText: '关闭',
@@ -158,7 +153,7 @@ function openVipGuide() {
.then(() => {
router.push({
name: 'products', // 使用命名路由
query: { from: userRole.value }, // 可选:添加来源标识
query: { from: isUserVip() ? 'vip' : 'user' }, // 可选:添加来源标识
});
})
.catch(() => {
@@ -180,7 +175,7 @@ function openVipGuide() {
<!-- 角色展示 -->
<div>
<span
v-if="userRole === 'vip'"
v-if="isUserVip()"
class="inline-block px-2 py-0.5 text-xs text-yellow-700 bg-yellow-100 rounded-full font-semibold"
>
YiXinAI-VIP
@@ -206,20 +201,20 @@ function openVipGuide() {
:popover-style="popoverStyle"
>
<template #trigger>
<el-avatar :src="userProfilePicture" :size="28" fit="fit" shape="circle" />
<el-avatar :src="getUserProfilePicture()" :size="28" fit="fit" shape="circle" />
</template>
<div class="popover-content-box shadow-lg">
<!-- 用户信息 -->
<div class="user-info-box flex items-center gap-8px p-8px rounded-lg mb-2">
<el-avatar :src="userProfilePicture" :size="32" fit="fit" shape="circle" />
<el-avatar :src="getUserProfilePicture()" :size="32" fit="fit" shape="circle" />
<div class="flex flex-col text-sm">
<div class="font-semibold text-gray-800">
{{ userStore.userInfo?.user.nick ?? '未登录用户' }}
</div>
<div class="text-xs text-gray-500">
<span
v-if="userRole === 'vip'"
v-if="isUserVip()"
class="inline-block px-2 py-0.5 text-xs text-yellow-700 bg-yellow-100 rounded-full font-semibold"
>
YiXinAI-VIP