| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- import Vue from "vue";
- import App from "./App.vue";
- import ElementUI from "element-ui";
- import store from "./store";
- import router from "./router";
- import axios from "axios";
- import api from "./http/api";
- import "./http/common/base";
- import { debounce } from "./utils/common";
- import * as echarts from "echarts";
- import "@/styles/element-variables.scss";
- // 引入vxe-table
- import VXETable from 'vxe-table';
- import 'vxe-table/lib/style.css';
- import "@/styles/common.scss";
- import "font-awesome/css/font-awesome.min.css";
- import './styles/XueKeWangQuestionStyles.css'
- import './assets/font2/iconfont.css'
- Vue.use(VXETable);
- // 解决el-radio报错
- Vue.directive('removeAriaHidden', {
- bind(el, binding) {
- let ariaEls = el.querySelectorAll('.el-radio__original');
- ariaEls.forEach((item) => {
- item.removeAttribute('aria-hidden');
- });
- }
- });
- import Header from "@/views/layout/components/Header.vue";
- import Footer from "@/views/layout/components/Footer.vue";
- Vue.component("Header", Header);
- Vue.component("Footer", Footer);
- import InfiniteLoading from "vue-infinite-loading";
- import lottie from "vue-lottie";
- import global from "@/utils/global.js";
- import envFeature from "@/utils/envFeature.js";
- Vue.prototype.$global = global;
- // 环境显隐:组件内无需 import,直接用 this.$feature.isShow() / isHide()
- Vue.prototype.$feature = envFeature;
- Vue.use(InfiniteLoading);
- Vue.component("lottie", lottie);
- const _ResizeObserver = window.ResizeObserver;
- ElementUI.Dialog.props.closeOnClickModal.default = false;
- window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
- constructor(callback) {
- callback = debounce(callback, 16);
- super(callback);
- }
- };
- Vue.config.productionTip = false;
- Vue.use(ElementUI, {
- table: {
- resizable: false,
- },
- });
- Vue.prototype.$axios = axios;
- Vue.prototype.$api = api;
- Vue.prototype.$echarts = echarts;
- //=======从pad App接收消息 start
- window.receiveAppMsg = function(payload) {
- console.log('【网页收到壳消息】', payload)
- if (!payload || !payload.type) return
- switch (payload.type) {
- case 'setToken':
- window.__IS_PAD_APP__ = true;
- window.__PAD_APP_TOKEN__ = payload.token;// 保存token到全局变量
- const rootEl = document.querySelector('#app') // vue项目根容器
- const cls = 'pad_container_layout';// pad容器样式
- if (rootEl && !rootEl.classList.contains(cls)) {
- rootEl.classList.add(cls)
- }
- // if (payload.token) {
- // axios.defaults.headers.common['Authorization'] = `${payload.token}`
- // }
- // 触发自定义事件,通知登录页面token准备好了!
- const tokenReadyEvent = new CustomEvent('padAppTokenReady', {
- detail: { token: payload.token }
- })
- window.dispatchEvent(tokenReadyEvent)
- break
- case 'goPage':
- router.push(payload.path)
- break
- case 'openHeaderDropdown':
- // 通知 Header 组件打开用户下拉(el-dropdown)弹框
- window.dispatchEvent(new CustomEvent('openHeaderDropdown'))
- break
- default:
- // console.log('未知消息类型', payload)
- break
- }
- }
- // H5 iframe监听壳消息
- window.addEventListener('message', function(e) {
- // console.log('【收到壳消息】', JSON.stringify(e.data))
- // ==========重点:APP‑PLUS环境直接退出,不要处理postMessage消息==========
- // uni-app webview中,window.plus 存在代表是安卓/ios app环境
- if(window.plus){
- console.log("【APP环境,跳过postMessage消息】")
- return
- }
- // 过滤webpack内部热更新消息
- if (e.data?.type === 'webpackWarnings' || e.data?.type === 'webpackHotUpdate') {
- return
- }
- // 白名单,只允许这些域名发送消息
- const baseUrl = process.env.VUE_APP_BASE;
- const allowOrigin = [
- 'http://localhost:8080',
- 'http://192.168.1.18:8080',
- baseUrl
- ];
- if (!allowOrigin.includes(e.origin)) return
- const data = e.data;
- if (!data || !data.type) return
- window.receiveAppMsg(data)
- })
- //=======从pad App接收消息 end
- new Vue({
- el: "#app",
- router,
- store,
- render: (h) => h(App),
- });
|