mirror of
https://github.com/woodchen-ink/openai-billing-query.git
synced 2025-07-18 05:51:59 +08:00
Update index.html
添加序号、组织ID
This commit is contained in:
parent
70e6c5a907
commit
9b6e2ae560
46
index.html
46
index.html
@ -21,7 +21,7 @@
|
||||
/* 自定义背景图 */
|
||||
background-size: cover;
|
||||
width: 90%;
|
||||
max-width: 980px;
|
||||
max-width: 1280px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-left: 2rem;
|
||||
@ -370,14 +370,16 @@
|
||||
<table id="result-table" style="visibility:hidden">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:35px">序号</th>
|
||||
<th>API KEY</th>
|
||||
<th style="width: 50px">总额度</th>
|
||||
<th style="width: 50px">已使用</th>
|
||||
<th style="width: 50px">剩余量</th>
|
||||
<th style="width: 120px">已用比例</th>
|
||||
<th style="width: 60px">到期时间</th>
|
||||
<th style="width: 100px">已用比例</th>
|
||||
<th style="width: 90px">到期时间</th>
|
||||
<th style="width: 50px">GPT-4</th>
|
||||
<th style="width: 50px">绑卡</th>
|
||||
<th>组织ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@ -391,6 +393,7 @@
|
||||
|
||||
<script>
|
||||
let queriedApiKeys = [];
|
||||
let serialNumber = 1;
|
||||
|
||||
async function checkBilling(apiKey, apiUrl) {
|
||||
// 计算起始日期和结束日期,当前为 90 天,最大不超过100天
|
||||
@ -408,6 +411,7 @@
|
||||
const gpt4Check = `${apiUrl}/v1/models`;
|
||||
const urlSubscription = `${apiUrl}/v1/dashboard/billing/subscription`;
|
||||
let urlUsage = `${apiUrl}/v1/dashboard/billing/usage?start_date=${formatDate(startDate)}&end_date=${formatDate(endDate)}`;
|
||||
const urlsetid = apiUrl + '/v1/organizations'; //查组织id
|
||||
|
||||
try {
|
||||
// 获取API限额
|
||||
@ -445,10 +449,20 @@
|
||||
remaining = subscriptionData.system_hard_limit_usd - totalUsage;
|
||||
}
|
||||
|
||||
return [totalAmount, totalUsage, remaining, formattedDate, GPT4CheckResult, isSubscrible];
|
||||
//查询组织id
|
||||
response = await fetch(urlsetid, { headers });
|
||||
const setiddata = await response.json();
|
||||
let setid = '';
|
||||
if (typeof setiddata.data[1] !== 'undefined') {
|
||||
setid = setiddata.data[0].id + '----' + setiddata.data[1].id;
|
||||
} else {
|
||||
setid = setiddata.data[0].id;
|
||||
}
|
||||
|
||||
return [totalAmount, totalUsage, remaining, formattedDate, GPT4CheckResult, isSubscrible, setid];
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return ["Error", null, null, null, null, null];
|
||||
return ["Error", null, null, null, null, null, null];
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,13 +527,19 @@
|
||||
checkBilling(apiKey, apiUrl).then((data) => {
|
||||
let row = document.createElement("tr");
|
||||
|
||||
let serialNumberCell = document.createElement("td"); // 创建序列号单元格
|
||||
serialNumberCell.textContent = serialNumber; // 设置序列号文本
|
||||
row.appendChild(serialNumberCell); // 将序列号单元格添加到行中
|
||||
|
||||
let apiKeyCell = document.createElement("td");
|
||||
apiKeyCell.textContent = apiKey.replace(/^(sk-[a-zA-Z0-9]{4})[a-zA-Z0-9]*(.{6})$/, "$1***$2");
|
||||
row.appendChild(apiKeyCell);
|
||||
|
||||
if (data[0] === "Error") {
|
||||
console.log(data); // 添加 console.log 以查看 data 的值
|
||||
|
||||
if (data?.[0] === "Error" || data === undefined) {
|
||||
let errorMessageCell = document.createElement("td");
|
||||
errorMessageCell.colSpan = "5";
|
||||
errorMessageCell.colSpan = "8";
|
||||
errorMessageCell.classList.add("status-error");
|
||||
errorMessageCell.textContent = "不正确或已失效的API-KEY";
|
||||
row.appendChild(errorMessageCell);
|
||||
@ -569,6 +589,10 @@
|
||||
let isSubscribe = document.createElement("td");
|
||||
isSubscribe.textContent = data[5];
|
||||
row.appendChild(isSubscribe);
|
||||
|
||||
let setidCell = document.createElement("td");
|
||||
setidCell.textContent = data[6]; // 使用data[6]来获取组织ID
|
||||
row.appendChild(setidCell);
|
||||
}
|
||||
|
||||
tableBody.appendChild(row);
|
||||
@ -576,18 +600,23 @@
|
||||
if (i === apiKeys.length - 1) {
|
||||
queriedApiKeys = [];
|
||||
}
|
||||
serialNumber++; // 增加序列号
|
||||
h2.style.display = 'block';
|
||||
table.style.display = 'table';
|
||||
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
let row = document.createElement("tr");
|
||||
|
||||
let serialNumberCell = document.createElement("td"); // 创建序列号单元格
|
||||
serialNumberCell.textContent = serialNumber; // 设置序列号文本
|
||||
row.appendChild(serialNumberCell); // 将序列号单元格添加到行中
|
||||
let apiKeyCell = document.createElement("td");
|
||||
apiKeyCell.textContent = apiKey;
|
||||
row.appendChild(apiKeyCell);
|
||||
|
||||
let errorMessageCell = document.createElement("td");
|
||||
errorMessageCell.colSpan = "6";
|
||||
errorMessageCell.colSpan = "8";
|
||||
errorMessageCell.style.width = "90px";
|
||||
errorMessageCell.classList.add("status-error");
|
||||
errorMessageCell.textContent = "账户疑似被封禁,请登录 OpenAI 官网确认";
|
||||
@ -598,6 +627,7 @@
|
||||
if (i === apiKeys.length - 1) {
|
||||
queriedApiKeys = [];
|
||||
}
|
||||
serialNumber++; // 增加序列号
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user