Skip to content

Commit 7bfaf0a

Browse files
committed
refactor: entryProvider module folder
1 parent 7923536 commit 7bfaf0a

File tree

8 files changed

+26
-152
lines changed

8 files changed

+26
-152
lines changed

apps/ui/src/composables/defineAppModule.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { Router } from "vue-router";
1+
import type { RouteRecordRaw } from "vue-router";
22

33
export interface AppModuleSetupContext {
4-
router: Router
5-
addRoute: Router['addRoute']
4+
addRoute: (route: RouteRecordRaw) => void
65
}
76

87
export interface AppModule {

apps/ui/src/main.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import App from './App.vue'
77
import router from '@/router/router'
88

99
import { vVisible } from './directives/vVisible'
10-
import type { AppModule } from './composables/defineAppModule'
10+
import type { AppModule, AppModuleSetupContext } from './composables/defineAppModule'
11+
import type { RouteRecordRaw } from 'vue-router'
1112

1213
async function getPlugins() {
1314
const files = import.meta.glob<Record<string, Plugin>>('./plugins/*.ts', { eager: true })
@@ -45,8 +46,6 @@ async function getAppModules() {
4546
async function createApp() {
4647
const app = createVueApp(App)
4748

48-
app.use(router)
49-
5049
app.directive('visible', vVisible)
5150

5251
const plugins = await getPlugins()
@@ -64,14 +63,17 @@ async function createApp() {
6463
for await (const appModule of appModules) {
6564
console.debug(`[app] module ${appModule.name} loaded`)
6665

67-
if (appModule.setup) {
68-
await appModule.setup({
69-
router,
70-
addRoute: router.addRoute,
71-
})
72-
}
66+
await appModule.setup({
67+
addRoute: r => {
68+
console.debug(`[app] module ${appModule.name} added route ${r.path}`)
69+
70+
router.addRoute(r)
71+
}
72+
})
7373
}
7474

75+
app.use(router)
76+
7577
return app
7678
}
7779

apps/ui/src/modules/appPage/components/AppPageDirectory.vue

Lines changed: 0 additions & 117 deletions
This file was deleted.

apps/ui/src/modules/appPage/components/AppPageFile.vue

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/ui/src/modules/appPage/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineAppModule({
22
setup({ addRoute }) {
33
addRoute({
4-
path: '/hephaestus-editor',
4+
path: '/app-page/:name',
55
component: () => import('./pages/AppPage.vue'),
66
})
77
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default defineAppModule({
2+
setup({ addRoute }) {
3+
addRoute({
4+
path: '/entries/:path(.*)*',
5+
props: true,
6+
component: () => import('./pages/EntryProvider.vue'),
7+
})
8+
}
9+
})

apps/ui/src/router/routes.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ const routes: RouteRecordRaw[] = [
1313
layout: 'empty'
1414
},
1515
},
16-
{
17-
path: '/entries/:path(.*)*',
18-
name: 'EntryProvider',
19-
props: true,
20-
component: () => import('@/pages/EntryProvider/EntryProvider.vue'),
21-
},
2216
// {
23-
// path: '/app-pages/:name',
24-
// name: 'AppPageProvider',
17+
// path: '/entries/:path(.*)*',
18+
// name: 'EntryProvider',
2519
// props: true,
26-
// component: () => import('@/pages/AppPage/AppPage.vue'),
20+
// component: () => import('@/pages/EntryProvider/EntryProvider.vue'),
2721
// },
2822
{
2923
path: '/cheat-sheet',

0 commit comments

Comments
 (0)