Mejoras en el Launcher C# y gestión de proyectos
- Se añadió la funcionalidad de limpieza del estado previo en el gestor de lanzadores C#. - Se implementó un método para reiniciar completamente el launcher, asegurando una inicialización adecuada. - Se mejoró la gestión de argumentos para ejecutables, permitiendo la selección y ejecución con argumentos predefinidos. - Se optimizó la lógica de inicialización y se añadieron mensajes de depuración para facilitar el seguimiento de errores. - Se realizaron ajustes en la interfaz para mejorar la experiencia del usuario al gestionar proyectos y ejecutables.
This commit is contained in:
parent
5be80138c5
commit
e3eb2fb9e5
16
data/log.txt
16
data/log.txt
|
@ -32,3 +32,19 @@
|
||||||
[01:54:56] ✅ Proceso completado exitosamente (PID: 44892)
|
[01:54:56] ✅ Proceso completado exitosamente (PID: 44892)
|
||||||
[01:54:56] ⏱️ Tiempo de ejecución: 3.87 segundos
|
[01:54:56] ⏱️ Tiempo de ejecución: 3.87 segundos
|
||||||
[01:54:56] ==================================================
|
[01:54:56] ==================================================
|
||||||
|
[02:43:57] 🚀 Ejecutando: GTPCorrgir
|
||||||
|
[02:43:57] 📁 Directorio: D:/Proyectos/VisualStudio/GTPCorrgir\bin\Release\net8.0-windows
|
||||||
|
[02:43:57] ⚡ Comando: D:/Proyectos/VisualStudio/GTPCorrgir\bin\Release\net8.0-windows\GTPCorrgir.exe --Menu
|
||||||
|
[02:43:57] ==================================================
|
||||||
|
[02:43:57] ✅ Proceso iniciado con PID: 42668
|
||||||
|
[02:43:59] ✅ Proceso completado exitosamente (PID: 42668)
|
||||||
|
[02:43:59] ⏱️ Tiempo de ejecución: 2.71 segundos
|
||||||
|
[02:43:59] ==================================================
|
||||||
|
[02:44:06] 🚀 Ejecutando: GTPCorrgir
|
||||||
|
[02:44:06] 📁 Directorio: D:/Proyectos/VisualStudio/GTPCorrgir\bin\Release\net8.0-windows
|
||||||
|
[02:44:06] ⚡ Comando: D:/Proyectos/VisualStudio/GTPCorrgir\bin\Release\net8.0-windows\GTPCorrgir.exe --Menu
|
||||||
|
[02:44:06] ==================================================
|
||||||
|
[02:44:06] ✅ Proceso iniciado con PID: 34300
|
||||||
|
[02:44:08] ❌ Proceso terminó con código: 1 (PID: 34300)
|
||||||
|
[02:44:08] ⏱️ Tiempo de ejecución: 2.09 segundos
|
||||||
|
[02:44:08] ==================================================
|
||||||
|
|
|
@ -12,10 +12,16 @@ class CSharpLauncherManager {
|
||||||
'Desarrollo', 'APIs', 'Otros'
|
'Desarrollo', 'APIs', 'Otros'
|
||||||
];
|
];
|
||||||
this.currentCategory = 'all';
|
this.currentCategory = 'all';
|
||||||
|
this.initialized = false;
|
||||||
|
this.processInterval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
console.log('Initializing C# Launcher Manager...');
|
console.log('Initializing C# Launcher Manager...');
|
||||||
|
|
||||||
|
// Limpiar estado previo si existe
|
||||||
|
this.clearState();
|
||||||
|
|
||||||
await this.loadProjects();
|
await this.loadProjects();
|
||||||
await this.loadFavorites();
|
await this.loadFavorites();
|
||||||
this.setupEventListeners();
|
this.setupEventListeners();
|
||||||
|
@ -23,7 +29,35 @@ class CSharpLauncherManager {
|
||||||
await this.refreshProcesses();
|
await this.refreshProcesses();
|
||||||
|
|
||||||
// Actualizar procesos cada 10 segundos
|
// Actualizar procesos cada 10 segundos
|
||||||
setInterval(() => this.refreshProcesses(), 10000);
|
if (!this.processInterval) {
|
||||||
|
this.processInterval = setInterval(() => this.refreshProcesses(), 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initialized = true;
|
||||||
|
console.log('C# Launcher Manager initialized successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
clearState() {
|
||||||
|
console.log('Clearing C# launcher state...');
|
||||||
|
this.currentProject = null;
|
||||||
|
this.projects = [];
|
||||||
|
this.executables = [];
|
||||||
|
this.favorites = new Set();
|
||||||
|
this.runningProcesses = [];
|
||||||
|
|
||||||
|
// Limpiar intervalos previos
|
||||||
|
if (this.processInterval) {
|
||||||
|
clearInterval(this.processInterval);
|
||||||
|
this.processInterval = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Método de utilidad para resetear completamente el launcher
|
||||||
|
async reset() {
|
||||||
|
console.log('Resetting C# Launcher...');
|
||||||
|
localStorage.removeItem('csharp_last_selected_project');
|
||||||
|
this.clearState();
|
||||||
|
await this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadProjects() {
|
async loadProjects() {
|
||||||
|
@ -71,7 +105,10 @@ class CSharpLauncherManager {
|
||||||
|
|
||||||
renderProjectSelector() {
|
renderProjectSelector() {
|
||||||
const select = document.getElementById('csharp-project-select');
|
const select = document.getElementById('csharp-project-select');
|
||||||
if (!select) return;
|
if (!select) {
|
||||||
|
console.warn('C# project select element not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
select.innerHTML = '<option value="">-- Seleccionar Proyecto --</option>';
|
select.innerHTML = '<option value="">-- Seleccionar Proyecto --</option>';
|
||||||
|
|
||||||
|
@ -83,24 +120,78 @@ class CSharpLauncherManager {
|
||||||
option.setAttribute('data-category', project.category || 'Otros');
|
option.setAttribute('data-category', project.category || 'Otros');
|
||||||
select.appendChild(option);
|
select.appendChild(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Restaurar última selección con delay para asegurar que el DOM esté listo
|
||||||
|
setTimeout(() => this.restoreLastSelectedProject(), 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreLastSelectedProject() {
|
||||||
|
try {
|
||||||
|
const lastSelectedProject = localStorage.getItem('csharp_last_selected_project');
|
||||||
|
console.log('Restoring last selected project:', lastSelectedProject);
|
||||||
|
|
||||||
|
if (!lastSelectedProject) {
|
||||||
|
console.log('No last selected project found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const project = this.projects.find(p => p.id === lastSelectedProject);
|
||||||
|
if (!project) {
|
||||||
|
console.log('Last selected project not found in current projects list, clearing localStorage');
|
||||||
|
localStorage.removeItem('csharp_last_selected_project');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const select = document.getElementById('csharp-project-select');
|
||||||
|
if (!select) {
|
||||||
|
console.warn('Project select element not found during restore');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Restoring project:', project.name);
|
||||||
|
select.value = lastSelectedProject;
|
||||||
|
|
||||||
|
// Disparar evento change para cargar el proyecto
|
||||||
|
const changeEvent = new Event('change', { bubbles: true });
|
||||||
|
select.dispatchEvent(changeEvent);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error restoring last selected project:', error);
|
||||||
|
// Limpiar localStorage corrupto
|
||||||
|
localStorage.removeItem('csharp_last_selected_project');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onProjectChange(e) {
|
async onProjectChange(e) {
|
||||||
const projectId = e.target.value;
|
const projectId = e.target.value;
|
||||||
|
console.log('Project change event:', projectId);
|
||||||
|
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
|
console.log('No project selected, clearing state');
|
||||||
this.currentProject = null;
|
this.currentProject = null;
|
||||||
this.hideCSharpProjectButtons();
|
this.hideCSharpProjectButtons();
|
||||||
this.clearExecutables();
|
this.clearExecutables();
|
||||||
|
// Limpiar persistencia
|
||||||
|
localStorage.removeItem('csharp_last_selected_project');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.currentProject = this.projects.find(p => p.id === projectId);
|
this.currentProject = this.projects.find(p => p.id === projectId);
|
||||||
|
if (!this.currentProject) {
|
||||||
|
console.error('Project not found:', projectId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Loading project:', this.currentProject.name);
|
||||||
this.showCSharpProjectButtons();
|
this.showCSharpProjectButtons();
|
||||||
await this.loadProjectExecutables(projectId);
|
await this.loadProjectExecutables(projectId);
|
||||||
|
|
||||||
|
// Guardar selección para persistencia
|
||||||
|
localStorage.setItem('csharp_last_selected_project', projectId);
|
||||||
|
console.log('Project loaded successfully');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error changing project:', error);
|
console.error('Error changing project:', error);
|
||||||
|
this.showNotification('Error cargando el proyecto', 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +253,11 @@ class CSharpLauncherManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.innerHTML = filteredExecutables.map(exe => this.createExecutableCard(exe)).join('');
|
grid.innerHTML = filteredExecutables.map(exe => this.createExecutableCard(exe)).join('');
|
||||||
|
|
||||||
|
// Cargar argumentos para cada ejecutable después de renderizar
|
||||||
|
filteredExecutables.forEach(exe => {
|
||||||
|
this.loadExecutableArgumentsForCard(this.currentProject.id, exe.filename);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createExecutableCard(exe) {
|
createExecutableCard(exe) {
|
||||||
|
@ -171,6 +267,8 @@ class CSharpLauncherManager {
|
||||||
'<span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">Release</span>' :
|
'<span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">Release</span>' :
|
||||||
'<span class="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">Debug</span>';
|
'<span class="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">Debug</span>';
|
||||||
|
|
||||||
|
// Los argumentos se cargan después de renderizar
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="executable-card bg-white border rounded-lg p-4 hover:shadow-md transition-shadow">
|
<div class="executable-card bg-white border rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||||
<div class="flex justify-between items-start mb-2">
|
<div class="flex justify-between items-start mb-2">
|
||||||
|
@ -183,15 +281,25 @@ class CSharpLauncherManager {
|
||||||
${buildTypeBadge}
|
${buildTypeBadge}
|
||||||
<span class="text-xs text-gray-500">${exe.filename}</span>
|
<span class="text-xs text-gray-500">${exe.filename}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Combo de argumentos -->
|
||||||
|
<div class="mb-3">
|
||||||
|
<select id="args-combo-${exe.filename.replace('.exe', '').replace(/[^a-zA-Z0-9]/g, '_')}"
|
||||||
|
class="w-full text-xs border border-gray-300 rounded px-2 py-1 bg-white">
|
||||||
|
<option value="">Sin argumentos</option>
|
||||||
|
<!-- Las opciones se cargan dinámicamente -->
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div class="space-x-1">
|
<div class="space-x-1">
|
||||||
<button class="text-blue-500 hover:underline text-xs"
|
<button class="text-blue-500 hover:underline text-xs"
|
||||||
onclick="showCSharpExecutableArgs('${this.currentProject.id}', '${exe.filename}', '${exe.display_name}')">
|
onclick="showCSharpExecutableArgs('${this.currentProject.id}', '${exe.filename}', '${exe.display_name}')">
|
||||||
Con Argumentos
|
Personalizar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="bg-blue-500 text-white px-3 py-1 rounded text-xs hover:bg-blue-600"
|
<button class="bg-blue-500 text-white px-3 py-1 rounded text-xs hover:bg-blue-600"
|
||||||
onclick="csharpLauncherManager.executeExecutable('${this.currentProject.id}', '${exe.filename}')">
|
onclick="csharpLauncherManager.executeWithSelectedArgs('${this.currentProject.id}', '${exe.filename}')">
|
||||||
Ejecutar
|
Ejecutar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -379,6 +487,50 @@ class CSharpLauncherManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async loadExecutableArgumentsForCard(projectId, exeName) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/csharp-executable-arguments/${projectId}/${exeName}`);
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
const argsList = data.arguments || [];
|
||||||
|
this.populateArgumentsCombo(exeName, argsList);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading arguments for card:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
populateArgumentsCombo(exeName, argsList) {
|
||||||
|
const comboId = `args-combo-${exeName.replace('.exe', '').replace(/[^a-zA-Z0-9]/g, '_')}`;
|
||||||
|
const combo = document.getElementById(comboId);
|
||||||
|
if (!combo) return;
|
||||||
|
|
||||||
|
// Limpiar opciones existentes excepto "Sin argumentos"
|
||||||
|
combo.innerHTML = '<option value="">Sin argumentos</option>';
|
||||||
|
|
||||||
|
// Agregar argumentos predefinidos
|
||||||
|
argsList.forEach((arg, index) => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = arg.arguments;
|
||||||
|
option.textContent = arg.description;
|
||||||
|
option.title = arg.arguments; // Tooltip con los argumentos
|
||||||
|
combo.appendChild(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async executeWithSelectedArgs(projectId, exeName) {
|
||||||
|
const comboId = `args-combo-${exeName.replace('.exe', '').replace(/[^a-zA-Z0-9]/g, '_')}`;
|
||||||
|
const combo = document.getElementById(comboId);
|
||||||
|
const selectedArgs = combo ? combo.value : '';
|
||||||
|
|
||||||
|
if (selectedArgs) {
|
||||||
|
const argsArray = selectedArgs.split(' ').filter(arg => arg.length > 0);
|
||||||
|
await this.executeExecutable(projectId, exeName, argsArray);
|
||||||
|
} else {
|
||||||
|
await this.executeExecutable(projectId, exeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clearExecutables() {
|
clearExecutables() {
|
||||||
const grid = document.getElementById('csharp-executables-grid');
|
const grid = document.getElementById('csharp-executables-grid');
|
||||||
if (grid) {
|
if (grid) {
|
||||||
|
@ -993,15 +1145,15 @@ async function saveCSharpExecutableMetadata(projectId, exeName) {
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
showNotification(result.message, 'success');
|
csharpLauncherManager.showNotification(result.message, 'success');
|
||||||
closeCSharpMetadataEditor();
|
closeCSharpMetadataEditor();
|
||||||
await loadCSharpExecutableManager();
|
await loadCSharpExecutableManager();
|
||||||
await csharpLauncherManager.loadProjectExecutables(projectId);
|
await csharpLauncherManager.loadProjectExecutables(projectId);
|
||||||
} else {
|
} else {
|
||||||
showNotification(result.message, 'error');
|
csharpLauncherManager.showNotification(result.message, 'error');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Error guardando metadatos', 'error');
|
csharpLauncherManager.showNotification('Error guardando metadatos', 'error');
|
||||||
console.error('Error saving metadata:', error);
|
console.error('Error saving metadata:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1174,7 @@ async function editCSharpExecutableArguments(projectId, exeName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCSharpArgumentsEditor(projectId, exeName, arguments) {
|
function showCSharpArgumentsEditor(projectId, exeName, argsList) {
|
||||||
const modalHtml = `
|
const modalHtml = `
|
||||||
<div id="csharp-arguments-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
<div id="csharp-arguments-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
||||||
<div class="bg-white rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto">
|
<div class="bg-white rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||||
|
@ -1057,14 +1209,14 @@ function showCSharpArgumentsEditor(projectId, exeName, arguments) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
document.body.insertAdjacentHTML('beforeend', modalHtml);
|
||||||
renderCSharpArguments(arguments);
|
renderCSharpArguments(argsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderCSharpArguments(arguments) {
|
function renderCSharpArguments(argsList) {
|
||||||
const container = document.getElementById('csharp-arguments-list');
|
const container = document.getElementById('csharp-arguments-list');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
container.innerHTML = arguments.map((arg, index) => `
|
container.innerHTML = argsList.map((arg, index) => `
|
||||||
<div class="argument-item bg-gray-50 p-4 rounded-lg" data-index="${index}">
|
<div class="argument-item bg-gray-50 p-4 rounded-lg" data-index="${index}">
|
||||||
<div class="grid grid-cols-12 gap-3 items-center">
|
<div class="grid grid-cols-12 gap-3 items-center">
|
||||||
<div class="col-span-4">
|
<div class="col-span-4">
|
||||||
|
@ -1087,7 +1239,7 @@ function renderCSharpArguments(arguments) {
|
||||||
</div>
|
</div>
|
||||||
`).join('');
|
`).join('');
|
||||||
|
|
||||||
if (arguments.length === 0) {
|
if (argsList.length === 0) {
|
||||||
container.innerHTML = `
|
container.innerHTML = `
|
||||||
<div class="text-center text-gray-500 py-8">
|
<div class="text-center text-gray-500 py-8">
|
||||||
<div class="text-2xl mb-2">⚙️</div>
|
<div class="text-2xl mb-2">⚙️</div>
|
||||||
|
@ -1115,40 +1267,48 @@ function removeCSharpArgument(index) {
|
||||||
|
|
||||||
function collectCSharpArguments() {
|
function collectCSharpArguments() {
|
||||||
const argumentItems = document.querySelectorAll('.argument-item');
|
const argumentItems = document.querySelectorAll('.argument-item');
|
||||||
const arguments = [];
|
const argsList = [];
|
||||||
|
|
||||||
argumentItems.forEach(item => {
|
argumentItems.forEach(item => {
|
||||||
const description = item.querySelector('.arg-description').value.trim();
|
const description = item.querySelector('.arg-description').value.trim();
|
||||||
const argumentValue = item.querySelector('.arg-value').value.trim();
|
const argumentValue = item.querySelector('.arg-value').value.trim();
|
||||||
|
|
||||||
if (description && argumentValue) {
|
if (description && argumentValue) {
|
||||||
arguments.push({ description, arguments: argumentValue });
|
argsList.push({ description, arguments: argumentValue });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return arguments;
|
return argsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveCSharpExecutableArguments(projectId, exeName) {
|
async function saveCSharpExecutableArguments(projectId, exeName) {
|
||||||
const arguments = collectCSharpArguments();
|
const argsList = collectCSharpArguments();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/csharp-executable-arguments/${projectId}/${exeName}`, {
|
const response = await fetch(`/api/csharp-executable-arguments/${projectId}/${exeName}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ arguments })
|
body: JSON.stringify({ arguments: argsList })
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
showNotification(result.message, 'success');
|
csharpLauncherManager.showNotification(result.message, 'success');
|
||||||
closeCSharpArgumentsEditor();
|
closeCSharpArgumentsEditor();
|
||||||
|
// Recargar la lista de ejecutables si está abierto el gestor
|
||||||
|
if (document.getElementById('csharp-executable-manager').style.display !== 'none') {
|
||||||
|
await loadCSharpExecutableManager();
|
||||||
|
}
|
||||||
|
// Recargar argumentos en las cards actuales
|
||||||
|
if (csharpLauncherManager.currentProject) {
|
||||||
|
csharpLauncherManager.loadExecutableArgumentsForCard(projectId, exeName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showNotification(result.message, 'error');
|
csharpLauncherManager.showNotification(result.message, 'error');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Error guardando argumentos', 'error');
|
csharpLauncherManager.showNotification('Error guardando argumentos', 'error');
|
||||||
console.error('Error saving arguments:', error);
|
console.error('Error saving arguments:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1254,5 +1414,124 @@ function showCSharpExecutableArgs(projectId, exeName, displayName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicialización global
|
// Asegurar inicialización cuando el DOM esté listo
|
||||||
window.csharpLauncherManager = new CSharpLauncherManager();
|
(function () {
|
||||||
|
console.log('C# Launcher script loaded, preparing initialization...');
|
||||||
|
|
||||||
|
function initializeCSharpLauncher() {
|
||||||
|
try {
|
||||||
|
console.log('Initializing CSharpLauncherManager...');
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
window.csharpLauncherManager = new CSharpLauncherManager();
|
||||||
|
console.log('CSharpLauncherManager created successfully');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error creating CSharpLauncherManager:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializar inmediatamente si el DOM ya está listo
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', initializeCSharpLauncher);
|
||||||
|
} else {
|
||||||
|
initializeCSharpLauncher();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Función global para debug
|
||||||
|
window.debugCSharpLauncher = function () {
|
||||||
|
console.log('=== C# Launcher Debug Info ===');
|
||||||
|
console.log('Initialized:', window.csharpLauncherManager.initialized);
|
||||||
|
console.log('Projects:', window.csharpLauncherManager.projects);
|
||||||
|
console.log('Current Project:', window.csharpLauncherManager.currentProject);
|
||||||
|
console.log('Executables:', window.csharpLauncherManager.executables);
|
||||||
|
console.log('Favorites:', Array.from(window.csharpLauncherManager.favorites));
|
||||||
|
console.log('localStorage:', localStorage.getItem('csharp_last_selected_project'));
|
||||||
|
|
||||||
|
// Verificar elementos DOM
|
||||||
|
const select = document.getElementById('csharp-project-select');
|
||||||
|
console.log('Project Select Element:', select);
|
||||||
|
if (select) {
|
||||||
|
console.log('Select Options:', select.options.length);
|
||||||
|
console.log('Select Value:', select.value);
|
||||||
|
}
|
||||||
|
console.log('==============================');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Función global para resetear
|
||||||
|
window.resetCSharpLauncher = function () {
|
||||||
|
console.log('Resetting C# Launcher...');
|
||||||
|
return window.csharpLauncherManager.reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
// === FUNCIONES DE RESPALDO PARA EVITAR ERRORES DE REFERENCIA ===
|
||||||
|
|
||||||
|
// Asegurar que las funciones globales estén definidas antes de que se necesiten
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
console.log('DOM loaded, ensuring C# launcher functions are available...');
|
||||||
|
|
||||||
|
// Solo redefinir si no existe para evitar conflictos
|
||||||
|
if (typeof window.openCSharpProjectEditor === 'undefined') {
|
||||||
|
window.openCSharpProjectEditor = function () {
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not initialized');
|
||||||
|
alert('Error: El launcher C# no está inicializado. Refresca la página.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.csharpLauncherManager.openProjectEditor();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window.loadCSharpExecutables === 'undefined') {
|
||||||
|
window.loadCSharpExecutables = function () {
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const select = document.getElementById('csharp-project-select');
|
||||||
|
if (select && window.csharpLauncherManager) {
|
||||||
|
window.csharpLauncherManager.onProjectChange({ target: select });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window.filterCSharpByCategory === 'undefined') {
|
||||||
|
window.filterCSharpByCategory = function (category) {
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.csharpLauncherManager.filterByCategory(category);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window.refreshCSharpProcesses === 'undefined') {
|
||||||
|
window.refreshCSharpProcesses = function () {
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.csharpLauncherManager.refreshProcesses();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window.openCSharpExecutableManager === 'undefined') {
|
||||||
|
window.openCSharpExecutableManager = function () {
|
||||||
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not initialized');
|
||||||
|
alert('Error: El launcher C# no está inicializado. Refresca la página.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!window.csharpLauncherManager.currentProject) {
|
||||||
|
alert('Por favor selecciona un proyecto primero');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usar la función ya implementada
|
||||||
|
loadCSharpExecutableManager();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('C# launcher backup functions initialized');
|
||||||
|
});
|
|
@ -1371,8 +1371,14 @@ function switchTab(tabName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializar C# launcher si es la primera vez
|
// Inicializar C# launcher si es la primera vez
|
||||||
if (tabName === 'csharp' && !window.csharpLauncherManager.currentProject) {
|
if (tabName === 'csharp') {
|
||||||
window.csharpLauncherManager.init();
|
if (!window.csharpLauncherManager) {
|
||||||
|
console.error('csharpLauncherManager not found! Make sure csharp_launcher.js is loaded.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!window.csharpLauncherManager.initialized) {
|
||||||
|
window.csharpLauncherManager.init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -385,7 +385,8 @@
|
||||||
<div class="flex justify-between items-center mb-4">
|
<div class="flex justify-between items-center mb-4">
|
||||||
<h2 class="text-xl font-bold">Launcher C# - Proyectos Compilados</h2>
|
<h2 class="text-xl font-bold">Launcher C# - Proyectos Compilados</h2>
|
||||||
<button onclick="openCSharpProjectEditor()"
|
<button onclick="openCSharpProjectEditor()"
|
||||||
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
|
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600"
|
||||||
|
onmousedown="if(!window.openCSharpProjectEditor) alert('Launcher C# cargando...')">
|
||||||
Gestionar Proyectos
|
Gestionar Proyectos
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue