| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import './public-path';
- import Vue from 'vue';
- import EleAdmin from 'ele-admin';
- import VueClipboard from 'vue-clipboard2';
- import App from './App.vue';
- import router, { resetRouter } from './router';
- import store from './store';
- import permission from './utils/permission';
- import initParentStore from '../qiankun_config/store';
- import i18n from './i18n';
- import { MAP_KEY, LICENSE_CODE, SYSTEM_NAME } from '@/config/setting';
- import { installMessageGuard } from '@/utils/message';
- import HeaderTitle from '@/components/header-title';
- import DictSelection from '@/components/Dict/DictSelection';
- import fileMain from '@/components/addDoc/index.vue';
- import clickOnce from '@/utils/clickOnce';
- import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
- import '@/components/bpmnProcessDesigner/package/theme/viewer.scss';
- import 'bpmn-js/dist/assets/diagram-js.css';
- import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
- import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
- import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
- import 'nprogress/nprogress.css';
- import './styles/index.scss';
- // 独立运行标记:样式仅在该 class 下接管 html/body,避免乾坤冲掉主应用侧栏
- if (!window.__POWERED_BY_QIANKUN__) {
- document.documentElement.classList.add('hr-standalone');
- }
- Vue.config.productionTip = false;
- Vue.directive('click-once', clickOnce);
- Vue.component('HeaderTitle', HeaderTitle);
- Vue.component('DictSelection', DictSelection);
- Vue.component('fileMain', fileMain);
- Vue.use(MyPD);
- Vue.use(permission);
- Vue.use(EleAdmin, {
- response: {
- dataName: 'list',
- },
- mapKey: MAP_KEY,
- license: LICENSE_CODE,
- i18n: (key, value) => i18n.t(key, value),
- });
- Vue.use(VueClipboard);
- installMessageGuard(Vue);
- function disableOverlayClose(componentName) {
- const component = Vue.options.components[componentName];
- if (!component) return;
- const options = component.options || component;
- const props = options.props;
- if (!props) return;
- if (props.closeOnClickModal) props.closeOnClickModal.default = false;
- if (props.wrapperClosable) props.wrapperClosable.default = false;
- }
- ['ElDialog', 'ElDrawer', 'EleModal'].forEach(disableOverlayClose);
- function wrapMessageBox(method) {
- const original = Vue.prototype[method];
- if (typeof original !== 'function') return;
- Vue.prototype[method] = function (message, title, options) {
- if (title !== null && typeof title === 'object') {
- options = title;
- title = undefined;
- }
- const nextOptions = { ...(options || {}), closeOnClickModal: false };
- if (title === undefined) {
- return original.call(this, message, nextOptions);
- }
- return original.call(this, message, title, nextOptions);
- };
- }
- ['$msgbox', '$confirm', '$prompt'].forEach(wrapMessageBox);
- let instance = null;
- function render(props = {}) {
- const { container, parentWindow } = props;
- if (parentWindow) {
- window.parentWindow = parentWindow;
- }
- instance = new Vue({
- router,
- store,
- i18n,
- render: (h) => h(App),
- }).$mount(container ? container.querySelector('#app') : '#app');
- }
- if (!window.__POWERED_BY_QIANKUN__) {
- render();
- }
- export async function bootstrap() {
- console.info('[page-hr] bootstrap');
- }
- export async function mount(props) {
- console.log('[page-hr] props from main framework', props);
- Vue.prototype.$portalStore = props.store;
- // 与 EOM 一致:只同步主题/用户,绝不改门户 menus
- initParentStore(props.store?.state || props.store);
- if (typeof props.onGlobalStateChange === 'function') {
- props.onGlobalStateChange((state) => {
- initParentStore(state);
- });
- }
- // 乾坤下强制校正 router base 为 /page-hr/
- if (
- window.__POWERED_BY_QIANKUN__ &&
- !String(router.options?.base || '').includes(`page-${SYSTEM_NAME}`)
- ) {
- resetRouter();
- }
- render(props);
- }
- export async function unmount() {
- if (instance) {
- instance.$destroy();
- instance.$el.innerHTML = '';
- }
- instance = null;
- }
|