1
1
import "@/assets/pages/article.less" ;
2
2
import { Button } from "@/components/ui/button.tsx" ;
3
3
import router from "@/router.tsx" ;
4
- import { Check , ChevronLeft , Files , Globe , Loader2 } from "lucide-react" ;
4
+ import { Check , ChevronLeft , Cloud , Files , Globe , Loader2 } from "lucide-react" ;
5
5
import { Textarea } from "@/components/ui/textarea.tsx" ;
6
6
import { useTranslation } from "react-i18next" ;
7
7
import { useDispatch , useSelector } from "react-redux" ;
@@ -31,7 +31,7 @@ type ProgressProps = {
31
31
total : number ;
32
32
} ;
33
33
34
- function GenerateProgress ( { current, total } : ProgressProps ) {
34
+ function GenerateProgress ( { current, total, quota } : ProgressProps & { quota : number } ) {
35
35
const { t } = useTranslation ( ) ;
36
36
37
37
return (
@@ -56,6 +56,12 @@ function GenerateProgress({ current, total }: ProgressProps) {
56
56
) }
57
57
</ p >
58
58
< Progress value = { ( 100 * current ) / total } />
59
+ < div
60
+ className = { `article-quota flex flex-row mt-4 border border-input rounded-md py-1 px-3 select-none w-max items-center mx-auto` }
61
+ >
62
+ < Cloud className = { `h-4 w-4 mr-2` } />
63
+ < p > { quota . toFixed ( 2 ) } </ p >
64
+ </ div >
59
65
</ div >
60
66
) ;
61
67
}
@@ -72,13 +78,15 @@ function ArticleContent() {
72
78
const [ progress , setProgress ] = useState ( false ) ;
73
79
74
80
const [ state , setState ] = useState < ProgressProps > ( { current : 0 , total : 0 } ) ;
81
+ const [ quota , setQuota ] = useState < number > ( 0 ) ;
75
82
const [ hash , setHash ] = useState ( "" ) ;
76
83
77
84
function clear ( ) {
78
85
setPrompt ( "" ) ;
79
86
setTitle ( "" ) ;
80
87
setHash ( "" ) ;
81
88
setProgress ( false ) ;
89
+ setQuota ( 0 ) ;
82
90
setState ( { current : 0 , total : 0 } ) ;
83
91
}
84
92
@@ -100,6 +108,8 @@ function ArticleContent() {
100
108
101
109
connection . onmessage = ( e ) => {
102
110
const data = JSON . parse ( e . data ) ;
111
+
112
+ data . data && data . data . quota && setQuota ( quota + data . data . quota ) ;
103
113
if ( ! data . hash ) setState ( data . data as ProgressProps ) ;
104
114
else {
105
115
toast ( {
@@ -123,7 +133,7 @@ function ArticleContent() {
123
133
124
134
return progress ? (
125
135
< >
126
- < GenerateProgress { ...state } />
136
+ < GenerateProgress { ...state } quota = { quota } />
127
137
{ hash && (
128
138
< div className = { `article-action flex flex-row items-center my-4 gap-4` } >
129
139
< Button
0 commit comments