主頁 > 企業開發 > photo-sphere-viewer.js實作全景圖

photo-sphere-viewer.js實作全景圖

2021-01-30 06:54:38 企業開發

photo-sphere-viewer.js是一個基于three.js的全景插件

1、能添加熱點;
2、能呼叫陀螺儀;
3、操作簡單,提供一張全景圖片即可(大多數手機都可以拍攝)

 

官網:https://photo-sphere-viewer.js.org/

使用方法很簡單,直接去官網參考example和api使用檔案,github上下載原始碼即可,

建議不要找網上的,版本太老,api用法都不太一樣了,功能也沒有新版的完善,

 

1、直接訪問全景圖(移動端自動呼叫陀螺儀)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全景圖基礎版-自動呼叫陀螺儀/title>
    
    <link rel="stylesheet" href="libs/photo-sphere-viewer.min.css"/>
    <script src="libs/three.min.js"></script>
    <script src="libs/browser.min.js"></script>
    <script src="libs/photo-sphere-viewer.min.js"></script>
    <script src="libs/gyroscope.js"></script>
    
    <div id="viewer"></div>
    
    <style>
      /* the viewer container must have a defined size */
      *{
          margin:0;
          padding:0;
      }
      #viewer {
        width: 100vw;
        height: 100vh;
      }
    </style>
    
    <script>var viewer = new PhotoSphereViewer.Viewer({
            container: document.querySelector('#viewer'),
            panorama: 'budi.jpg',
            plugins: [
                PhotoSphereViewer.GyroscopePlugin,
            ],
            lang: {
                gyroscope : 'Gyroscope',
            },
        });
      
        // 如果是移動端
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
            viewer.once('ready', function(){
                document.querySelector('.psv-gyroscope-button').click();
            });
        }
    </script>
</body>

</html>

 注意:Photo Sphere Viewer的陀螺儀必須在https下才能開啟,否則無效!!!

 

2、使用iframe訪問全景圖

這種情況下存在跨域iframe問題,需要使用post message進行父子組件通信

(1)【父組件】iframe.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全景圖跨域iframe版-子組件</title>
    
    <style>
        *{
            margin:0;
            padding:0;
        }
        html,body,iframe {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <iframe id="iframe" frameborder="no" border="0" marginwidth="0" marginheight="0" src="https://xxx.xxx.com/vr.html" scrolling="no"  allowTransparency="true"></iframe>

    <script>
    
    if (window.DeviceOrientationEvent) {
        window.addEventListener("deviceorientation", handleOrientation, false); // 組件iframe層  -- VR iframe層
    } else {
        alert("您的瀏覽器不支持HTML5 DeviceOrientation介面");
    }

    function handleOrientation(orientData){
        var absolute = orientData.absolute;
        var alpha = orientData.alpha;
        var beta = orientData.beta;
        var gamma = orientData.gamma;

        // Do stuff with the new orientation data
        var val = {
            "act": "gyroscope",
            "val": {
                alpha: alpha,
                beta: beta,
                gamma: gamma
            }
        };
        //獲取iframe
        var ifr = document.querySelector('#iframe');

        //iframe的路徑
        var url = 'https://xxx.xxx.com/vr.html';
        ifr.contentWindow.postMessage(JSON.stringify(val), url);
    }
    </script>
</body>

</html>

 

 

(2)【子組件】vr.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全景圖跨域iframe版-子組件</title>
    
    <link rel="stylesheet" href="libs/photo-sphere-viewer.min.css"/>
    <script src="libs/three.min.js"></script>
    <script src="libs/browser.min.js"></script>
    <script src="libs/photo-sphere-viewer.min.js"></script>
    <script src="libs/gyroscope.js"></script>
    
    <div id="viewer"></div>
    
    <style>
      /* the viewer container must have a defined size */
      *{
          margin:0;
          padding:0;
      }
      #viewer {
        width: 100vw;
        height: 100vh;
      }
    </style>
    
    <script>
        // 接收訊息
        if(top !== self) {
            window.parent.postMessage("gyroscope", '*');
        }
        
        window.onmessage = function(event) {
            var data = eval('(' + event.data + ')');
            if (data.act === 'gyroscope') {
                window.deviceOrientation = data.val;
            }
        }
        
        var viewer = new PhotoSphereViewer.Viewer({
            container: document.querySelector('#viewer'),
            panorama: 'budi.jpg',
            plugins: [
                PhotoSphereViewer.GyroscopePlugin,
            ],
            lang: {
                gyroscope : 'Gyroscope',
            },
        });
      
        // 如果是移動端
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
            viewer.once('ready', function(){
                document.querySelector('.psv-gyroscope-button').click();
            });
        }
    </script>
