Files
cost-frontend/src/main.js
T

87 lines
2.1 KiB
JavaScript
Raw Normal View History

2024-06-12 09:50:18 +08:00
import { createApp } from "vue";
import "./assets/styles/tailwind.css";
import Cookies from "js-cookie";
import "@/utils/flexible.js";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import locale from "element-plus/es/locale/lang/zh-cn";
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
import "@/assets/styles/index.scss";
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
import App from "./App";
import store from "./store";
import router from "./router";
import directive from "./directive"; // directive
import { qomoPlatformOptions } from "./platform";
import QomoPlatform from "@qomo-platform/core";
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
// 注册指令
import plugins from "./plugins"; // plugins
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
import {
renderWithQiankun,
qiankunWindow
} from "vite-plugin-qiankun/dist/helper";
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
// svg图标
import "virtual:svg-icons-register";
import usePermissionStore from "@/store/modules/permission";
import "@/assets/styles/global.css";
2024-07-10 09:43:43 +08:00
import FlowableComponents from "@/flowableComponents/index.ts"
2024-06-12 09:50:18 +08:00
let app;
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
function render(props = {}) {
const { container } = props;
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
app = createApp(App);
app.use(store);
usePermissionStore()
.generateRoutes()
.then(routes => {
routes.forEach(route => {
if (!isHttp(route.path)) {
router.addRoute(route); // 动态添加可访问路由表
}
});
app.use(router);
app.use(plugins);
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
app.use(QomoPlatform, qomoPlatformOptions);
2024-07-10 09:43:43 +08:00
app.use(FlowableComponents);
2024-06-12 09:50:18 +08:00
directive(app);
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
2024-07-01 10:03:53 +08:00
name:'testApp',
2024-06-12 09:50:18 +08:00
locale: locale,
// 支持 large、default、small
size: Cookies.get("size") || "default"
});
2024-06-03 14:52:58 +08:00
2024-06-12 09:50:18 +08:00
app.mount(container ? container.querySelector("#subApp") : "#subApp");
});
}
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
render();
} else {
renderWithQiankun({
mount(props) {
console.log("===mount===");
render(props);
},
bootstrap() {
console.log("===bootstrap===");
},
unmount(props) {
console.log(app);
console.log("===unmount===");
const { container } = props;
app.unmount();
},
update(props) {
console.log("===update===", props);
}
});
}