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

@@ -8,19 +8,15 @@ import Popover from '@/components/Popover/index.vue';
import SvgIcon from '@/components/SvgIcon/index.vue';
import { useUserStore } from '@/stores';
import { useModelStore } from '@/stores/modules/model';
import { isUserVip } from '@/utils/user';
const router = useRouter();
// 用户角色
const isUserRoleVip = computed(() => {
const roles = userStore.userInfo?.roles ?? [];
return roles.some(role => role.roleCode === 'YiXinAi-Vip');
});
const userStore = useUserStore();
const modelStore = useModelStore();
// 检查模型是否可用
function isModelAvailable(item: GetSessionListVO) {
return isUserRoleVip.value || item.modelId?.includes('DeepSeek-R1-0528') || userStore.userInfo?.user?.userName === 'cc';
return isUserVip() || item.modelId?.includes('DeepSeek-R1-0528') || userStore.userInfo?.user?.userName === 'cc';
}
onMounted(async () => {
@@ -64,22 +60,22 @@ function handleModelClick(item: GetSessionListVO) {
ElMessageBox.confirm(
`
<div class="text-center leading-relaxed">
<h3 class="text-lg font-bold mb-3">${isUserRoleVip.value ? 'YiXinAI-VIP 会员' : '成为 YiXinAI-VIP'}</h3>
<h3 class="text-lg font-bold mb-3">${isUserVip() ? 'YiXinAI-VIP 会员' : '成为 YiXinAI-VIP'}</h3>
<p class="mb-2">
${
isUserRoleVip.value
isUserVip()
? '您已是尊贵会员,享受全部 AI 模型与专属服务。感谢支持!'
: '解锁所有 AI 模型,无限加速,专属客服,尽享尊贵体验。'
}
</p>
${
isUserRoleVip.value
isUserVip()
? '<p class="text-sm text-gray-500">您可随时访问产品页面查看更多特权内容。</p>'
: '<p class="text-sm text-gray-500">点击下方按钮,立即升级为 VIP 会员!</p>'
}
</div>
`,
isUserRoleVip.value ? '会员状态' : '会员尊享',
isUserVip() ? '会员状态' : '会员尊享',
{
confirmButtonText: '前往产品页面',
cancelButtonText: '关闭',
@@ -92,7 +88,7 @@ function handleModelClick(item: GetSessionListVO) {
.then(() => {
router.push({
name: 'products', // 使用命名路由
query: { from: isUserRoleVip.value ? 'vip' : 'user' }, // 可选:添加来源标识
query: { from: isUserVip() ? 'vip' : 'user' }, // 可选:添加来源标识
});
})
.catch(() => {

View File

@@ -3,7 +3,7 @@ import { CircleCheck } from '@element-plus/icons-vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { applyApiKey, getApiKey, getRechargeLog } from '@/api/model/index.ts';
import { applyApiKey, getApiKey } from '@/api/model/index.ts';
import { isUserVip } from '@/utils/user';
const apiKey = ref('');
@@ -29,8 +29,6 @@ const router = useRouter();
async function fetchApiKey() {
try {
const res = await getApiKey();
const res2 = await getRechargeLog();
console.log('re2', res2);
if (res.data?.apiKey) {
apiKey.value = res.data.apiKey;
displayedKey.value = res.data.apiKey;
@@ -43,7 +41,7 @@ async function fetchApiKey() {
// 领取密钥
async function handleClaim() {
if (!isUserVip) {
if (!isUserVip()) {
ElMessageBox.confirm(
`
<div class="text-center leading-relaxed">
@@ -172,7 +170,7 @@ onMounted(async () => {
element-loading-background="rgba(122, 122, 122, 0.8)"
>
<!-- 未领取状态 -->
<div v-if="!apiKey " class="unclaimed-state">
<div v-if="!apiKey" class="unclaimed-state">
<div class="gift-container" @click="handleClaim">
<div class="gift-box" :class="{ opening: isOpening }">
<div class="gift-lid" />
@@ -239,7 +237,7 @@ onMounted(async () => {
</div>
</div>
<!-- 使用说明 -->
<div class="usage-guide">
<div v-if="apiKey" class="usage-guide">
<el-divider />
<h3>使用说明</h3>
<div class="guide-content">