feat(webui): refactor settings architecture and achieve full i18n coverage

This commit is contained in:
Wha1eChai
2026-01-09 00:39:25 +08:00
parent c9c5e7d486
commit a4814b8c34
10 changed files with 711 additions and 423 deletions

View File

@@ -0,0 +1,43 @@
/**
* Model Manager Component
* Handles model configuration (pinning, hiding, aliasing, mapping)
* Registers itself to window.Components for Alpine.js to consume
*/
window.Components = window.Components || {};
window.Components.modelManager = () => ({
init() {
// Component is ready
},
/**
* Update model configuration with authentication
* @param {string} modelId - The model ID to update
* @param {object} configUpdates - Configuration updates (pinned, hidden, alias, mapping)
*/
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 model config: ' + e.message, 'error');
}
}
});