123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { createApp } from "vue";
- import App from "@/App.vue";
- import router from "@/router";
- import store from "@/store";
- import { isMicroApp } from "@/config";
- import microApp from "@micro-zoe/micro-app";
- // @kasite/intelmt-plus 弹窗和loading单独引入
- import { ElMessage, ElLoading } from "@kasite/element-plus";
- import "@kasite/element-plus/theme-chalk/base.css";
- import "@kasite/element-plus/theme-chalk/display.css";
- import "@kasite/element-plus/theme-chalk/el-overlay.css";
- import "@kasite/element-plus/theme-chalk/el-message.css";
- import "@kasite/element-plus/theme-chalk/el-message-box.css";
- import "@kasite/element-plus/theme-chalk/el-loading.css";
- import ZyAdminComponents from "@kasite/intelmt-admin/components";
- import toolEntry from "@/utils/tool-entry";
- import interfaceEntry from "@/service/interface-entry";
- // px转rem
- import "@kasite/intelmt-admin/utils/tool/px2rem";
- const app = createApp(App);
- app.config.globalProperties.$ELEMENT = { size: "default" };
- app.config.globalProperties.$message = ElMessage;
- app.config.globalProperties.$messageBox = toolEntry.common.messageBox;;
- app.config.globalProperties.$loading = ElLoading;
- app.config.globalProperties.$store = store;
- app.config.globalProperties.$toolEntry = toolEntry;
- app.config.globalProperties.$interfaceEntry = interfaceEntry;
- import * as ElementPlusIconsVue from "@element-plus/icons-vue";
- for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
- app.component(`el-icon${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`, component as any);
- }
- app.use(store).use(router).use(ZyAdminComponents).mount("#app");
- // 启用微前端嵌入别的页面
- if (isMicroApp) {
- microApp.start({
- tagName: `micro-app-demo`
- });
- }
- // 如果是微前端
- if (window.__MICRO_APP_ENVIRONMENT__) {
- // eslint-disable-next-line
- __webpack_public_path__ = window.__MICRO_APP_PUBLIC_PATH__;
- // 重定向
- const data = window.microApp.getData();
- if(data.redirect) {
- // 如果绑定的重定向数据发生变化,路由进行跳转
- window.microApp.addDataListener(() => {
- const {redirect} = window.microApp.getData()
- redirect && router.push({ path: redirect });
- })
- }
- router.push({ path: data.redirect || window.config.index });
- // 监听卸载操作
- window.addEventListener("unmount", function () {
- app.unmount();
- });
- }
- // 如果是iframe
- else {
- window.addEventListener("load", () => {
- setTimeout(() => {
- if (window.__INTERMT_IFRAME__) {
- app.config.globalProperties.$frameEntry = window.$frameEntry;
- }
- }, 0);
- });
- }
|