Commit 3c5c57b9 authored by fisherdaddy's avatar fisherdaddy

feature: add gemini 2.0 flash price

parent b3f1dde1
// PricingChart.jsx
import React, { useState } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { useScrollToTop } from '../hooks/useScrollToTop';
import '../styles/PricingChart.css';
......@@ -105,6 +105,54 @@ const PricingChart = ({ data }) => {
input: true,
output: true,
});
const chartAreaRef = useRef(null);
const [hasScroll, setHasScroll] = useState(false);
const [showScrollHint, setShowScrollHint] = useState(false);
useEffect(() => {
const checkScroll = () => {
if (chartAreaRef.current) {
const { scrollWidth, clientWidth, scrollLeft } = chartAreaRef.current;
setHasScroll(scrollWidth > clientWidth);
// 只在滚动到最左侧时显示提示
setShowScrollHint(scrollWidth > clientWidth && scrollLeft === 0);
}
};
const handleScroll = () => {
if (chartAreaRef.current) {
const { scrollLeft } = chartAreaRef.current;
// 当用户开始滚动时隐藏提示
if (scrollLeft > 0) {
setShowScrollHint(false);
}
}
};
checkScroll();
window.addEventListener('resize', checkScroll);
if (chartAreaRef.current) {
chartAreaRef.current.addEventListener('scroll', handleScroll);
}
return () => {
window.removeEventListener('resize', checkScroll);
if (chartAreaRef.current) {
chartAreaRef.current.removeEventListener('scroll', handleScroll);
}
};
}, [data]);
const handleScrollHintClick = () => {
if (chartAreaRef.current) {
const { scrollWidth, clientWidth } = chartAreaRef.current;
chartAreaRef.current.scrollTo({
left: scrollWidth - clientWidth,
behavior: 'smooth'
});
setShowScrollHint(false);
}
};
const handleLegendClick = (barType) => {
setHighlightedBarTypes((prevState) => ({
......@@ -130,7 +178,7 @@ const PricingChart = ({ data }) => {
<ChartLegend onLegendClick={handleLegendClick} highlightedBarTypes={highlightedBarTypes} />
<div className="chart-area">
<div className={`chart-area ${hasScroll ? 'has-scroll' : ''}`} ref={chartAreaRef}>
<YAxis maxPrice={maxPrice} />
<div className="chart-container">
<GridLines />
......@@ -143,6 +191,19 @@ const PricingChart = ({ data }) => {
/>
))}
</div>
{showScrollHint && (
<div
className="scroll-hint-container"
onClick={handleScrollHintClick}
style={{ cursor: 'pointer' }}
>
<div className="scroll-hint">
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M9.29 15.88L13.17 12 9.29 8.12c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0-.38-.39-.39-1.03 0-1.42z"/>
</svg>
</div>
</div>
)}
</div>
</div>
);
......
......@@ -11,7 +11,7 @@ import LoadingOverlay from './LoadingOverlay';
const PricingCharts = () => {
useScrollToTop();
const isLoading = usePageLoading();
const lastUpdateTime = '2025-01-09 10:00';
const lastUpdateTime = '2025-02-06 18:00';
return (
<>
......
......@@ -20,6 +20,12 @@
"inputPrice": 1,
"outputPrice": 1
},
{
"name": "gemini 2.0 Flash-Lite",
"logo": "/assets/icon/google_small.svg",
"inputPrice": 0.53,
"outputPrice": 2.1
},
{
"name": "gemini 1.5 Flash",
"logo": "/assets/icon/google_small.svg",
......@@ -50,6 +56,12 @@
"inputPrice": 0.8,
"outputPrice": 2
},
{
"name": "google 2.0 Falsh",
"logo": "/assets/icon/google_small.svg",
"inputPrice": 0.7,
"outputPrice": 2.8
},
{
"name": "gpt-4o-mini",
"logo": "/assets/icon/openai_small.svg",
......
......@@ -8,6 +8,18 @@
"inputPrice": 0.15,
"outputPrice": 0.6
},
{
"name": "o3-mini",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 1.1,
"outputPrice": 4.4
},
{
"name": "o1-mini",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 1.1,
"outputPrice": 4.4
},
{
"name": "gpt-4o",
"logo": "/assets/icon/openai_small.svg",
......@@ -21,22 +33,22 @@
"outputPrice": 15
},
{
"name": "gpt-4-turbo",
"name": "gpt-4o-mini-audio-preview",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 10,
"outputPrice": 30
"outputPrice": 20
},
{
"name": "o3-mini",
"name": "gpt-4o-mini-realtime-preview",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 1.1,
"outputPrice": 4.4
"inputPrice": 10,
"outputPrice": 20
},
{
"name": "o1-mini",
"name": "gpt-4-turbo",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 1.1,
"outputPrice": 4.4
"inputPrice": 10,
"outputPrice": 30
},
{
"name": "o1",
......@@ -44,24 +56,12 @@
"inputPrice": 15,
"outputPrice": 60
},
{
"name": "gpt-4o-mini-audio-preview",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 10,
"outputPrice": 20
},
{
"name": "gpt-4o-audio-preview",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 100,
"outputPrice": 200
},
{
"name": "gpt-4o-mini-realtime-preview",
"logo": "/assets/icon/openai_small.svg",
"inputPrice": 10,
"outputPrice": 20
},
{
"name": "gpt-4o-realtime-preview",
"logo": "/assets/icon/openai_small.svg",
......
......@@ -14,12 +14,24 @@
"inputPrice": 1.5,
"outputPrice": 4.5
},
{
"name": "gemini 2.0 Flash-Lite",
"logo": "/assets/icon/google_small.svg",
"inputPrice": 0.53,
"outputPrice": 2.1
},
{
"name": "gemini 1.5 Flash",
"logo": "/assets/icon/google_small.svg",
"inputPrice": 0.53,
"outputPrice": 2.1
},
{
"name": "gemini 2.0 Falsh",
"logo": "/assets/icon/google_small.svg",
"inputPrice": 0.7,
"outputPrice": 2.8
},
{
"name": "Doubao-1.5-vision-pro-32k",
"logo": "/assets/icon/doubao.png",
......
......@@ -59,6 +59,11 @@
.chart-area {
display: flex;
width: 100%;
overflow-x: auto;
padding-bottom: 10px;
position: relative;
scroll-behavior: smooth;
}
.y-axis {
......@@ -77,12 +82,12 @@
.chart-container {
display: flex;
align-items: flex-end;
gap: 0.5rem; /* 减小柱状图之间的间距 */
height: 300px;
gap: 1rem;
height: 380px;
position: relative;
padding-bottom: 80px;
width: 100%; /* 确保容器占满可用宽度 */
overflow: visible; /* 移除水平滚动 */
padding-bottom: 160px;
min-width: min-content;
flex-grow: 1;
}
.grid-lines {
......@@ -103,26 +108,25 @@
.chart-column {
position: relative;
flex: 1; /* 使柱状图列可伸缩 */
/* max-width: 60px; */ /* 移除这行 */
min-width: 60px;
max-width: 80px;
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
}
/* 让.bar根据可用空间调整宽度 */
.bars-container {
display: flex;
gap: 2px;
align-items: flex-end;
height: 100%;
justify-content: center;
flex-grow: 1; /* 新增 */
flex-grow: 1;
}
.bar {
width: 15px; /* 减小柱状图的宽度 */
width: 15px;
position: relative;
border-radius: 4px 4px 0 0;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
......@@ -144,7 +148,7 @@
top: -20px;
left: 50%;
transform: translateX(-50%);
font-size: 0.65rem; /* 减小价格标签的字体大小 */
font-size: 0.65rem;
white-space: nowrap;
}
......@@ -159,7 +163,7 @@
}
.provider-logo {
width: 20px; /* 缩小Logo尺寸 */
width: 20px;
height: 20px;
object-fit: contain;
filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
......@@ -171,19 +175,17 @@
}
.provider-name {
font-size: 13px;
font-size: 12px;
transform: translate(-18px, 36px) rotate(-77deg);
transform-origin: top center;
/* white-space: nowrap; */
/* margin-top: 35px; */
line-height: 16px;
padding-top: -11px;
width: 100px;
line-height: 14px;
width: 90px;
text-align: right;
height: 40px;
word-break: break-all;
white-space: break-spaces;
padding-right: 18px;
color: var(--text-secondary);
}
.pricing-charts-container {
......@@ -201,3 +203,80 @@
margin-bottom: 2rem;
display: inline-block;
}
.chart-area::after {
content: '';
position: sticky;
top: 0;
right: 0;
height: calc(100% - 10px);
width: 60px;
background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.2));
pointer-events: none;
opacity: 0;
transition: opacity 0.3s ease;
z-index: 5;
}
.chart-area.has-scroll::after {
opacity: 1;
}
@keyframes scrollHint {
0% {
transform: translateX(0);
}
50% {
transform: translateX(10px);
}
100% {
transform: translateX(0);
}
}
.scroll-hint-container {
position: absolute;
right: 20px;
top: 50%;
transform: translateY(-50%);
z-index: 6;
pointer-events: auto;
cursor: pointer;
}
.scroll-hint {
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.15);
animation: scrollHint 1.5s infinite;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease, background-color 0.3s ease;
}
.scroll-hint:hover {
background: rgba(255, 255, 255, 0.25);
transform: scale(1.1);
}
.chart-area::-webkit-scrollbar {
height: 8px;
z-index: 10;
}
.chart-area::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
border-radius: 4px;
}
.chart-area::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 4px;
border: 2px solid rgba(255, 255, 255, 0.05);
}
.chart-area::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.4);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment