فهرست منبع

🐛 fix(preview): 修复会员下载权限判断逻辑

- 将会员判断条件从 membership 改为 userType === 'premium'
- 移除未使用的 Eye 图标导入和 getFileIcon 函数
- 统一下载按钮的禁用条件判断逻辑
yourname 3 ماه پیش
والد
کامیت
c7e2330143
2فایلهای تغییر یافته به همراه4 افزوده شده و 18 حذف شده
  1. 3 17
      src/client/home/components/FilePreview.tsx
  2. 1 1
      src/client/home/components/RechargeRecords.tsx

+ 3 - 17
src/client/home/components/FilePreview.tsx

@@ -3,7 +3,7 @@ import { publicTemplateClient } from '@/client/api';
 import { Card, CardContent, CardHeader, CardTitle } from '@/client/components/ui/card';
 import { Button } from '@/client/components/ui/button';
 import { Badge } from '@/client/components/ui/badge';
-import { Loader2, Download, Eye, AlertCircle } from 'lucide-react';
+import { Loader2, Download, AlertCircle } from 'lucide-react';
 import { toast } from 'sonner';
 import { useAuth } from '@/client/home/hooks/AuthProvider';
 import { useNavigate } from 'react-router-dom';
@@ -53,7 +53,7 @@ const FilePreview: React.FC<FilePreviewProps> = ({ templateId, onClose }) => {
       return;
     }
 
-    if (!template.isFree && !user.membership) {
+    if (!template.isFree && user?.userType !== 'premium') {
       toast.error('需要购买会员才能下载');
       navigate('/pricing');
       return;
@@ -80,20 +80,6 @@ const FilePreview: React.FC<FilePreviewProps> = ({ templateId, onClose }) => {
     }
   };
 
-  const getFileIcon = (fileType: string) => {
-    switch (fileType) {
-      case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
-        return '📝';
-      case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
-        return '📊';
-      case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
-        return '📊';
-      case 'application/pdf':
-        return '📄';
-      default:
-        return '📁';
-    }
-  };
 
   const renderPreview = () => {
     if (!previewUrl) {
@@ -215,7 +201,7 @@ const FilePreview: React.FC<FilePreviewProps> = ({ templateId, onClose }) => {
               </Button>
               <Button
                 onClick={handleDownload}
-                disabled={!template.isFree && !user?.membership}
+                disabled={!template.isFree && user?.userType !== 'premium'}
               >
                 <Download className="w-4 h-4 mr-2" />
                 {template.isFree ? '免费下载' : '会员下载'}

+ 1 - 1
src/client/home/components/RechargeRecords.tsx

@@ -1,5 +1,5 @@
 import { useState, useEffect } from 'react';
-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/client/components/ui/card';
+import { Card, CardContent } from '@/client/components/ui/card';
 import { Badge } from '@/client/components/ui/badge';
 import { Skeleton } from '@/client/components/ui/skeleton';
 import { Alert, AlertDescription } from '@/client/components/ui/alert';