feat: use definePlugin function to define a plugin object

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/583/head
Ryan Wang 2022-06-17 15:00:14 +08:00
parent 8bc6ff798e
commit 515ec78842
14 changed files with 41 additions and 57 deletions

View File

@ -0,0 +1,5 @@
import type { Plugin } from "@/types/plugin";
export function definePlugin(plugin: Plugin): Plugin {
return plugin;
}

View File

@ -1,2 +1,3 @@
export * from "./types/plugin"; export * from "./types/plugin";
export * from "./types/menus"; export * from "./types/menus";
export * from "./core/plugins";

View File

@ -50,7 +50,7 @@ async function registerModule(pluginModule: Plugin) {
} }
function loadCoreModules() { function loadCoreModules() {
[ Array.from<Plugin>([
dashboardModule, dashboardModule,
postModule, postModule,
sheetModule, sheetModule,
@ -62,7 +62,7 @@ function loadCoreModules() {
userModule, userModule,
roleModule, roleModule,
settingModule, settingModule,
].forEach(registerModule); ]).forEach(registerModule);
} }
function loadPluginModules() { function loadPluginModules() {

View File

@ -1,9 +1,9 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import AttachmentList from "./AttachmentList.vue"; import AttachmentList from "./AttachmentList.vue";
import { IconFolder } from "@halo-dev/components"; import { IconFolder } from "@halo-dev/components";
const attachmentModule: Plugin = { export default definePlugin({
name: "attachmentModule", name: "attachmentModule",
components: [], components: [],
routes: [ routes: [
@ -31,6 +31,4 @@ const attachmentModule: Plugin = {
], ],
}, },
], ],
}; });
export default attachmentModule;

View File

@ -1,9 +1,9 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import { IconMessage } from "@halo-dev/components"; import { IconMessage } from "@halo-dev/components";
import CommentList from "./CommentList.vue"; import CommentList from "./CommentList.vue";
const commentModule: Plugin = { export default definePlugin({
name: "commentModule", name: "commentModule",
components: [], components: [],
routes: [ routes: [
@ -31,6 +31,4 @@ const commentModule: Plugin = {
], ],
}, },
], ],
}; });
export default commentModule;

View File

@ -1,4 +1,4 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout, BlankLayout } from "@/layouts"; import { BasicLayout, BlankLayout } from "@/layouts";
import { IconBookRead } from "@halo-dev/components"; import { IconBookRead } from "@halo-dev/components";
import PostList from "./PostList.vue"; import PostList from "./PostList.vue";
@ -6,7 +6,7 @@ import PostEditor from "./PostEditor.vue";
import CategoryList from "./categories/CategoryList.vue"; import CategoryList from "./categories/CategoryList.vue";
import TagList from "./tags/TagList.vue"; import TagList from "./tags/TagList.vue";
const postModule: Plugin = { export default definePlugin({
name: "postModule", name: "postModule",
components: [], components: [],
routes: [ routes: [
@ -61,6 +61,4 @@ const postModule: Plugin = {
], ],
}, },
], ],
}; });
export default postModule;

View File

@ -1,9 +1,9 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import SheetList from "./SheetList.vue"; import SheetList from "./SheetList.vue";
import { IconPages } from "@halo-dev/components"; import { IconPages } from "@halo-dev/components";
const sheetModule: Plugin = { export default definePlugin({
name: "sheetModule", name: "sheetModule",
components: [], components: [],
routes: [ routes: [
@ -31,6 +31,4 @@ const sheetModule: Plugin = {
], ],
}, },
], ],
}; });
export default sheetModule;

View File

@ -1,4 +1,4 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import Dashboard from "./Dashboard.vue"; import Dashboard from "./Dashboard.vue";
import { IconDashboard } from "@halo-dev/components"; import { IconDashboard } from "@halo-dev/components";
@ -12,7 +12,7 @@ import RecentPublishedWidget from "./widgets/RecentPublishedWidget.vue";
import UserStatsWidget from "./widgets/UserStatsWidget.vue"; import UserStatsWidget from "./widgets/UserStatsWidget.vue";
import ViewsStatsWidget from "./widgets/ViewsStatsWidget.vue"; import ViewsStatsWidget from "./widgets/ViewsStatsWidget.vue";
const dashboardModule: Plugin = { export default definePlugin({
name: "dashboardModule", name: "dashboardModule",
components: [ components: [
CommentStatsWidget, CommentStatsWidget,
@ -50,6 +50,4 @@ const dashboardModule: Plugin = {
], ],
}, },
], ],
}; });
export default dashboardModule;

