perf(webui): refactor dashboard modules and optimize API performance

This commit is contained in:
Wha1eChai
2026-01-09 17:58:09 +08:00
parent e909ea6fe3
commit a914821d49
20 changed files with 1420 additions and 599 deletions

View File

@@ -7,9 +7,9 @@ window.Components = window.Components || {};
window.Components.models = () => ({
init() {
// Ensure data is fetched when this tab becomes active
this.$watch('$store.global.activeTab', (val) => {
if (val === 'models') {
// Ensure data is fetched when this tab becomes active (skip initial trigger)
this.$watch('$store.global.activeTab', (val, oldVal) => {
if (val === 'models' && oldVal !== undefined) {
// Trigger recompute to ensure filters are applied
this.$nextTick(() => {
Alpine.store('data').computeQuotaRows();
@@ -26,33 +26,11 @@ window.Components.models = () => ({
},
/**
* Update model configuration (Pin/Hide quick actions)
* Update model configuration (delegates to shared utility)
* @param {string} modelId - The model ID to update
* @param {object} configUpdates - Configuration updates (pinned, hidden)
*/
async updateModelConfig(modelId, configUpdates) {
const store = Alpine.store('global');
try {
const { response, newPassword } = await window.utils.request('/api/models/config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ modelId, config: configUpdates })
}, store.webuiPassword);
if (newPassword) store.webuiPassword = newPassword;
if (!response.ok) {
throw new Error('Failed to update model config');
}
// Optimistic update
Alpine.store('data').modelConfig[modelId] = {
...Alpine.store('data').modelConfig[modelId],
...configUpdates
};
Alpine.store('data').computeQuotaRows();
} catch (e) {
store.showToast('Failed to update: ' + e.message, 'error');
}
return window.ModelConfigUtils.updateModelConfig(modelId, configUpdates);
}
});