</body>

</html>

 

(3) 修改gyroscope.js (跟我需求一樣的小伙伴直接復制替換即可)

/*!
* Photo Sphere Viewer 4.1.0
* @copyright 2014-2015 Jérémy Heleine
* @copyright 2015-2021 Damien "Mistic" Sorel
* @licence MIT (https://opensource.org/licenses/MIT)
*/
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('photo-sphere-viewer'), require('three')) :
  typeof define === 'function' && define.amd ? define(['photo-sphere-viewer', 'three'], factory) :
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.PhotoSphereViewer = global.PhotoSphereViewer || {}, global.PhotoSphereViewer.GyroscopePlugin = factory(global.PhotoSphereViewer, global.THREE)));
}(this, (function (photoSphereViewer, THREE) { 'use strict';

  function _extends() {
    _extends = Object.assign || function (target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i];

        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }

      return target;
    };

    return _extends.apply(this, arguments);
  }

  function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    subClass.__proto__ = superClass;
  }

  function _assertThisInitialized(self) {
    if (self === void 0) {
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }

    return self;
  }

  /**
   * W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
   */

  var DeviceOrientationControls = function DeviceOrientationControls(object) {
    var scope = this;
    var changeEvent = {
      type: 'change'
    };
    var EPS = 0.000001;
    this.object = object;
    this.object.rotation.reorder('YXZ');
    this.enabled = true;
    this.deviceOrientation = {};
    this.screenOrientation = 0;
    this.alphaOffset = 0; // radians

    var onDeviceOrientationChangeEvent = function onDeviceOrientationChangeEvent(event) {
      scope.deviceOrientation = event;
    };

    var onScreenOrientationChangeEvent = function onScreenOrientationChangeEvent() {
      scope.screenOrientation = window.orientation || 0;
    }; // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''


    var setObjectQuaternion = function () {
      var zee = new THREE.Vector3(0, 0, 1);
      var euler = new THREE.Euler();
      var q0 = new THREE.Quaternion();
      var q1 = new THREE.Quaternion(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5)); // - PI/2 around the x-axis

      return function (quaternion, alpha, beta, gamma, orient) {
        euler.set(beta, alpha, -gamma, 'YXZ'); // 'ZXY' for the device, but 'YXZ' for us

        quaternion.setFromEuler(euler); // orient the device

        quaternion.multiply(q1); // camera looks out the back of the device, not the top

        quaternion.multiply(q0.setFromAxisAngle(zee, -orient)); // adjust for screen orientation
      };
    }();

    this.connect = function () {
      onScreenOrientationChangeEvent(); // run once on load
    //   onDeviceOrientationChangeEvent();
      // iOS 13+

    //   if (window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === 'function') {
    //     window.DeviceOrientationEvent.requestPermission().then(function (response) {
    //       if (response == 'granted') {
    //         window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false);
    //         window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);
    //       }
    //     }).catch(function (error) {
    //       console.error('THREE.DeviceOrientationControls: Unable to use DeviceOrientation API:', error);
    //     });
    //   } else {
    //     //   window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false);
    //     //   window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);
          
    //       if (top === self) {
    //           window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false);
    //           window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);
    //       }else{
              
    //       }
    //   }
      
      window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false);
      window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);

      scope.enabled = true;
    };

    this.disconnect = function () {
      window.removeEventListener('orientationchange', onScreenOrientationChangeEvent, false);
      window.removeEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);
      scope.enabled = false;
    };

    this.update = function () {
      var lastQuaternion = new THREE.Quaternion();
      return function () {
        if (scope.enabled === false) return;
        
        var device = scope.deviceOrientation;
        
        if (top !== self) {
            device = window.deviceOrientation;
        }
        
        if (device) {
          var alpha = device.alpha ? THREE.MathUtils.degToRad(device.alpha) + scope.alphaOffset : 0; // Z

          var beta = device.beta ? THREE.MathUtils.degToRad(device.beta) : 0; // X'

          var gamma = device.gamma ? THREE.MathUtils.degToRad(device.gamma) : 0; // Y''

          var orient = scope.screenOrientation ? THREE.MathUtils.degToRad(scope.screenOrientation) : 0; // O

          setObjectQuaternion(scope.object.quaternion, alpha, beta, gamma, orient);

          if (8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
            lastQuaternion.copy(scope.object.quaternion);
            scope.dispatchEvent(changeEvent);
          }
        }
      };
    }();

    this.dispose = function () {
      scope.disconnect();
    };

    this.connect();
  };

  DeviceOrientationControls.prototype = Object.create(THREE.EventDispatcher.prototype);
  DeviceOrientationControls.prototype.constructor = DeviceOrientationControls;

  var compass = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 100 100\"><path fill=\"currentColor\" d=\"M50 0a50 50 0 1 0 0 100A50 50 0 0 0 50 0zm0 88.81a38.86 38.86 0 0 1-38.81-38.8 38.86 38.86 0 0 1 38.8-38.82A38.86 38.86 0 0 1 88.82 50 38.87 38.87 0 0 1 50 88.81z\"/><path d=\"M72.07 25.9L40.25 41.06 27.92 74.12l31.82-15.18v-.01l12.32-33.03zM57.84 54.4L44.9 42.58l21.1-10.06-8.17 21.9z\"/><!--Created by iconoci from the Noun Project--></svg>\n";

  /**
   * @summary Navigation bar gyroscope button class
   * @extends PSV.buttons.AbstractButton
   * @memberof PSV.buttons
   */

  var GyroscopeButton = /*#__PURE__*/function (_AbstractButton) {
    _inheritsLoose(GyroscopeButton, _AbstractButton);

    /**
     * @param {PSV.components.Navbar} navbar
     */
    function GyroscopeButton(navbar) {
      var _this;

      _this = _AbstractButton.call(this, navbar, 'psv-button--hover-scale psv-gyroscope-button', true) || this;
      /**
       * @type {PSV.plugins.GyroscopePlugin}
       * @readonly
       * @private
       */

      _this.plugin = _this.psv.getPlugin(GyroscopePlugin.id);

      if (_this.plugin) {
        _this.plugin.on(GyroscopePlugin.EVENTS.GYROSCOPE_UPDATED, _assertThisInitialized(_this));
      }

      return _this;
    }
    /**
     * @override
     */


    var _proto = GyroscopeButton.prototype;

    _proto.destroy = function destroy() {
      if (this.plugin) {
        this.plugin.off(GyroscopePlugin.EVENTS.GYROSCOPE_UPDATED, this);
      }

      delete this.plugin;

      _AbstractButton.prototype.destroy.call(this);
    }
    /**
     * @override
     */
    ;

    _proto.isSupported = function isSupported() {
      return !this.plugin ? false : {
        initial: false,
        promise: this.plugin.prop.isSupported
      };
    }
    /**
     * @summary Handles events
     * @param {Event} e
     * @private
     */
    ;

    _proto.handleEvent = function handleEvent(e) {
      if (e.type === GyroscopePlugin.EVENTS.GYROSCOPE_UPDATED) {
        this.toggleActive(e.args[0]);
      }
    }
    /**
     * @override
     * @description Toggles gyroscope control
     */
    ;

    _proto.onClick = function onClick() {
      this.plugin.toggle();
    };

    return GyroscopeButton;
  }(photoSphereViewer.AbstractButton);
  GyroscopeButton.id = 'gyroscope';
  GyroscopeButton.icon = compass;

  /**
   * @typedef {Object} external:THREE.DeviceOrientationControls
   * @summary {@link https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/DeviceOrientationControls.js}
   */

  /**
   * @typedef {Object} PSV.plugins.GyroscopePlugin.Options
   * @property {boolean} [touchmove=true] - allows to pan horizontally when the gyroscope is enabled (requires global `mousemove=true`)
   * @property {boolean} [absolutePosition=false] - when true the view will ignore the current direction when enabling gyroscope control
   */
  // add gyroscope button

  photoSphereViewer.DEFAULTS.navbar.splice(-1, 0, GyroscopeButton.id);
  photoSphereViewer.DEFAULTS.lang[GyroscopeButton.id] = 'Gyroscope';
  photoSphereViewer.registerButton(GyroscopeButton);
  /**
   * @summary Adds gyroscope controls on mobile devices
   * @extends PSV.plugins.AbstractPlugin
   * @memberof PSV.plugins
   */

  var GyroscopePlugin = /*#__PURE__*/function (_AbstractPlugin) {
    _inheritsLoose(GyroscopePlugin, _AbstractPlugin);

    /**
     * @summary Available events
     * @enum {string}
     * @memberof PSV.plugins.GyroscopePlugin
     * @constant
     */

    /**
     * @param {PSV.Viewer} psv
     * @param {PSV.plugins.GyroscopePlugin.Options} options
     */
    function GyroscopePlugin(psv, options) {
      var _this;

      _this = _AbstractPlugin.call(this, psv) || this;
      /**
       * @member {Object}
       * @private
       * @property {Promise<boolean>} isSupported - indicates of the gyroscope API is available
       * @property {number} alphaOffset - current alpha offset for gyroscope controls
       * @property {Function} orientationCb - update callback of the device orientation
       * @property {boolean} config_moveInertia - original config "moveInertia"
       */

      _this.prop = {
        isSupported: _this.__checkSupport(),
        alphaOffset: 0,
        orientationCb: null,
        config_moveInertia: true
      };
      /**
       * @member {PSV.plugins.GyroscopePlugin.Options}
       * @private
       */

      _this.config = _extends({
        touchmove: true,
        absolutePosition: false
      }, options);
      /**
       * @member {external:THREE.DeviceOrientationControls}
       * @private
       */

      _this.controls = null;

      _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, _assertThisInitialized(_this));

      _this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_ROTATE, _assertThisInitialized(_this));

      return _this;
    }
    /**
     * @package
     */


    var _proto = GyroscopePlugin.prototype;

    _proto.destroy = function destroy() {
      this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL, this);
      this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_ROTATE, this);
      this.stop();
      delete this.controls;
      delete this.prop;

      _AbstractPlugin.prototype.destroy.call(this);
    }
    /**
     * @private
     */
    ;

    _proto.handleEvent = function handleEvent(e) {
      switch (e.type) {
        case photoSphereViewer.CONSTANTS.EVENTS.STOP_ALL:
          this.stop();
          break;

        case photoSphereViewer.CONSTANTS.EVENTS.BEFORE_ROTATE:
          this.__onRotate(e);

          break;
      }
    }
    /**
     * @summary Checks if the gyroscope is enabled
     * @returns {boolean}
     */
    ;

    _proto.isEnabled = function isEnabled() {
      return !!this.prop.orientationCb;
    }
    /**
     * @summary Enables the gyroscope navigation if available
     * @returns {Promise}
     * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated
     * @throws {PSV.PSVError} if the gyroscope API is not available/granted
     */
    ;

    _proto.start = function start() {
      var _this2 = this;

      return this.prop.isSupported.then(function (supported) {
        if (supported) {
          return _this2.__requestPermission();
        } else {
          photoSphereViewer.utils.logWarn('gyroscope not available');
          return Promise.reject();
        }
      }).then(function (granted) {
        if (granted) {
          return Promise.resolve();
        } else {
          photoSphereViewer.utils.logWarn('gyroscope not allowed');
          return Promise.reject();
        }
      }).then(function () {
        _this2.psv.__stopAll(); // disable inertia


        _this2.prop.config_moveInertia = _this2.psv.config.moveInertia;
        _this2.psv.config.moveInertia = false;

        _this2.__configure();
        /**
         * @event gyroscope-updated
         * @memberof PSV.plugins.GyroscopePlugin
         * @summary Triggered when the gyroscope mode is enabled/disabled
         * @param {boolean} enabled
         */


        _this2.trigger(GyroscopePlugin.EVENTS.GYROSCOPE_UPDATED, true);
      });
    }
    /**
     * @summary Disables the gyroscope navigation
     * @fires PSV.plugins.GyroscopePlugin.gyroscope-updated
     */
    ;

    _proto.stop = function stop() {
      if (this.isEnabled()) {
        this.controls.disconnect();
        this.psv.off(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this.prop.orientationCb);
        this.prop.orientationCb = null;
        this.psv.config.moveInertia = this.prop.config_moveInertia;
        this.trigger(GyroscopePlugin.EVENTS.GYROSCOPE_UPDATED, false);
      }
    }
    /**
     * @summary Enables or disables the gyroscope navigation
     */
    ;

    _proto.toggle = function toggle() {
      if (this.isEnabled()) {
        this.stop();
      } else {
        this.start();
      }
    }
    /**
     * @summary Attaches the {@link external:THREE.DeviceOrientationControls} to the camera
     * @private
     */
    ;

    _proto.__configure = function __configure() {
      var _this3 = this;

      if (!this.controls) {
        this.controls = new DeviceOrientationControls(this.psv.renderer.camera);
      } else {
        this.controls.connect();
      } // force reset


      this.controls.deviceOrientation = null;
      this.controls.screenOrientation = 0;
      this.controls.alphaOffset = 0;
      this.prop.alphaOffset = this.config.absolutePosition ? 0 : null;

      this.prop.orientationCb = function () {
        if (!_this3.controls.deviceOrientation) {
          return;
        } // on first run compute the offset depending on the current viewer position and device orientation


        if (_this3.prop.alphaOffset === null) {
          _this3.controls.update();

          var direction = new THREE.Vector3();

          _this3.psv.renderer.camera.getWorldDirection(direction);

          var sphericalCoords = _this3.psv.dataHelper.vector3ToSphericalCoords(direction);

          _this3.prop.alphaOffset = sphericalCoords.longitude - _this3.psv.prop.position.longitude;
        } else {
          _this3.controls.alphaOffset = _this3.prop.alphaOffset;

          _this3.controls.update();

          _this3.psv.renderer.camera.getWorldDirection(_this3.psv.prop.direction);

          _this3.psv.prop.direction.multiplyScalar(photoSphereViewer.CONSTANTS.SPHERE_RADIUS);

          var _sphericalCoords = _this3.psv.dataHelper.vector3ToSphericalCoords(_this3.psv.prop.direction);

          _this3.psv.prop.position.longitude = _sphericalCoords.longitude;
          _this3.psv.prop.position.latitude = _sphericalCoords.latitude;

          _this3.psv.needsUpdate();
        }
      };

      this.psv.on(photoSphereViewer.CONSTANTS.EVENTS.BEFORE_RENDER, this.prop.orientationCb);
    }
    /**
     * @summary Intercepts moves and offsets the alpha angle
     * @param {external:uEvent.Event} e
     * @private
     */
    ;

    _proto.__onRotate = function __onRotate(e) {
      if (this.isEnabled()) {
        e.preventDefault();

        if (this.config.touchmove) {
          this.prop.alphaOffset -= e.args[0].longitude - this.psv.prop.position.longitude;
        }
      }
    }
    /**
     * @summary Detects if device orientation is supported
     * @returns {Promise<boolean>}
     * @private
     */
    ;

    _proto.__checkSupport = function __checkSupport() {
      if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {
        return Promise.resolve(true);
      } else if ('DeviceOrientationEvent' in window) {
        return new Promise(function (resolve) {
          var listener = function listener(e) {
            resolve(e && e.alpha !== null && !isNaN(e.alpha));
            window.removeEventListener('deviceorientation', listener);
          };

          window.addEventListener('deviceorientation', listener, false); // after 2 secs, auto-reject the promise

          setTimeout(listener, 2000);
        });
      } else {
        return Promise.resolve(false);
      }
    }
    /**
     * @summary Request permission to the motion API
     * @returns {Promise<boolean>}
     * @private
     */
    ;

    _proto.__requestPermission = function __requestPermission() {
      if ('DeviceMotionEvent' in window && typeof DeviceMotionEvent.requestPermission === 'function') {
        return DeviceOrientationEvent.requestPermission().then(function (response) {
          return response === 'granted';
        }).catch(function () {
          return false;
        });
      } else {
        return Promise.resolve(true);
      }
    };

    return GyroscopePlugin;
  }(photoSphereViewer.AbstractPlugin);

  GyroscopePlugin.id = 'gyroscope';
  GyroscopePlugin.EVENTS = {
    GYROSCOPE_UPDATED: 'gyroscope-updated'
  };

  return GyroscopePlugin;

})));
//# sourceMappingURL=gyroscope.js.map

 因為我的專案需要開啟自動陀螺儀,所以我刪掉了有關是否允許設備開啟陀螺儀的判斷

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/254377.html