View File

@ -1,9 +1,9 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import MenuList from "./MenuList.vue"; import MenuList from "./MenuList.vue";
import { IconListSettings } from "@halo-dev/components"; import { IconListSettings } from "@halo-dev/components";
const menuModule: Plugin = { export default definePlugin({
name: "menuModule", name: "menuModule",
components: [], components: [],
routes: [ routes: [
@ -31,6 +31,4 @@ const menuModule: Plugin = {
], ],
}, },
], ],
}; });
export default menuModule;

View File

@ -1,10 +1,10 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout, BlankLayout } from "@/layouts"; import { BasicLayout, BlankLayout } from "@/layouts";
import ThemeDetail from "./ThemeDetail.vue"; import ThemeDetail from "./ThemeDetail.vue";
import Visual from "./Visual.vue"; import Visual from "./Visual.vue";
import { IconPalette } from "@halo-dev/components"; import { IconPalette } from "@halo-dev/components";
const themeModule: Plugin = { export default definePlugin({
name: "themeModule", name: "themeModule",
components: [], components: [],
routes: [ routes: [
@ -43,6 +43,4 @@ const themeModule: Plugin = {
], ],
}, },
], ],
}; });
export default themeModule;

View File

@ -1,10 +1,10 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import PluginList from "./PluginList.vue"; import PluginList from "./PluginList.vue";
import PluginDetail from "./PluginDetail.vue"; import PluginDetail from "./PluginDetail.vue";
import { IconPlug } from "@halo-dev/components"; import { IconPlug } from "@halo-dev/components";
const pluginModule: Plugin = { export default definePlugin({
name: "pluginModule", name: "pluginModule",
components: [], components: [],
routes: [ routes: [
@ -37,6 +37,4 @@ const pluginModule: Plugin = {
], ],
}, },
], ],
}; });
export default pluginModule;

View File

@ -1,9 +1,9 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout } from "@/layouts"; import { BasicLayout } from "@/layouts";
import RoleList from "./RoleList.vue"; import RoleList from "./RoleList.vue";
import RoleDetail from "./RoleDetail.vue"; import RoleDetail from "./RoleDetail.vue";
const roleModule: Plugin = { export default definePlugin({
name: "roleModule", name: "roleModule",
components: [], components: [],
routes: [ routes: [
@ -25,6 +25,4 @@ const roleModule: Plugin = {
}, },
], ],
menus: [], menus: [],
}; });
export default roleModule;

View File

@ -1,10 +1,10 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { SystemSettingsLayout } from "@/layouts"; import { SystemSettingsLayout } from "@/layouts";
import GeneralSettings from "./GeneralSettings.vue"; import GeneralSettings from "./GeneralSettings.vue";
import NotificationSettings from "./NotificationSettings.vue"; import NotificationSettings from "./NotificationSettings.vue";
import { IconSettings } from "@halo-dev/components"; import { IconSettings } from "@halo-dev/components";
const settingModule: Plugin = { export default definePlugin({
name: "settingModule", name: "settingModule",
components: [], components: [],
routes: [ routes: [
@ -38,6 +38,4 @@ const settingModule: Plugin = {
], ],
}, },
], ],
}; });
export default settingModule;

View File

@ -1,4 +1,4 @@
import type { Plugin } from "@halo-dev/admin-shared"; import { definePlugin } from "@halo-dev/admin-shared";
import { BasicLayout, BlankLayout, UserProfileLayout } from "@/layouts"; import { BasicLayout, BlankLayout, UserProfileLayout } from "@/layouts";
import UserList from "./UserList.vue"; import UserList from "./UserList.vue";
import UserDetail from "./UserDetail.vue"; import UserDetail from "./UserDetail.vue";
@ -7,7 +7,7 @@ import PasswordChange from "./PasswordChange.vue";
import PersonalAccessTokens from "./PersonalAccessTokens.vue"; import PersonalAccessTokens from "./PersonalAccessTokens.vue";
import { IconUserSettings } from "@halo-dev/components"; import { IconUserSettings } from "@halo-dev/components";
const userModule: Plugin = { export default definePlugin({
name: "userModule", name: "userModule",
components: [], components: [],
routes: [ routes: [
@ -68,6 +68,4 @@ const userModule: Plugin = {
], ],
}, },
], ],
}; });
export default userModule;