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


    目前在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
  • 相关阅读:
    apache+tomcat分布式搭建
    maven 加入本地jar包
    一步一步搭建Jenkins环境
    缓存详解
    nginx配置文件注释
    mybatis like的用法
    Golang聊天室
    windows 10安装gensim、nltk
    理解矩阵乘法
    超赞的 Go 语言 INI 文件操作
  • 原文地址:https://www.cnblogs.com/lsc-boke/p/11739032.html
Copyright © 2020-2023  润新知