標籤:JavaScript

上一篇:演算法面試題二:旋轉陣列,存在重復元素,只出現一次的數字

下一篇:原生js使用面向物件的方法開發選項卡實體教程

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • IEEE1588PTP在數字化變電站時鐘同步方面的應用

    IEEE1588ptp在數字化變電站時鐘同步方面的應用 京準電子科技官微——ahjzsz 一、電力系統時間同步基本概況 隨著對IEC 61850標準研究的不斷深入,國內外學者提出基于IEC61850通信標準體系建設數字化變電站的發展思路。數字化變電站與常規變電站的顯著區別在于程序層傳統的電流/電壓互 ......

    uj5u.com 2020-09-10 03:51:52 more
  • HTTP request smuggling CL.TE

    CL.TE 簡介 前端通過Content-Length處理請求,通過反向代理或者負載均衡將請求轉發到后端,后端Transfer-Encoding優先級較高,以TE處理請求造成安全問題。 檢測 發送如下資料包 POST / HTTP/1.1 Host: ac391f7e1e9af821806e890 ......

    uj5u.com 2020-09-10 03:52:11 more
  • 網路滲透資料大全單——漏洞庫篇

    網路滲透資料大全單——漏洞庫篇漏洞庫 NVD ——美國國家漏洞庫 →http://nvd.nist.gov/。 CERT ——美國國家應急回應中心 →https://www.us-cert.gov/ OSVDB ——開源漏洞庫 →http://osvdb.org Bugtraq ——賽門鐵克 →ht ......

    uj5u.com 2020-09-10 03:52:15 more
  • 京準講述NTP時鐘服務器應用及原理

    京準講述NTP時鐘服務器應用及原理京準講述NTP時鐘服務器應用及原理 安徽京準電子科技官微——ahjzsz 北斗授時原理 授時是指接識訓通過某種方式獲得本地時間與北斗標準時間的鐘差,然后調整本地時鐘使時差控制在一定的精度范圍內。 衛星導航系統通常由三部分組成:導航授時衛星、地面檢測校正維護系統和用戶 ......

    uj5u.com 2020-09-10 03:52:25 more
  • 利用北斗衛星系統設計NTP網路時間服務器

    利用北斗衛星系統設計NTP網路時間服務器 利用北斗衛星系統設計NTP網路時間服務器 安徽京準電子科技官微——ahjzsz 概述 NTP網路時間服務器是一款支持NTP和SNTP網路時間同步協議,高精度、大容量、高品質的高科技時鐘產品。 NTP網路時間服務器設備采用冗余架構設計,高精度時鐘直接來源于北斗 ......

    uj5u.com 2020-09-10 03:52:35 more
  • 詳細解讀電力系統各種對時方式

    詳細解讀電力系統各種對時方式 詳細解讀電力系統各種對時方式 安徽京準電子科技官微——ahjzsz,更多資料請添加VX 衛星同步時鐘是我京準公司開發研制的應用衛星授時時技術的標準時間顯示和發送的裝置,該裝置以M國全球定位系統(GLOBAL POSITIONING SYSTEM,縮寫為GPS)或者我國北 ......

    uj5u.com 2020-09-10 03:52:45 more
  • 如何保證外包團隊接入企業內網安全

    不管企業規模的大小,只要企業想省錢,那么企業的某些服務就一定會采用外包的形式,然而看似美好又經濟的策略,其實也有不好的一面。下面我通過安全的角度來聊聊使用外包團的安全隱患問題。 先看看什么服務會使用外包的,最常見的就是話務/客服這種需要大量重復性、無技術性的服務,或者是一些銷售外包、特殊的職能外包等 ......

    uj5u.com 2020-09-10 03:52:57 more
  • PHP漏洞之【整型數字型SQL注入】

    0x01 什么是SQL注入 SQL是一種注入攻擊,通過前端帶入后端資料庫進行惡意的SQL陳述句查詢。 0x02 SQL整型注入原理 SQL注入一般發生在動態網站URL地址里,當然也會發生在其它地發,如登錄框等等也會存在注入,只要是和資料庫打交道的地方都有可能存在。 如這里http://192.168. ......

    uj5u.com 2020-09-10 03:55:40 more
  • [GXYCTF2019]禁止套娃

    git泄露獲取原始碼 使用GET傳參,引數為exp 經過三層過濾執行 第一層過濾偽協議,第二層過濾帶引數的函式,第三層過濾一些函式 preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'] (?R)參考當前正則運算式,相當于匹配函式里的引數 因此傳遞 ......

    uj5u.com 2020-09-10 03:56:07 more
  • 等保2.0實施流程

    流程 結論 ......

    uj5u.com 2020-09-10 03:56:16 more
