new webpack.ProvidePlugin vue模块化的全局引用

流过昼夜 提交于 2019-12-02 08:48:39

目前在vue-cli2运用

webpack.base.conf.js

new webpack.ProvidePlugin({
      jQuery: 'jquery',
      $: 'jquery',
      Gdata: ['@/api/index.js', 'default'],
      RequestApi: resolve('/static/config/index.js')
    })
static/config/index.js
const peconfig = 'devCompXs';
switch (peconfig) {
  case 'devPloce':
    var DUTY_URL_INTERNET = '//10.95.1.210:10021';
    var WEBSOCKET_INTERNET = 'ws://10.95.1.210:10021/commonwebsocket/channels/test';
    var MAPCONTROL_SOCKET_INTERNET = 'ws://10.95.1.210:10021/websocket/mapControl/127.0.0.1'; //这条目前没有业务用注释着
    var VIDEO_SOCKET_INTERNET = 'ws://10.95.1.210:10021/websocket/vidoControl/127.0.0.1';
    var MESSAGE_SOCKET_INTERNET = 'ws://10.95.1.210:10021/websocket/message/127.0.0.1'; //这条目前没有业务用注释着
    //其他资源
    var MAP_URL_INTERNET = 'http://114.215.146.210:25003/v3/tile?z={z}&x={x}&y={y}';
    var TRAFFIC_URL_INTERNET =
      'https://api.mapbox.com/styles/v1/banterise/cjhvkka84004g2rpn9cw8ng90/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYmFudGVyaXNlIiwiYSI6ImNpaXNrNzRidjAzOGZ2NG01d3ozcmt6cW4ifQ.V--rLvOufK9nTJdRoAm_Pw';

    var VIDEOWPZ = 'http://10.168.31.222/download/VideoWebPlugin.exe';
    var MAPCONFIG_INTERNET = {
      center: [34.2778, 108.953098],
      zoom: 13
    };
    break;
  case 'devCompBd':
    var DUTY_URL_INTERNET = '//10.168.31.96:10021';
    var WEBSOCKET_INTERNET = 'ws://10.168.31.96:10021/commonwebsocket/channels/test';
    var MAPCONTROL_SOCKET_INTERNET = 'ws://10.168.31.96:10021/websocket/mapControl/127.0.0.1';
    var VIDEO_SOCKET_INTERNET = 'ws://10.168.31.96:10021/websocket/vidoControl/127.0.0.1';
    var MESSAGE_SOCKET_INTERNET = 'ws://10.168.31.96:10021/websocket/message/127.0.0.1';
    //其他资源
    var MAP_URL_INTERNET = 'http://114.215.146.210:25003/v3/tile?z={z}&x={x}&y={y}';
    var TRAFFIC_URL_INTERNET =
      'https://api.mapbox.com/styles/v1/banterise/cjhvkka84004g2rpn9cw8ng90/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYmFudGVyaXNlIiwiYSI6ImNpaXNrNzRidjAzOGZ2NG01d3ozcmt6cW4ifQ.V--rLvOufK9nTJdRoAm_Pw';

    var VIDEOWPZ = 'http://10.168.31.222/download/VideoWebPlugin.exe';
    var MAPCONFIG_INTERNET = {
      center: [34.2778, 108.953098],
      zoom: 13
    };
    break;
  case 'devCompXs':
    var DUTY_URL_INTERNET = '//10.168.31.3:9111';
    var WEBSOCKET_INTERNET = 'ws://10.168.31.3:9111/commonwebsocket/channels/test';
    var MAPCONTROL_SOCKET_INTERNET = 'ws://10.168.31.3:9111/websocket/mapControl/127.0.0.1';
    var VIDEO_SOCKET_INTERNET = 'ws://10.168.31.3:9111/websocket/vidoControl/127.0.0.1';
    var MESSAGE_SOCKET_INTERNET = 'ws://10.168.31.3:9111/websocket/message/127.0.0.1';
    //其他资源
    var MAP_URL_INTERNET = 'http://114.215.146.210:25003/v3/tile?z={z}&x={x}&y={y}';
    var TRAFFIC_URL_INTERNET =
      'https://api.mapbox.com/styles/v1/banterise/cjhvkka84004g2rpn9cw8ng90/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiYmFudGVyaXNlIiwiYSI6ImNpaXNrNzRidjAzOGZ2NG01d3ozcmt6cW4ifQ.V--rLvOufK9nTJdRoAm_Pw';

    var VIDEOWPZ = 'http://10.168.31.222/download/VideoWebPlugin.exe';
    var MAPCONFIG_INTERNET = {
      center: [34.2778, 108.953098],
      zoom: 13
    };
    break;
  case 'production':
    var DUTY_URL_INTERNET = '//10.95.1.120:10011'; //服务地址
    var WEBSOCKET_INTERNET = 'ws://10.95.1.120:10011/commonwebsocket/channels/test'; //实车socket
    var MAPCONTROL_SOCKET_INTERNET = 'ws://10.95.1.120:10011/websocket/mapControl/127.0.0.1';
    var VIDEO_SOCKET_INTERNET = 'ws://10.95.1.120:10011/websocket/vidoControl/127.0.0.1'; //4分屏前三个socket
    var MESSAGE_SOCKET_INTERNET = 'ws://10.95.1.120:10011/websocket/message/127.0.0.1';
    var VIDEOWPZ = 'http://10.95.1.120:9111/VideoWebPlugin.exe'; //下载视频资源

    var TRAFFIC_URL_INTERNET = 'http://114.215.146.210:25003/v3/tile?z={z}&x={x}&y={y}';
    var MAP_URL_INTERNET = 'http://10.95.1.104/xian/m/{z}/{x}/{y}.png';

    var MAPCONFIG_INTERNET = {
      center: [34.2778, 108.953098],
      zoom: 13
    };
    break;
}

export {
  DUTY_URL_INTERNET, // 配置服务器地址,
  WEBSOCKET_INTERNET,
  MAPCONTROL_SOCKET_INTERNET,
  VIDEO_SOCKET_INTERNET,
  MESSAGE_SOCKET_INTERNET,
  MAP_URL_INTERNET,
  TRAFFIC_URL_INTERNET,
  VIDEOWPZ,
  MAPCONFIG_INTERNET
};
View Code

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!