diff --git a/console/console-src/modules/index.ts b/console/console-src/modules/index.ts index c3f5a66a36..9e8177aaf1 100644 --- a/console/console-src/modules/index.ts +++ b/console/console-src/modules/index.ts @@ -1,48 +1,10 @@ -// fixme: add supports for auto import -import dashboardModule from "./dashboard/module"; -import postModule from "./contents/posts/module"; -import pageModule from "./contents/pages/module"; -import commentModule from "./contents/comments/module"; -import attachmentModule from "./contents/attachments/module"; -import themeModule from "./interface/themes/module"; -import menuModule from "./interface/menus/module"; -import pluginModule from "./system/plugins/module"; -import userModule from "./system/users/module"; -import roleModule from "./system/roles/module"; -import settingModule from "./system/settings/module"; -import actuatorModule from "./system/actuator/module"; -import authProviderModule from "./system/auth-providers/module"; -import backupModule from "./system/backup/module"; +import type { PluginModule } from "@halo-dev/console-shared"; -// const coreModules = [ -// dashboardModule, -// postModule, -// pageModule, -// commentModule, -// attachmentModule, -// themeModule, -// menuModule, -// pluginModule, -// userModule, -// roleModule, -// settingModule, -// ]; +const modules = Object.values( + import.meta.glob("./**/module.ts", { + eager: true, + import: "default", + }) +) as PluginModule[]; -const coreModules = [ - postModule, - pluginModule, - settingModule, - actuatorModule, - dashboardModule, - menuModule, - commentModule, - attachmentModule, - pageModule, - themeModule, - userModule, - roleModule, - authProviderModule, - backupModule, -]; - -export { coreModules }; +export default modules; diff --git a/console/console-src/modules/system/auth-providers/module.ts b/console/console-src/modules/system/auth-providers/module.ts index e7c2e55a93..086919dd9a 100644 --- a/console/console-src/modules/system/auth-providers/module.ts +++ b/console/console-src/modules/system/auth-providers/module.ts @@ -6,11 +6,11 @@ import AuthProviderDetail from "./AuthProviderDetail.vue"; export default definePlugin({ routes: [ { - path: "/users", + path: "/users/auth-providers", component: BasicLayout, children: [ { - path: "auth-providers", + path: "", name: "AuthProviders", component: AuthProviders, meta: { @@ -19,7 +19,7 @@ export default definePlugin({ }, }, { - path: "auth-providers/:name", + path: ":name", name: "AuthProviderDetail", component: AuthProviderDetail, meta: { diff --git a/console/console-src/modules/system/roles/module.ts b/console/console-src/modules/system/roles/module.ts index 1f27a10aca..38ff665a82 100644 --- a/console/console-src/modules/system/roles/module.ts +++ b/console/console-src/modules/system/roles/module.ts @@ -7,11 +7,11 @@ export default definePlugin({ components: {}, routes: [ { - path: "/users", + path: "/users/roles", component: BasicLayout, children: [ { - path: "roles", + path: "", name: "Roles", component: RoleList, meta: { @@ -21,7 +21,7 @@ export default definePlugin({ }, }, { - path: "roles/:name", + path: ":name", name: "RoleDetail", component: RoleDetail, meta: { diff --git a/console/console-src/modules/system/users/module.ts b/console/console-src/modules/system/users/module.ts index 4380c72fad..9f260715ca 100644 --- a/console/console-src/modules/system/users/module.ts +++ b/console/console-src/modules/system/users/module.ts @@ -1,6 +1,5 @@ import { definePlugin } from "@halo-dev/console-shared"; import BasicLayout from "@console/layouts/BasicLayout.vue"; -import BlankLayout from "@console/layouts/BlankLayout.vue"; import UserStatsWidget from "./widgets/UserStatsWidget.vue"; import UserList from "./UserList.vue"; import UserDetail from "./UserDetail.vue"; @@ -34,45 +33,32 @@ export default definePlugin({ }, { path: "/users", - component: BlankLayout, + component: BasicLayout, children: [ { path: "", - component: BasicLayout, - children: [ - { - path: "", - name: "Users", - component: UserList, - meta: { - title: "core.user.title", - searchable: true, - permissions: ["system:users:view"], - menu: { - name: "core.sidebar.menu.items.users", - group: "system", - icon: markRaw(IconUserSettings), - priority: 1, - mobile: true, - }, - }, + name: "Users", + component: UserList, + meta: { + title: "core.user.title", + searchable: true, + permissions: ["system:users:view"], + menu: { + name: "core.sidebar.menu.items.users", + group: "system", + icon: markRaw(IconUserSettings), + priority: 1, + mobile: true, }, - ], + }, }, { path: ":name", - component: BasicLayout, - name: "User", - children: [ - { - path: "", - name: "UserDetail", - component: UserDetail, - meta: { - title: "core.user.detail.title", - }, - }, - ], + name: "UserDetail", + component: UserDetail, + meta: { + title: "core.user.detail.title", + }, }, ], }, diff --git a/console/console-src/setup/setupModules.ts b/console/console-src/setup/setupModules.ts index bfab108a7c..f850062611 100644 --- a/console/console-src/setup/setupModules.ts +++ b/console/console-src/setup/setupModules.ts @@ -1,5 +1,5 @@ import { i18n } from "@/locales"; -import { coreModules } from "@console/modules"; +import modules from "@console/modules"; import router from "@console/router"; import { usePluginModuleStore } from "@/stores/plugin"; import type { PluginModule, RouteRecordAppend } from "@halo-dev/console-shared"; @@ -10,7 +10,7 @@ import type { RouteRecordRaw } from "vue-router"; import { loadStyle } from "@/utils/load-style"; export function setupCoreModules(app: App) { - coreModules.forEach((module) => { + modules.forEach((module) => { registerModule(app, module, true); }); }