Browse Source

Merge pull request #112 from micooz/master

Minor changes
DIYgod 8 years ago
parent
commit
daeccbde2e
5 changed files with 24 additions and 12 deletions
  1. 8 11
      src/DPlayer.js
  2. 3 0
      src/index.js
  3. 6 0
      src/utils.js
  4. 4 1
      webpack/dev.config.js
  5. 3 0
      webpack/prod.config.js

+ 8 - 11
src/DPlayer.js

@@ -1,13 +1,11 @@
-console.log('\n %c DPlayer 1.5.0 %c http://dplayer.js.org \n\n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
+import './DPlayer.scss';
 
-require('./DPlayer.scss');
-const utils = require('./utils.js');
-const svg = require('./svg.js');
-const handleOption = require('./option.js');
-const i18n = require('./i18n.js');
-const html = require('./html.js');
-const Video = require('./video.js');
-const isMobile = /mobile/i.test(window.navigator.userAgent);
+import utils, {isMobile} from './utils';
+import svg from './svg';
+import handleOption from './option';
+import i18n from './i18n';
+import html from './html';
+import Video from './video';
 
 let index = 0;
 
@@ -160,7 +158,7 @@ class DPlayer {
         const clearCheckLoadingTime = () => {
             clearInterval(this.checkLoading);
         };
-        
+
         this.animationFrame = () => {
             if (this.playedTime) {
                 this.updateBar('played', this.video.currentTime() / this.video.duration, 'width');
@@ -933,7 +931,6 @@ class DPlayer {
      * Read danmaku from API
      */
     readDanmaku () {
-        const isMobile = /mobile/i.test(window.navigator.userAgent);
         let apiurl;
         if (this.option.danmaku.maximum) {
             apiurl = `${this.option.danmaku.api}?id=${this.option.danmaku.id}&max=${this.option.danmaku.maximum}`;

+ 3 - 0
src/index.js

@@ -1 +1,4 @@
+// eslint-disable-next-line
+console.log(`\n %c DPlayer ${DPLAYER_VERSION} %c http://dplayer.js.org \n\n`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
+
 module.exports = require('./DPlayer');

+ 6 - 0
src/utils.js

@@ -35,4 +35,10 @@ module.exports = {
         }
         return actualLeft - elementScrollLeft;
     },
+
+    /**
+     * check if user is using mobile or not
+     */
+    isMobile: /mobile/i.test(window.navigator.userAgent)
+
 };

+ 4 - 1
webpack/dev.config.js

@@ -91,7 +91,10 @@ module.exports = {
     },
 
     plugins: [
-        new webpack.NamedModulesPlugin()
+        new webpack.NamedModulesPlugin(),
+        new webpack.DefinePlugin({
+            DPLAYER_VERSION: `"${require('../package.json').version}"`
+        })
     ],
 
     node: {

+ 3 - 0
webpack/prod.config.js

@@ -85,6 +85,9 @@ module.exports = {
     },
 
     plugins: [
+        new webpack.DefinePlugin({
+            DPLAYER_VERSION: `"${require('../package.json').version}"`
+        }),
         new webpack.optimize.UglifyJsPlugin({
             compress: {
                 warnings: false