最新发布
  • 使用Django Rest framework搭建Blog

    在前面的Blog例子中我們使用的是GraphQL, 雖然GraphQL的使用處于上升趨勢,但是Rest API還是使用的更廣泛一些. 所以還是決定回到傳統的rest api framework上來, Django rest framework的官網上給了一個很好用的QuickStart, 我參考Qu ......

    uj5u.com 2023-04-20 08:17:54 more
  • 記錄-new Date() 我忍你很久了!

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 大家平時在開發的時候有沒被new Date()折磨過?就是它的諸多怪異的設定讓你每每用的時候,都可能不小心踩坑。造成程式意外出錯,卻一下子找不到問題出處,那叫一個煩透了…… 下面,我就列舉它的“四宗罪”及應用思考 可惡的四宗罪 1. Sa ......

    uj5u.com 2023-04-20 08:17:47 more
  • 使用Vue.js實作文字跑馬燈效果

    實作文字跑馬燈效果,首先用到 substring()截取 和 setInterval計時器 clearInterval()清除計時器 效果如下: 實作代碼如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ......

    uj5u.com 2023-04-20 08:12:31 more
  • JavaScript 運算子

    JavaScript 運算子/運算子 在 JavaScript 中,有一些運算子可以使代碼更簡潔、易讀和高效。以下是一些常見的運算子: 1、可選鏈運算子(optional chaining operator) ?.是可選鏈運算子(optional chaining operator)。?. 可選鏈操 ......

    uj5u.com 2023-04-20 08:02:25 more
  • CSS—相對單位rem

    一、概述 rem是一個相對長度單位,它的單位長度取決于根標簽html的字體尺寸。rem即root em的意思,中文翻譯為根em。瀏覽器的文本尺寸一般默認為16px,即默認情況下: 1rem = 16px rem布局原理:根據CSS媒體查詢功能,更改根標簽的字體尺寸,實作rem單位隨螢屏尺寸的變化,如 ......

    uj5u.com 2023-04-20 08:02:21 more
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 08:01:50 more
  • 如何在 vue3 中使用 jsx/tsx?

    我們都知道,通常情況下我們使用 vue 大多都是用的 SFC(Signle File Component)單檔案組件模式,即一個組件就是一個檔案,但其實 Vue 也是支持使用 JSX 來撰寫組件的。這里不討論 SFC 和 JSX 的好壞,這個仁者見仁智者見智。本篇文章旨在帶領大家快速了解和使用 Vu ......

    uj5u.com 2023-04-20 08:01:37 more
  • 【Vue2.x原始碼系列06】計算屬性computed原理

    本章目標:計算屬性是如何實作的?計算屬性快取原理以及洋蔥模型的應用?在初始化Vue實體時,我們會給每個計算屬性都創建一個對應watcher,我們稱之為計算屬性watcher ......

    uj5u.com 2023-04-20 08:01:31 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:01:10 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:00:32 more