wok-ui-router

Manage routes, parameters, and navigation in wok-ui single-page applications.

Updated Sep 14, 2023
One-click install
npx skills add https://github.com/PeakTai/wok-ui --skill wok-ui-router
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wok-ui-router
Source: https://github.com/PeakTai/wok-ui/tree/main/skills/wok-ui-router
Command: npx skills add https://github.com/PeakTai/wok-ui --skill wok-ui-router

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

介绍 wok-ui 路由系统的使用方法,包括路由初始化、路径规则与别名、按需加载、参数获取、页面跳转、布局复用、缓存、生命周期与钩子函数。

Core Features & Use Cases

  • 初始化路由:通过 initRouter 设置模式、基础路径和路由规则
  • 参数与查询解析:通过 getPathVar、getParam、getParamVals 提取路径变量与查询参数
  • 导航与链接:使用 push/replace 和 RouterLink 实现声明式导航
  • 缓存与性能:路由缓存支持多参数缓存与页面保留
  • 按需加载:支持 Promise<Module> 的延迟加载
  • 生命周期与钩子:支持 beforeEach、afterEach、errorHandler 等导航钩子

Quick Start

Create a router with initRouter and mount it to the document body to render a page.

Frequently Asked Questions about wok-ui-router

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up routing in a wok-ui single-page application?

To set up routing in a wok-ui single-page application, use the initRouter function to configure the routing mode, base path, and route rules, then mount the router to the document body to render pages.

How does lazy loading work for wok-ui routes?

Lazy loading for wok-ui routes works by mapping route paths to a Promise<Module>, which defers loading the module until the route is accessed, improving initial application performance.

Can I extract path variables and query parameters in wok-ui navigation?

Yes, you can extract path variables and query parameters in wok-ui navigation by using the getPathVar, getParam, and getParamVals functions to parse route data during navigation.

Does wok-ui support navigation hooks like beforeEach and afterEach?

Yes, wok-ui supports navigation hooks including beforeEach, afterEach, and errorHandler, allowing you to intercept navigation, execute logic, and handle routing errors globally.

What is the best way to manage route caching and remove specific page caches?

The best way to manage route caching is using the built-in cache support for multi-parameter retention, and clearing specific caches using removeCurrentPageCache, removeCacheByPath, or removeCache.

Does the wok-ui router support both hash and history routing modes?

Yes, the wok-ui router supports both hash and history routing modes, which can be specified during the initRouter configuration to manage single-page application navigation strategies.