feat(plugin): add left-menu registration for P365X with settings fallback
This commit is contained in:
41
porn365.js
41
porn365.js
@@ -209,32 +209,39 @@
|
||||
v.load();
|
||||
};
|
||||
|
||||
addLampaMenuButton();
|
||||
registerLeftMenuEntry();
|
||||
log('UI mounted');
|
||||
}
|
||||
|
||||
function addLampaMenuButton() {
|
||||
function registerLeftMenuEntry() {
|
||||
try {
|
||||
if (!window.Lampa || !Lampa.SettingsApi || !Lampa.SettingsApi.addParam) return;
|
||||
if (!window.Lampa) return;
|
||||
|
||||
// Основной путь: пункт в левом меню
|
||||
if (Lampa.Menu && typeof Lampa.Menu.add === 'function') {
|
||||
Lampa.Menu.add({
|
||||
title: 'P365X',
|
||||
component: 'p365x_proxy_component',
|
||||
icon: '<svg width="36" height="36" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><circle cx="32" cy="32" r="30" fill="currentColor" opacity="0.18"/><text x="32" y="39" text-anchor="middle" font-size="20" fill="currentColor" font-family="sans-serif">P</text></svg>',
|
||||
onSelect: function () { openPanel(); },
|
||||
onClick: function () { openPanel(); },
|
||||
action: function () { openPanel(); }
|
||||
});
|
||||
log('Left menu entry registered via Lampa.Menu.add');
|
||||
}
|
||||
|
||||
// Фолбэк: оставим кнопку в настройках, если API меню недоступно
|
||||
if (Lampa.SettingsApi && typeof Lampa.SettingsApi.addParam === 'function') {
|
||||
Lampa.SettingsApi.addParam({
|
||||
component: 'interface',
|
||||
param: {
|
||||
name: 'p365x_open_btn',
|
||||
type: 'button'
|
||||
},
|
||||
field: {
|
||||
name: 'P365X каталог',
|
||||
description: 'Открыть каталог P365X'
|
||||
},
|
||||
onChange: function () {
|
||||
openPanel();
|
||||
}
|
||||
param: { name: 'p365x_open_btn', type: 'button' },
|
||||
field: { name: 'P365X каталог', description: 'Открыть каталог P365X' },
|
||||
onChange: function () { openPanel(); }
|
||||
});
|
||||
|
||||
log('Settings button registered');
|
||||
log('Fallback settings button registered');
|
||||
}
|
||||
} catch (e) {
|
||||
log('Settings button error: ' + (e && e.message ? e.message : e));
|
||||
log('Menu registration error: ' + (e && e.message ? e.message : e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user