
Пример мини-приложения с SDK
HTML<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Моё мини-приложение</title> <script src="https://panel.leecyber.com/assets/scripts/mapp_sdk.js"></script> </head> <body> <div id="app">Загрузка...</div> <script> const params = new URLSearchParams(window.location.search); const clientId = params.get('client_id'); const parentOrigin = params.get('parent_origin'); async function init() { LcPanel.init({ clientId, parentOrigin }); // Контекст const ctx = await LcPanel.getContext(); applyTheme(ctx.theme); // Подписка на смену темы LcPanel.on('THEME_CHANGED', (p) => applyTheme(p.theme)); // Загрузка настроек let settings; try { const stored = await LcPanel.storage.get('settings'); settings = stored.value; } catch { settings = { notifications: true }; } // Рендер document.getElementById('app').innerHTML = ` <h1>Привет, ${ctx.userId}</h1> <p>Организация: ${ctx.orgId}</p> <p>Язык: ${ctx.locale}</p> <button id="save">Сохранить</button> <button id="oauth">Авторизовать API</button> <button id="close">Закрыть</button> `; document.getElementById('save').onclick = async () => { await LcPanel.storage.put('settings', { notifications: false }); LcPanel.notify({ level: 'success', message: 'Сохранено!' }); }; document.getElementById('oauth').onclick = () => { LcPanel.requestOAuth({ scopes: ['id.read', 'projects.read'], }); }; document.getElementById('close').onclick = () => { LcPanel.close(); }; LcPanel.ready(); } function applyTheme(theme) { document.documentElement.dataset.theme = theme; } init().catch(console.error); </script> </body> </html>