用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-vue --skill vue-router命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Master Vue Composition API - Composables, Reactivity Utilities, Script Setup, Provide/Inject
Master Vue.js core concepts - Components, Reactivity, Templates, Directives, Lifecycle
Master Nuxt.js - SSR, SSG, Nitro Server, Modules, Auto-imports, Deployment
基于 SOC 职业分类
正在显示 SKILL.md
| name | vue-router |
| description | Master Vue Router - Navigation, Guards, Lazy Loading, Meta Fields, History Modes |
| sasmp_version | 1.3.0 |
| bonded_agent | 04-vue-router |
| bond_type | PRIMARY_BOND |
| version | 2.0.0 |
| last_updated | 2025-01 |
Production-grade skill for mastering Vue Router and building robust navigation systems.
Single Responsibility: Teach Vue Router configuration, navigation patterns, route guards, lazy loading, and advanced routing techniques.
interface VueRouterParams {
topic: 'config' | 'guards' | 'lazy-loading' | 'meta' | 'navigation' | 'all';
level: 'beginner' | 'intermediate' | 'advanced';
context?: {
auth_required?: boolean;
app_type?: 'spa' | 'ssr';
};
}
Prerequisites: vue-fundamentals
Duration: 2 hours
Outcome: Configure Vue Router
| Topic | Concept | Exercise |
|---|---|---|
| Installation | Vue Router setup | Basic config |
| Routes array | Route definitions | Multi-page app |
| History modes | Hash vs HTML5 | Production setup |
| Router-view | Outlet component | Layout system |
| Router-link | Navigation links | Navigation menu |
Prerequisites: Module 1
Duration: 2-3 hours
Outcome: Build complex route structures
| Pattern | Example | Exercise |
|---|---|---|
| Dynamic params | /user/:id | User profile |
| Optional params | /user/:id? | Optional filters |
| Catch-all | /:pathMatch(.*)* | 404 page |
| Nested routes | /dashboard/settings | Admin layout |
| Named views | Multiple outlets | Dashboard widgets |
Prerequisites: Modules 1-2
Duration: 3-4 hours
Outcome: Secure routes with guards
| Guard Type | Scope | Use Case |
|---|---|---|
| beforeEach | Global | Auth check |
| beforeEnter | Per-route | Role check |
| beforeRouteEnter | Component | Data prefetch |
| beforeRouteUpdate | Component | Param change |
| beforeRouteLeave | Component | Unsaved changes |
| afterEach | Global | Analytics |
Guard Composition:
router.beforeEach(async (to, from) => {
// Auth check
if (to.meta.requiresAuth && !isAuthenticated()) {
return { name: 'Login', query: { redirect: to.fullPath } }
}
// Role check
if (to.meta.roles && !hasRole(to.meta.roles)) {
return { name: 'Unauthorized' }
}
return true
})
Prerequisites: Module 3
Duration: 2 hours
Outcome: Optimize route loading
| Technique | Implementation | Benefit |
|---|---|---|
| Basic lazy | () => import() | Smaller bundles |
| Named chunks | webpackChunkName | Grouped loading |
| Prefetching | router.afterEach | Faster navigation |
| Loading states | Async components | Better UX |
Prerequisites: Modules 1-4
Duration: 3 hours
Outcome: Expert routing techniques
| Pattern | Use Case | Exercise |
|---|---|---|
| Route meta | Page metadata | SEO, auth, layout |
| Scroll behavior | Scroll position | Saved positions |
| Transitions | Page animations | Enter/leave effects |
| Route modules | Large apps | Feature-based routes |
const skillConfig = {
maxAttempts: 3,
backoffMs: [1000, 2000, 4000],
onFailure: 'provide_simpler_route'
}
tracking:
- event: route_configured
data: [route_count, guards_count]
- event: navigation_pattern_learned
data: [pattern_name, complexity]
- event: skill_completed
data: [routes_built, auth_implemented]
| Issue | Cause | Solution |
|---|---|---|
| Route not matching | Wrong path order | Specific before generic |
| Guard infinite loop | Guard → same route | Check target route |
| Lazy load fails | Wrong import path | Verify file exists |
| Params undefined | Missing props: true | Enable props |
import { describe, it, expect, beforeEach } from 'vitest'
import { createRouter, createWebHistory } from 'vue-router'
import { routes } from './routes'
describe('Router', () => {
let router: Router
beforeEach(() => {
router = createRouter({
history: createWebHistory(),
routes
})
})
it('redirects to login when not authenticated', async () => {
await router.push('/dashboard')
expect(router.currentRoute.value.name).toBe('Login')
})
it('allows access to public routes', async () => {
await router.push('/about')
expect(router.currentRoute.value.name).toBe('About')
})
})
Skill("vue-router")
vue-fundamentals - Prerequisitevue-pinia - Auth state for guardsvue-nuxt - File-based routing alternative