@@ -8,11 +8,11 @@ A lightweight solution providing standardized plugin system for Vue Router.
88
99## 🌟 Core Features
1010
11- | Feature | Description |
12- | -------------------------------------- | ------------------------------------------------------------------------------ |
13- | 🧱 ** Standardized Plugin Interface** | Unified plugin development specification with auto-registration/uninstallation |
14- | 🔁 ** Reactive Side-effect Management** | Automatic tracking/cleanup of plugin's reactive side-effects |
15- | ⚖️ ** Dual-mode Compatibility** | Support both Vue Router plugin system and Vue plugin system |
11+ | Feature | Description |
12+ | -------------------------------------- | -------------------------------------------------------------------------------- |
13+ | 🧱 ** Standardized Plugin Interface** | Unified plugin development specification with auto-registration/uninstallation |
14+ | 🔁 ** Reactive Side-effect Management** | Automatic tracking/cleanup of plugin's reactive side-effects |
15+ | ⚖️ ** Dual-mode Compatibility** | Supports both Vue Router plugin system and Vue plugin system compatibility modes |
1616
1717---
1818
@@ -26,7 +26,7 @@ npm install vue-router-plugin-system
2626
2727## 🚀 Getting Started
2828
29- ### Mode 1: Vue Router Plugin (Recommended)
29+ ### Mode 1: Vue Router Plugin Mode (Recommended)
3030
3131** 1. Plugin Development**
3232
@@ -70,37 +70,39 @@ const router = createRouter({
7070router .isNavigating .value
7171```
7272
73- ### Mode 2: Vue Plugin (Compatibility)
73+ ### Mode 2: Vue Plugin Mode (Compatibility)
7474
75- ** 1. Create Vue Plugin**
75+ ** 1. Plugin Development **
7676
7777``` ts
78- import { createVueRouterPlugin } from ' vue-router-plugin-system'
78+ import type { RouterPlugin } from ' vue-router-plugin-system'
79+ import { ref } from ' vue'
7980
80- export const NavigationStatePlugin = createVueRouterPlugin ( (ctx ) => {
81- // Same implementation logic as above
82- })
81+ export const NavigationStatePlugin: RouterPlugin = (ctx ) => {
82+ // Implementation logic remains the same
83+ }
8384```
8485
8586** 2. Application Integration**
8687
8788``` ts
8889// main.ts
90+ import { asVuePlugin } from ' vue-router-plugin-system'
91+
8992const app = createApp (App )
9093app .use (router ) // Mount router first
91- app .use (NavigationStatePlugin ) // Register plugin later
94+ app .use (asVuePlugin ( NavigationStatePlugin ) ) // Register plugin later
9295```
9396
9497---
9598
9699## ⚠️ Mode Comparison
97100
98- | Feature | Vue Router Plugin | Vue Plugin |
99- | ------------------------- | -------------------------------- | ------------------------------- |
100- | Initialization Order | Prior to app logic | Dependent on client usage order |
101- | Navigation Guard Priority | Higher | Dependent on registration order |
102- | Reactive Management | Automatic cleanup | Automatic cleanup |
103- | Dependency Requirement | Requires this lib's createRouter | No dependency required |
101+ | Feature | Vue Router Plugin Mode | Vue Plugin Mode |
102+ | -------------------- | -------------------------- | ----------------------------- |
103+ | Initialization Order | Prioritized over app logic | Depends on client usage order |
104+ | Guard Priority | Higher priority | Depends on registration order |
105+ | Reactive Management | Auto-cleanup | Auto-cleanup |
104106
105107---
106108
@@ -113,11 +115,11 @@ interface RouterPluginContext {
113115 */
114116 router: Router
115117 /**
116- * Execute callback with vue app instance
118+ * Execute callback with Vue app instance
117119 */
118120 runWithApp: (handler : RouterPluginRunWithAppHandler ) => void
119121 /**
120- * Register uninstall callback (can be called multiple times )
122+ * Register uninstallation callback (supports multiple calls )
121123 */
122124 onUninstall: (handler : RouterPluginUninstallHandler ) => void
123125}
@@ -128,24 +130,17 @@ interface RouterPlugin {
128130 */
129131 (ctx : RouterPluginContext ): void
130132}
131-
132- interface VueRouterPlugin extends RouterPlugin {
133- /**
134- * Vue plugin installation function
135- */
136- install: (app : App ) => void
137- }
138133```
139134
140135---
141136
142- ## 🤝 Contribution Guidelines
137+ ## 🤝 Contribution Guide
143138
144- Contributions welcome! Please ensure:
139+ Contributions are welcome! Please ensure:
145140
146- 1 . Pass all unit tests
147- 2 . Maintain TypeScript type integrity
148- 3 . Add necessary documentation
141+ 1 . All unit tests pass
142+ 2 . TypeScript type integrity maintained
143+ 3 . Necessary documentation added
149144
150145## License
151146
0 commit comments