|
| 1 | +import noop from '../../utils/noop' |
| 2 | +import { hasSeenEnhancedPromotionAtom } from '@/store' |
| 3 | +import { Dialog, Transition } from '@headlessui/react' |
| 4 | +import { track } from '@vercel/analytics' |
| 5 | +import { useAtom } from 'jotai' |
| 6 | +import type React from 'react' |
| 7 | +import { Fragment, useEffect, useState } from 'react' |
| 8 | +import IconStar from '~icons/heroicons/star-solid' |
| 9 | +import IconX from '~icons/tabler/x' |
| 10 | + |
| 11 | +const EnhancedPromotionModal: React.FC = () => { |
| 12 | + const [hasSeenPromotion, setHasSeenPromotion] = useAtom(hasSeenEnhancedPromotionAtom) |
| 13 | + const [isOpen, setIsOpen] = useState(false) |
| 14 | + |
| 15 | + useEffect(() => { |
| 16 | + // Only show modal if user hasn't seen it before |
| 17 | + if (!hasSeenPromotion) { |
| 18 | + const timer = setTimeout(() => { |
| 19 | + setIsOpen(true) |
| 20 | + }, 2000) // Show after 2 seconds to let the page load |
| 21 | + |
| 22 | + return () => clearTimeout(timer) |
| 23 | + } |
| 24 | + }, [hasSeenPromotion]) |
| 25 | + |
| 26 | + const handleTryNow = () => { |
| 27 | + track('promotion_event', { |
| 28 | + from: 'enhanced_promotion_modal', |
| 29 | + action: 'open', |
| 30 | + }) |
| 31 | + setHasSeenPromotion(true) |
| 32 | + // setIsOpen(false) |
| 33 | + // Open in new tab |
| 34 | + window.open('https://qwertylearner.ai', '_blank') |
| 35 | + } |
| 36 | + |
| 37 | + const handleDismiss = () => { |
| 38 | + track('promotion_event', { |
| 39 | + from: 'enhanced_promotion_modal', |
| 40 | + action: 'close', |
| 41 | + }) |
| 42 | + setHasSeenPromotion(true) |
| 43 | + setIsOpen(false) |
| 44 | + } |
| 45 | + |
| 46 | + return ( |
| 47 | + <Transition.Root show={isOpen} as={Fragment}> |
| 48 | + <Dialog as="div" className="relative z-50" onClose={noop}> |
| 49 | + <Transition.Child |
| 50 | + as={Fragment} |
| 51 | + enter="ease-out duration-300" |
| 52 | + enterFrom="opacity-0" |
| 53 | + enterTo="opacity-100" |
| 54 | + leave="ease-in duration-200" |
| 55 | + leaveFrom="opacity-100" |
| 56 | + leaveTo="opacity-0" |
| 57 | + > |
| 58 | + <div className="fixed inset-0 bg-black bg-opacity-40 backdrop-blur-sm transition-opacity" /> |
| 59 | + </Transition.Child> |
| 60 | + |
| 61 | + <div className="fixed inset-0 z-10 overflow-y-auto"> |
| 62 | + <div className="flex min-h-full items-center justify-center p-4 text-center"> |
| 63 | + <Transition.Child |
| 64 | + as={Fragment} |
| 65 | + enter="ease-out duration-300" |
| 66 | + enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" |
| 67 | + enterTo="opacity-100 translate-y-0 sm:scale-100" |
| 68 | + leave="ease-in duration-200" |
| 69 | + leaveFrom="opacity-100 translate-y-0 sm:scale-100" |
| 70 | + leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" |
| 71 | + > |
| 72 | + <Dialog.Panel className="dark:via-gray-850 relative transform overflow-hidden rounded-2xl border border-blue-200 bg-gradient-to-br from-white via-blue-50 to-indigo-100 p-0 text-left shadow-2xl transition-all dark:border-gray-700 dark:from-gray-800 dark:to-gray-900 sm:my-8 sm:w-full sm:max-w-xl"> |
| 73 | + {/* Header with close button */} |
| 74 | + <div className="absolute right-4 top-4 z-10"> |
| 75 | + <button |
| 76 | + type="button" |
| 77 | + onClick={handleDismiss} |
| 78 | + className="rounded-full p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300" |
| 79 | + title="关闭" |
| 80 | + > |
| 81 | + <IconX className="h-5 w-5" /> |
| 82 | + </button> |
| 83 | + </div> |
| 84 | + |
| 85 | + {/* Content */} |
| 86 | + <div className="px-8 pb-8 pt-10"> |
| 87 | + {/* Icon and title */} |
| 88 | + <div className="mb-6 text-center"> |
| 89 | + <div className="mx-auto mb-4 flex h-20 w-20 animate-pulse items-center justify-center rounded-full bg-gradient-to-r from-blue-500 to-purple-600 shadow-lg"> |
| 90 | + <IconStar className="h-10 w-10 text-white" /> |
| 91 | + </div> |
| 92 | + <h3 className="bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-3xl font-bold text-transparent"> |
| 93 | + 体验 QwertyLearner.ai |
| 94 | + </h3> |
| 95 | + |
| 96 | + <p className="mt-2 text-sm text-gray-600 dark:text-gray-400">解锁更强大的学习体验 ✨</p> |
| 97 | + </div> |
| 98 | + |
| 99 | + {/* Main content */} |
| 100 | + <div className="space-y-4 py-2 text-sm text-gray-700 dark:text-gray-300"> |
| 101 | + <p className="text-center font-medium text-gray-900 dark:text-white"> |
| 102 | + 不会编程?想拥有自己的专属学习词典?操作简单,一键上传,点击即用 |
| 103 | + <br /> |
| 104 | + <div className="my-2"></div> |
| 105 | + 那么,推荐您尝试由英国 DeepLearningAI 专业团队开发运营的 QwertyLearner.ai |
| 106 | + </p> |
| 107 | + |
| 108 | + <div className="rounded-lg bg-white p-4 shadow-sm dark:bg-gray-800"> |
| 109 | + <h4 className="mb-3 font-semibold text-gray-900 dark:text-white">🚀 专业功能</h4> |
| 110 | + <ul className="space-y-2.5"> |
| 111 | + <li className="flex items-start"> |
| 112 | + <span className="mr-2 mt-0.5 text-blue-500">•</span> |
| 113 | + <span> |
| 114 | + <strong>AI 智能词库</strong> - 一键上传,智能生成释义和词性,打造专属自定义词库 |
| 115 | + </span> |
| 116 | + </li> |
| 117 | + <li className="flex items-start"> |
| 118 | + <span className="mr-2 mt-0.5 text-blue-500">•</span> |
| 119 | + <span> |
| 120 | + <strong>文章练习</strong> - 自定义文章内容,提升实战能力 |
| 121 | + </span> |
| 122 | + </li> |
| 123 | + <li className="flex items-start"> |
| 124 | + <span className="mr-2 mt-0.5 text-blue-500">•</span> |
| 125 | + <span> |
| 126 | + <strong>云端同步</strong> - 多设备练习记录、错题库同步 |
| 127 | + </span> |
| 128 | + </li> |
| 129 | + <li className="flex items-start"> |
| 130 | + <span className="mr-2 mt-0.5 text-blue-500">•</span> |
| 131 | + <span> |
| 132 | + <strong>词典选择</strong> - 更多丰富的专业词库 |
| 133 | + </span> |
| 134 | + </li> |
| 135 | + </ul> |
| 136 | + </div> |
| 137 | + |
| 138 | + <div className="rounded-lg bg-amber-50 p-3 text-xs text-amber-800 dark:bg-amber-900/20 dark:text-amber-200"> |
| 139 | + <p> |
| 140 | + <strong>说明:</strong>QwertyLearner.ai 由英国 DeepLearningAI 独立开发运营,为开源版 QwertyLearner |
| 141 | + 的独立衍生版本,开源版将持续维持开源与开放运营。 |
| 142 | + </p> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + |
| 146 | + {/* Action buttons */} |
| 147 | + <div className="mt-8 space-y-3"> |
| 148 | + <button |
| 149 | + type="button" |
| 150 | + onClick={handleTryNow} |
| 151 | + className="w-full transform rounded-lg bg-gradient-to-r from-blue-500 to-purple-600 px-8 py-4 text-lg font-bold text-white shadow-lg transition-all duration-200 hover:scale-105 hover:from-blue-600 hover:to-purple-700 hover:shadow-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2" |
| 152 | + > |
| 153 | + 🚀 立即体验 QwertyLearner.ai |
| 154 | + </button> |
| 155 | + </div> |
| 156 | + </div> |
| 157 | + </Dialog.Panel> |
| 158 | + </Transition.Child> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + </Dialog> |
| 162 | + </Transition.Root> |
| 163 | + ) |
| 164 | +} |
| 165 | + |
| 166 | +export default EnhancedPromotionModal |
0 commit comments