Добавлены runtime logs и автозагрузка Android устройств

Этот коммит содержится в:
Виктор
2026-05-11 23:31:51 +09:00
родитель 1966eb1c0d
Коммит 8158dd265c
+60 -3
Просмотреть файл
@@ -1,4 +1,19 @@
function appendLog(message) {
const logs = document.getElementById('logs');
if (!logs) {
return;
}
const time = new Date().toLocaleTimeString();
logs.innerText += `\n[${time}] ${message}`;
logs.scrollTop = logs.scrollHeight;
}
async function workspaceApi(url, payload = {}) { async function workspaceApi(url, payload = {}) {
appendLog(`API запрос: ${url}`);
const response = await fetch(url, { const response = await fetch(url, {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -13,6 +28,8 @@ async function workspaceApi(url, payload = {}) {
async function loadWorkspaceTree() { async function loadWorkspaceTree() {
const workspace = document.getElementById('workspacePath').value; const workspace = document.getElementById('workspacePath').value;
appendLog(`Загрузка workspace: ${workspace}`);
const data = await workspaceApi('/api/files/tree', { const data = await workspaceApi('/api/files/tree', {
path: workspace path: workspace
}); });
@@ -47,6 +64,8 @@ function renderTree(tree, level = 0) {
} }
async function openFile(path) { async function openFile(path) {
appendLog(`Открытие файла: ${path}`);
const data = await workspaceApi('/api/files/read', { const data = await workspaceApi('/api/files/read', {
path path
}); });
@@ -59,12 +78,50 @@ async function saveCurrentFile() {
const path = document.getElementById('editorPath').innerText; const path = document.getElementById('editorPath').innerText;
const content = document.getElementById('editor').value; const content = document.getElementById('editor').value;
appendLog(`Сохранение файла: ${path}`);
const data = await workspaceApi('/api/files/save', { const data = await workspaceApi('/api/files/save', {
path, path,
content content
}); });
document.getElementById('editorStatus').innerText = data.success appendLog(data.success ? 'Файл успешно сохранен' : 'Ошибка сохранения файла');
? 'Файл сохранен'
: 'Ошибка сохранения';
} }
async function loadDevices() {
appendLog('Обновление списка Android устройств');
const data = await workspaceApi('/api/android/devices');
const container = document.getElementById('devices');
if (!container) {
return;
}
const lines = (data.stdout || '').split('\n');
const devices = lines.filter(line =>
line.includes('device') && !line.includes('List')
);
if (devices.length === 0) {
container.innerHTML = 'Устройства не подключены';
return;
}
container.innerHTML = devices.map(device => {
const id = device.split(/\s+/)[0];
return `
<div style="margin-bottom:8px;padding:8px;background:#1d2430;border-radius:8px;">
📱 ${id}
</div>
`;
}).join('');
}
window.addEventListener('load', () => {
loadDevices();
appendLog('DevConsole workspace runtime готов');
});