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;
|
background-size: cover;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
max-width: 980px;
|
max-width: 1280px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
padding-left: 2rem;
|
padding-left: 2rem;
|
||||||
@ -370,14 +370,16 @@
|
|||||||
<table id="result-table" style="visibility:hidden">
|
<table id="result-table" style="visibility:hidden">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="width:35px">序号</th>
|
||||||
<th>API KEY</th>
|
<th>API KEY</th>
|
||||||
<th style="width: 50px">总额度</th>
|
<th style="width: 50px">总额度</th>
|
||||||
<th style="width: 50px">已使用</th>
|
<th style="width: 50px">已使用</th>
|
||||||
<th style="width: 50px">剩余量</th>
|
<th style="width: 50px">剩余量</th>
|
||||||
<th style="width: 120px">已用比例</th>
|
<th style="width: 100px">已用比例</th>
|
||||||
<th style="width: 60px">到期时间</th>
|
<th style="width: 90px">到期时间</th>
|
||||||
<th style="width: 50px">GPT-4</th>
|
<th style="width: 50px">GPT-4</th>
|
||||||
<th style="width: 50px">绑卡</th>
|
<th style="width: 50px">绑卡</th>
|
||||||
|
<th>组织ID</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
@ -391,6 +393,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
let queriedApiKeys = [];
|
let queriedApiKeys = [];
|
||||||
|
let serialNumber = 1;
|
||||||
|
|
||||||
async function checkBilling(apiKey, apiUrl) {
|
async function checkBilling(apiKey, apiUrl) {
|
||||||
// 计算起始日期和结束日期,当前为 90 天,最大不超过100天
|
// 计算起始日期和结束日期,当前为 90 天,最大不超过100天
|
||||||
@ -408,6 +411,7 @@
|
|||||||
const gpt4Check = `${apiUrl}/v1/models`;
|
const gpt4Check = `${apiUrl}/v1/models`;
|
||||||
const urlSubscription = `${apiUrl}/v1/dashboard/billing/subscription`;
|
const urlSubscription = `${apiUrl}/v1/dashboard/billing/subscription`;
|
||||||
let urlUsage = `${apiUrl}/v1/dashboard/billing/usage?start_date=${formatDate(startDate)}&end_date=${formatDate(endDate)}`;
|
let urlUsage = `${apiUrl}/v1/dashboard/billing/usage?start_date=${formatDate(startDate)}&end_date=${formatDate(endDate)}`;
|
||||||
|
const urlsetid = apiUrl + '/v1/organizations'; //查组织id
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 获取API限额
|
// 获取API限额
|
||||||
@ -445,10 +449,20 @@
|
|||||||
remaining = subscriptionData.system_hard_limit_usd - totalUsage;
|
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) {
|
} catch (error) {
|
||||||
console.error(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) => {
|
checkBilling(apiKey, apiUrl).then((data) => {
|
||||||
let row = document.createElement("tr");
|
let row = document.createElement("tr");
|
||||||
|
|
||||||
|
let serialNumberCell = document.createElement("td"); // 创建序列号单元格
|
||||||
|
serialNumberCell.textContent = serialNumber; // 设置序列号文本
|
||||||
|
row.appendChild(serialNumberCell); // 将序列号单元格添加到行中
|
||||||
|
|
||||||
let apiKeyCell = document.createElement("td");
|
let apiKeyCell = document.createElement("td");
|
||||||
apiKeyCell.textContent = apiKey.replace(/^(sk-[a-zA-Z0-9]{4})[a-zA-Z0-9]*(.{6})$/, "$1***$2");
|
apiKeyCell.textContent = apiKey.replace(/^(sk-[a-zA-Z0-9]{4})[a-zA-Z0-9]*(.{6})$/, "$1***$2");
|
||||||
row.appendChild(apiKeyCell);
|
row.appendChild(apiKeyCell);
|
||||||
|
|
||||||
if (data[0] === "Error") {
|
console.log(data); // 添加 console.log 以查看 data 的值
|
||||||
|
|
||||||
|
if (data?.[0] === "Error" || data === undefined) {
|
||||||
let errorMessageCell = document.createElement("td");
|
let errorMessageCell = document.createElement("td");
|
||||||
errorMessageCell.colSpan = "5";
|
errorMessageCell.colSpan = "8";
|
||||||
errorMessageCell.classList.add("status-error");
|
errorMessageCell.classList.add("status-error");
|
||||||
errorMessageCell.textContent = "不正确或已失效的API-KEY";
|
errorMessageCell.textContent = "不正确或已失效的API-KEY";
|
||||||
row.appendChild(errorMessageCell);
|
row.appendChild(errorMessageCell);
|
||||||
@ -569,6 +589,10 @@
|
|||||||
let isSubscribe = document.createElement("td");
|
let isSubscribe = document.createElement("td");
|
||||||
isSubscribe.textContent = data[5];
|
isSubscribe.textContent = data[5];
|
||||||
row.appendChild(isSubscribe);
|
row.appendChild(isSubscribe);
|
||||||
|
|
||||||
|
let setidCell = document.createElement("td");
|
||||||
|
setidCell.textContent = data[6]; // 使用data[6]来获取组织ID
|
||||||
|
row.appendChild(setidCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
tableBody.appendChild(row);
|
tableBody.appendChild(row);
|
||||||
@ -576,18 +600,23 @@
|
|||||||
if (i === apiKeys.length - 1) {
|
if (i === apiKeys.length - 1) {
|
||||||
queriedApiKeys = [];
|
queriedApiKeys = [];
|
||||||
}
|
}
|
||||||
|
serialNumber++; // 增加序列号
|
||||||
h2.style.display = 'block';
|
h2.style.display = 'block';
|
||||||
table.style.display = 'table';
|
table.style.display = 'table';
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
let row = document.createElement("tr");
|
let row = document.createElement("tr");
|
||||||
|
|
||||||
|
let serialNumberCell = document.createElement("td"); // 创建序列号单元格
|
||||||
|
serialNumberCell.textContent = serialNumber; // 设置序列号文本
|
||||||
|
row.appendChild(serialNumberCell); // 将序列号单元格添加到行中
|
||||||
let apiKeyCell = document.createElement("td");
|
let apiKeyCell = document.createElement("td");
|
||||||
apiKeyCell.textContent = apiKey;
|
apiKeyCell.textContent = apiKey;
|
||||||
row.appendChild(apiKeyCell);
|
row.appendChild(apiKeyCell);
|
||||||
|
|
||||||
let errorMessageCell = document.createElement("td");
|
let errorMessageCell = document.createElement("td");
|
||||||
errorMessageCell.colSpan = "6";
|
errorMessageCell.colSpan = "8";
|
||||||
errorMessageCell.style.width = "90px";
|
errorMessageCell.style.width = "90px";
|
||||||
errorMessageCell.classList.add("status-error");
|
errorMessageCell.classList.add("status-error");
|
||||||
errorMessageCell.textContent = "账户疑似被封禁,请登录 OpenAI 官网确认";
|
errorMessageCell.textContent = "账户疑似被封禁,请登录 OpenAI 官网确认";
|
||||||
@ -598,6 +627,7 @@
|
|||||||
if (i === apiKeys.length - 1) {
|
if (i === apiKeys.length - 1) {
|
||||||
queriedApiKeys = [];
|
queriedApiKeys = [];
|
||||||
}
|
}
|
||||||
|
serialNumber++; // 增加序列号
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user