2022-03-03 10:26:15 +00:00
|
|
|
import { createApp } from "vue";
|
|
|
|
import { createPinia } from "pinia";
|
|
|
|
import App from "./App.vue";
|
|
|
|
import router from "./router";
|
2022-06-17 06:12:15 +00:00
|
|
|
import type { Plugin } from "@halo-dev/admin-shared";
|
2022-06-16 09:01:18 +00:00
|
|
|
// setup
|
|
|
|
import "./setup/setupStyles";
|
|
|
|
import { setupComponents } from "./setup/setupComponents";
|
2022-06-17 06:12:15 +00:00
|
|
|
import { registerMenu } from "@/router/menus.config";
|
|
|
|
|
|
|
|
// modules
|
|
|
|
import dashboardModule from "./modules/dashboard/module";
|
|
|
|
import postModule from "./modules/contents/posts/module";
|
|
|
|
import sheetModule from "./modules/contents/sheets/module";
|
|
|
|
import commentModule from "./modules/contents/comments/module";
|
|
|
|
import attachmentModule from "./modules/contents/attachments/module";
|
|
|
|
import themeModule from "./modules/interface/themes/module";
|
|
|
|
import menuModule from "./modules/interface/menus/module";
|
|
|
|
import pluginModule from "./modules/system/plugins/module";
|
|
|
|
import userModule from "./modules/system/users/module";
|
|
|
|
import roleModule from "./modules/system/roles/module";
|
|
|
|
import settingModule from "./modules/system/settings/module";
|
|
|
|
|
|
|
|
const app = createApp(App);
|
2022-03-03 10:26:15 +00:00
|
|
|
|
2022-06-16 09:01:18 +00:00
|
|
|
setupComponents(app);
|
2022-05-26 09:37:08 +00:00
|
|
|
|
2022-06-16 09:01:18 +00:00
|
|
|
app.use(createPinia());
|
2022-05-26 09:37:08 +00:00
|
|
|
|
2022-06-17 06:12:15 +00:00
|
|
|
async function registerModule(pluginModule: Plugin) {
|
|
|
|
if (pluginModule.components) {
|
|
|
|
for (const component of pluginModule.components) {
|
|
|
|
component.name && app.component(component.name, component);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginModule.routes) {
|
|
|
|
for (const route of pluginModule.routes) {
|
|
|
|
router.addRoute(route);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginModule.menus) {
|
|
|
|
for (const group of pluginModule.menus) {
|
|
|
|
for (const menu of group.items) {
|
|
|
|
registerMenu(group.name, menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadCoreModules() {
|
2022-06-17 07:00:14 +00:00
|
|
|
Array.from<Plugin>([
|
2022-06-17 06:12:15 +00:00
|
|
|
dashboardModule,
|
|
|
|
postModule,
|
|
|
|
sheetModule,
|
|
|
|
commentModule,
|
|
|
|
attachmentModule,
|
|
|
|
themeModule,
|
|
|
|
menuModule,
|
|
|
|
pluginModule,
|
|
|
|
userModule,
|
|
|
|
roleModule,
|
|
|
|
settingModule,
|
2022-06-17 07:00:14 +00:00
|
|
|
]).forEach(registerModule);
|
2022-06-17 06:12:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadPluginModules() {
|
|
|
|
// TODO: load plugin modules
|
|
|
|
}
|
|
|
|
|
|
|
|
initApp();
|
|
|
|
|
|
|
|
async function initApp() {
|
|
|
|
loadCoreModules();
|
|
|
|
loadPluginModules();
|
|
|
|
app.use(router);
|
|
|
|
app.mount("#app");
|
|
|
|
}
|