Refactor TelegramManager and improve frontend article display

- Simplified inline keyboard button creation in TelegramManager for better readability.
- Adjusted the structure of the keyboard arrays to ensure proper formatting.
- Enhanced Articles.vue by cleaning up the layout and ensuring consistent spacing and alignment.
- Improved the handling of article display properties for better user experience.
This commit is contained in:
Omar Sánchez Pizarro
2026-01-19 21:10:44 +01:00
parent c3ef3daf5e
commit 96db30ff00
3 changed files with 72 additions and 59 deletions

View File

@@ -524,10 +524,12 @@ function closeGeneralModal() {
async function saveWorker() { async function saveWorker() {
try { try {
const updatedWorkers = { ...workers.value }; const updatedWorkers = {
if (!updatedWorkers.items) { ...workers.value,
updatedWorkers.items = []; items: [...(workers.value.items || [])],
} disabled: [...(workers.value.disabled || [])],
general: workers.value.general || {}
};
const workerData = { const workerData = {
name: workerForm.value.name, name: workerForm.value.name,
@@ -567,10 +569,14 @@ async function saveWorker() {
async function saveGeneralConfig() { async function saveGeneralConfig() {
try { try {
const updatedWorkers = { ...workers.value }; const updatedWorkers = {
updatedWorkers.general = { ...workers.value,
items: workers.value.items || [],
disabled: workers.value.disabled || [],
general: {
...(textToArray(generalForm.value.title_exclude_text).length > 0 && { title_exclude: textToArray(generalForm.value.title_exclude_text) }), ...(textToArray(generalForm.value.title_exclude_text).length > 0 && { title_exclude: textToArray(generalForm.value.title_exclude_text) }),
...(textToArray(generalForm.value.description_exclude_text).length > 0 && { description_exclude: textToArray(generalForm.value.description_exclude_text) }), ...(textToArray(generalForm.value.description_exclude_text).length > 0 && { description_exclude: textToArray(generalForm.value.description_exclude_text) }),
}
}; };
await api.updateWorkers(updatedWorkers); await api.updateWorkers(updatedWorkers);
@@ -588,14 +594,17 @@ async function disableWorker(name) {
} }
try { try {
const updatedWorkers = { ...workers.value }; const updatedWorkers = {
if (!updatedWorkers.disabled) { ...workers.value,
updatedWorkers.disabled = []; items: workers.value.items || [],
} disabled: [...(workers.value.disabled || [])]
};
if (!updatedWorkers.disabled.includes(name)) { if (!updatedWorkers.disabled.includes(name)) {
updatedWorkers.disabled.push(name); updatedWorkers.disabled.push(name);
} }
await api.updateWshowGeneralModalorkers(updatedWorkers);
await api.updateWorkers(updatedWorkers);
await loadWorkers(); await loadWorkers();
} catch (error) { } catch (error) {
console.error('Error desactivando worker:', error); console.error('Error desactivando worker:', error);
@@ -605,10 +614,12 @@ async function disableWorker(name) {
async function enableWorker(name) { async function enableWorker(name) {
try { try {
const updatedWorkers = { ...workers.value }; const updatedWorkers = {
if (updatedWorkers.disabled) { ...workers.value,
updatedWorkers.disabled = updatedWorkers.disabled.filter(n => n !== name); items: workers.value.items || [],
} disabled: [...(workers.value.disabled || [])].filter(n => n !== name)
};
await api.updateWorkers(updatedWorkers); await api.updateWorkers(updatedWorkers);
await loadWorkers(); await loadWorkers();
} catch (error) { } catch (error) {
@@ -623,11 +634,13 @@ async function deleteWorker(name) {
} }
try { try {
const updatedWorkers = { ...workers.value }; const updatedWorkers = {
updatedWorkers.items = updatedWorkers.items.filter(w => w.name !== name); ...workers.value,
if (updatedWorkers.disabled) { items: (workers.value.items || []).filter(w => w.name !== name),
updatedWorkers.disabled = updatedWorkers.disabled.filter(n => n !== name); disabled: (workers.value.disabled || []).filter(n => n !== name),
} general: workers.value.general || {}
};
await api.updateWorkers(updatedWorkers); await api.updateWorkers(updatedWorkers);
await loadWorkers(); await loadWorkers();
} catch (error) { } catch (error) {