feat: implement model pricing functionality with UI elements, storage management, and cost calculation
This commit is contained in:
19
app.js
19
app.js
@@ -504,6 +504,9 @@ class CLIProxyManager {
|
||||
const tokensHourBtn = document.getElementById('tokens-hour-btn');
|
||||
const tokensDayBtn = document.getElementById('tokens-day-btn');
|
||||
const chartLineSelects = document.querySelectorAll('.chart-line-select');
|
||||
const modelPriceForm = document.getElementById('model-price-form');
|
||||
const resetModelPricesBtn = document.getElementById('reset-model-prices');
|
||||
const modelPriceSelect = document.getElementById('model-price-model-select');
|
||||
|
||||
if (refreshUsageStats) {
|
||||
refreshUsageStats.addEventListener('click', () => this.loadUsageStats());
|
||||
@@ -528,6 +531,18 @@ class CLIProxyManager {
|
||||
});
|
||||
});
|
||||
}
|
||||
if (modelPriceForm) {
|
||||
modelPriceForm.addEventListener('submit', (event) => {
|
||||
event.preventDefault();
|
||||
this.handleModelPriceSubmit();
|
||||
});
|
||||
}
|
||||
if (resetModelPricesBtn) {
|
||||
resetModelPricesBtn.addEventListener('click', () => this.handleModelPriceReset());
|
||||
}
|
||||
if (modelPriceSelect) {
|
||||
modelPriceSelect.addEventListener('change', () => this.prefillModelPriceInputs());
|
||||
}
|
||||
|
||||
// 模态框
|
||||
const closeBtn = document.querySelector('.close');
|
||||
@@ -617,6 +632,7 @@ class CLIProxyManager {
|
||||
// 使用统计状态
|
||||
requestsChart = null;
|
||||
tokensChart = null;
|
||||
costChart = null;
|
||||
currentUsageData = null;
|
||||
chartLineSelections = ['none', 'none', 'none'];
|
||||
chartLineSelectIds = ['chart-line-select-0', 'chart-line-select-1', 'chart-line-select-2'];
|
||||
@@ -625,6 +641,9 @@ class CLIProxyManager {
|
||||
{ borderColor: '#a855f7', backgroundColor: 'rgba(168, 85, 247, 0.15)' },
|
||||
{ borderColor: '#10b981', backgroundColor: 'rgba(16, 185, 129, 0.15)' }
|
||||
];
|
||||
modelPriceStorageKey = 'cli-proxy-model-prices-v2';
|
||||
modelPrices = {};
|
||||
modelPriceInitialized = false;
|
||||
|
||||
showModal() {
|
||||
const modal = document.getElementById('modal');
|
||||
|
||||
Reference in New Issue
Block a user