
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
@blumjs/router
Advanced tools
Библиотека основана на effector и window.history.state без изменения url и hash. Создана для роутинга vk-mini-apps, также поддерживает PWA. Рекомендуется использовать с @blumjs/cli.
Чтобы обработать браузерную кнопку назад, нужно проинициализровать роутер:
import { useInitRouter } from '@blumjs/router';
const App = () => {
useInitRouter({
view: "Main",
panel: "Home",
modal: null,
popout: null
});
...
}
Чтобы поймать кнопку назад, используйте middlewares:
import {
useInitRouter,
createCatchBackBrowserRouteMiddleware,
createDisableBackBrowserRouteMiddleware,
createRouteMiddleware,
blumRouter
} from '@blumjs/router';
const App = () => {
useInitRouter({
view: "Main",
panel: "Home",
modal: null,
popout: null
},
//первый аргумент - название роута; второй callback, который вызовется при срабатывании браузерной кнопки назад
createCatchBackBrowserRouteMiddleware('Alert', (storeRoutes, prevRoutes) => back());
//такая же как createCatchBackBrowserRouteMiddleware, но автоматически предотвращает изменение роутеров
createDisableBackBrowserRouteMiddleware('Loading', (storeRoutes, prevRoutes) => console.log('loading, please wait...')),
//кастомный middleware
createRouteMiddleware((storeRoutes, prevRoutes) => {
if(navigator.onLine){
//middleware пройден
return true;
}
blumRouter.historyPush({view: 'ConnectionError', panel: 'Offline', modal: null, popout: null});
return false;
})
);
...
}
Чтобы получить роутеры и проверить инициализацию:
import { useRouter } from '@blumjs/router';
const App = () => {
const { activeView, activePanel, activeModal, activePopout, isRouteInit } = useRouter();
...
}
Чтобы поставить роутер, используйте функции: setActiveView, setActivePanel, setActiveModal, setActivePopout.
import { setActiveViewPanel, setActivePanel, setActiveModal, setActivePopout } from '@blumjs/router';
setActiveViewPanel({view: 'Main', panel: 'Home'});
setActivePanel('Home');
setActiveModal('Notifications');
setActivePopout('Loading');
Чтобы вернуться на предыдущую страницу:
import { back } from '@blumjs/router';
//если вы хотите, чтобы роутеры менялись до прогонки middlewares:
back({
isDispatchChangeStateEventBeforeMiddleware: true,
isDispatchChangeStateEventAfterMiddleware: false
});
//back - асинхронная функция и ее нельзя дождаться с помощью await и then. Используйте опции beforeBackHandledCallback (срабатывает после window.history.back и перед middlewares) и afterBackHandledCallback (срабатывает при успешном или провальном обходе middlewares)
back({
beforeBackHandledCallback: (storeRoutes, prevRoutes) => {
console.log("I triggered before middlewares")
},
afterBackHandledCallback: (storeRoutes, prevRoutes) => {
console.log("I triggered after middlewares")
}
});
//значения по умолчанию: isDispatchChangeStateEventBeforeMiddleware = false, isDispatchChangeStateEventAfterMiddleware = true, и callbacks = null
back();
Если вам нужно выключить модалку или popout на новой странице (например, offline страница, где пользователь не должен видеть модалку и popout) вы можете использовать _setActiveModal, _setActivePopout. В других случаях лучше использовать функцию back.
import { _setActiveModal, _setActivePopout } from '@blumjs/router';
_setActiveModal(null);
_setActivePopout(null);
FAQs
Роутер для vk-mini-apps
We found that @blumjs/router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.