Qiankun Micro Frontend Checker (micro/index.ts)

JeecgBoot · jeecgboot-vue3/src/qiankun/micro/index.ts · typescript · Apache-2.0
infra, tag:qiankun, tag:microfrontend, tag:window, tag:check

Utility functions to check if the app is running as a Qiankun micro frontend and to get the global window object.

// Source: https://github.com/jeecgboot/JeecgBoot | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import {qiankunWindow} from 'vite-plugin-qiankun/dist/helper'

/**
 * 【JEECG作为乾坤子应用】【判断当前是否是以乾坤子应用的模式运行】
 */
export function checkIsQiankunMicro(): boolean {
  return !!qiankunWindow.__POWERED_BY_QIANKUN__;
}

export function getGlobal() {
  return (checkIsQiankunMicro() ? qiankunWindow : window) as Window
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key