You've already forked bilibili-subtitle
跳转评论
This commit is contained in:
53
src/components/RateExtension.tsx
Normal file
53
src/components/RateExtension.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import React, { useState } from 'react';
|
||||
import { FaStar } from 'react-icons/fa';
|
||||
import { IoMdClose } from 'react-icons/io';
|
||||
import { setTempData } from '../redux/envReducer';
|
||||
import { useAppDispatch, useAppSelector } from '../hooks/redux';
|
||||
import { openUrl } from '@kky002/kky-util';
|
||||
|
||||
const RateExtension: React.FC = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const reviewed = useAppSelector(state => state.env.tempData.reviewed)
|
||||
|
||||
const handleRateClick = () => {
|
||||
dispatch(setTempData({
|
||||
reviewed: true
|
||||
}))
|
||||
// Chrome Web Store URL for your extension
|
||||
openUrl(import.meta.env.VITE_REVIEW_URL)
|
||||
};
|
||||
|
||||
if (reviewed === true || reviewed === undefined) return null;
|
||||
|
||||
return (
|
||||
<div className="relative bg-gradient-to-r from-primary to-secondary text-primary-content p-4 rounded-lg shadow-lg text-sm transition-all duration-300 ease-in-out hover:shadow-xl">
|
||||
<button
|
||||
onClick={() => {
|
||||
dispatch(setTempData({
|
||||
reviewed: true
|
||||
}))
|
||||
}}
|
||||
className="absolute top-2 right-2 text-primary-content opacity-70 hover:opacity-100 transition-opacity"
|
||||
>
|
||||
<IoMdClose size={20} />
|
||||
</button>
|
||||
<h3 className="text-lg font-bold mb-2 animate-pulse">喜欢这个扩展吗?</h3>
|
||||
<p className="mb-3">如果觉得有用,请给我们评分!</p>
|
||||
<button
|
||||
onClick={handleRateClick}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}
|
||||
className="btn btn-accent btn-sm gap-2 transition-all duration-300 ease-in-out hover:scale-105"
|
||||
>
|
||||
<FaStar className={`inline-block text-yellow-300 ${isHovered ? 'animate-spin' : ''}`} />
|
||||
去评分
|
||||
<span className="transition-transform duration-300 ease-in-out transform inline-block">
|
||||
{isHovered ? '🚀' : '→'}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default RateExtension;
|
Reference in New Issue
Block a user