@@ -34,7 +34,6 @@ async function submit(key) {
34
34
'Authorization' : `Bearer ${ key } `
35
35
}
36
36
// 查是否订阅
37
- // const subscription = await fetch("https://openai.1rmb.tk/v1/dashboard/billing/subscription", {
38
37
const subscription = await fetch ( "/api/v1/dashboard/billing/subscription" , {
39
38
method : 'get' ,
40
39
headers : headers
@@ -48,18 +47,39 @@ async function submit(key) {
48
47
const subscriptionData = await subscription . json ( )
49
48
// console.log(subscriptionData);
50
49
// console.log(subscriptionData.plan.id);
50
+ const billingendDate = Math . floor ( Date . now ( ) / 1000 + 24 * 60 * 60 ) ;
51
+ const billingstartDate = new Date ( billingendDate - 90 * 24 * 60 * 60 ) ;
52
+
53
+ // 赠送额度有效期
51
54
const endDate = subscriptionData . access_until
52
55
const startDate = new Date ( endDate - 90 * 24 * 60 * 60 ) ;
53
56
console . log ( formatDate ( endDate , "YYYY-MM-DD" ) ) ;
54
57
console . log ( formatDate ( startDate , "YYYY-MM-DD" ) ) ;
55
- // const response = await fetch(`https://openai.1rmb.tk/v1/dashboard/billing/usage?start_date=${formatDate(startDate, "YYYY-MM-DD")}&end_date=${formatDate(endDate, "YYYY-MM-DD")}`, {
56
- const response = await fetch ( `/api/v1/dashboard/billing/usage?start_date=${ formatDate ( startDate , "YYYY-MM-DD" ) } &end_date=${ formatDate ( endDate , "YYYY-MM-DD" ) } ` , {
58
+ // const response = await fetch(`/api/v1/dashboard/billing/usage?start_date=${formatDate(startDate, "YYYY-MM-DD")}&end_date=${formatDate(endDate, "YYYY-MM-DD")}`, {
59
+
60
+ // 查询90天内的使用情况
61
+ const response = await fetch ( `/api/v1/dashboard/billing/usage?start_date=${ formatDate ( billingstartDate , "YYYY-MM-DD" ) } &end_date=${ formatDate ( billingendDate , "YYYY-MM-DD" ) } ` , {
57
62
method : 'get' ,
58
63
headers : headers
59
64
} )
60
65
61
66
const usageData = await response . json ( ) ;
62
67
console . log ( usageData ) ;
68
+
69
+ // 获取apiKey支持的最高GPT模型
70
+ const modelResponse = await fetch ( `/api/v1/models` , {
71
+ method : 'get' ,
72
+ headers : headers
73
+ } ) ;
74
+ const modelData = await modelResponse . json ( ) ;
75
+ const gptModels = modelData . data . filter ( model => model . id . includes ( "gpt" ) ) ;
76
+ const highestGPTModel = gptModels . reduce ( ( prev , current ) => {
77
+ const prevVersion = parseFloat ( prev . id . split ( "-" ) [ 1 ] ) ;
78
+ const currentVersion = parseFloat ( current . id . split ( "-" ) [ 1 ] ) ;
79
+ return ( currentVersion > prevVersion ) ? current : prev ;
80
+ } ) ;
81
+ // console.log(highestGPTModel);
82
+ const GPTModel = highestGPTModel . id
63
83
// 账号类型
64
84
// const plan = subscriptionData.plan.title
65
85
const plan = ( subscriptionData . plan . title === "Pay-as-you-go" ) ? "Pay-as-you-go" : subscriptionData . plan . id ;
@@ -71,7 +91,7 @@ async function submit(key) {
71
91
// 剩余额度
72
92
const total_available = total_granted - total_used ;
73
93
74
- return { plan, total_granted, total_used, total_available, endDate, startDate }
94
+ return { plan, total_granted, total_used, total_available, endDate, startDate, GPTModel }
75
95
76
96
}
77
97
@@ -90,10 +110,6 @@ export default function Home() {
90
110
const [ isLoading , setIsLoading ] = useState ( true ) ;
91
111
const [ proxylink , setproxyLink ] = useState ( "" ) ;
92
112
93
- // const router = useRouter();
94
-
95
-
96
-
97
113
useEffect ( ( ) => {
98
114
const { origin } = location ;
99
115
setproxyLink ( `${ origin } /api` ) ;
@@ -211,8 +227,11 @@ export default function Home() {
211
227
< p > 额度总量:{ balance . total_granted } </ p >
212
228
< p > 已用额度:{ balance . total_used } </ p >
213
229
< p > 剩余额度:{ balance . total_available } </ p >
230
+ < p > 最高模型:{ balance . GPTModel } </ p >
231
+ < p > 有效期为赠送额度的有效期</ p >
214
232
< p > 有效期起:{ formatDate ( balance . startDate ) } </ p >
215
233
< p > 有效期止:{ formatDate ( balance . endDate ) } </ p >
234
+
216
235
</ div >
217
236
) }
218
237
0 commit comments