@majkapp/plugin-kit 3.3.3 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/INDEX.md +42 -1
- package/package.json +1 -1
package/docs/INDEX.md
CHANGED
|
@@ -43,7 +43,8 @@ const plugin = definePlugin('my-plugin', 'My Plugin', '1.0.0')
|
|
|
43
43
|
name: 'My Plugin',
|
|
44
44
|
description: 'Main plugin screen',
|
|
45
45
|
route: '/plugin-screens/my-plugin/main',
|
|
46
|
-
pluginPath: '/index.html'
|
|
46
|
+
pluginPath: '/index.html', // Path to built React app
|
|
47
|
+
pluginPathHash: '#/' // Route within React app (HashRouter)
|
|
47
48
|
})
|
|
48
49
|
|
|
49
50
|
.build();
|
|
@@ -228,6 +229,46 @@ export default defineConfig({
|
|
|
228
229
|
- Empty base ensures assets load correctly
|
|
229
230
|
- `base: './'` will cause 404 errors for assets
|
|
230
231
|
|
|
232
|
+
### Hash Routing for Multiple Screens
|
|
233
|
+
|
|
234
|
+
**Use `pluginPathHash` to route to different screens in your React app:**
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// Multiple screens using hash routes
|
|
238
|
+
.screenReact({
|
|
239
|
+
id: 'my-plugin-dashboard',
|
|
240
|
+
name: 'Dashboard',
|
|
241
|
+
route: '/plugin-screens/my-plugin/dashboard',
|
|
242
|
+
pluginPath: '/index.html',
|
|
243
|
+
pluginPathHash: '#/' // Main dashboard
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
.screenReact({
|
|
247
|
+
id: 'my-plugin-settings',
|
|
248
|
+
name: 'Settings',
|
|
249
|
+
route: '/plugin-screens/my-plugin/settings',
|
|
250
|
+
pluginPath: '/index.html',
|
|
251
|
+
pluginPathHash: '#/settings' // Settings page
|
|
252
|
+
})
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Your React app (ui/src/App.tsx) uses HashRouter:
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { HashRouter, Routes, Route } from 'react-router-dom';
|
|
259
|
+
|
|
260
|
+
export function App() {
|
|
261
|
+
return (
|
|
262
|
+
<HashRouter>
|
|
263
|
+
<Routes>
|
|
264
|
+
<Route path="/" element={<DashboardPage />} />
|
|
265
|
+
<Route path="/settings" element={<SettingsPage />} />
|
|
266
|
+
</Routes>
|
|
267
|
+
</HashRouter>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
231
272
|
## Best Practice: Decoupled Business Logic
|
|
232
273
|
|
|
233
274
|
**ALWAYS separate business logic from plugin code.** This makes testing easier and allows logic reuse.
|
package/package.json
CHANGED