Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
lhttjdr committed Aug 11, 2017
1 parent 6e36ac2 commit 9fc56b9
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 17 deletions.
Binary file added assert/linux/hjplayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assert/mac/hjplayer.icns
Binary file not shown.
Binary file added assert/win/hjplayer.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var packager = require('electron-packager');
var config = require('./package.json');

packager({
dir: './',
out: './dist',
name: config.name,
platform: 'win32',
arch: 'all',
electronVersion: '1.4.13',
icon: './assert/win/jplayer.ico',

overwrite: true,
asar: true,
prune: true,
ignore: "test"
}, function done (err, appPath) {
if(err) {
throw new Error(err);
}
console.log('Done!!');
});
21 changes: 12 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@
require('malihu-custom-scrollbar-plugin')(window.$);
require("./js/hjplayer.js");
const decompress = require('decompress');
const app = require('electron').remote;
const dialog = app.dialog;
const remote = require('electron').remote;
const dialog = remote.dialog;
const app=remote.app;

const data=app.getPath('userData');

const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -173,7 +176,7 @@
console.log("No file selected");
return;
} else {
var data_path = path.join(__dirname, "/data/");
var data_path = path.join(data, "/hjplayer/");
if (fs.existsSync(data_path)) {
rimraf.sync(data_path);
}
Expand All @@ -182,13 +185,13 @@
strip: 1
}).then(file => {
console.log("done");
hjp.localLoad(path.join(__dirname, "/data/index.xml"));
hjp.localLoad(data_path);
});
}
});
});
var fillWindow = function() {
var window = app.getCurrentWindow();
var window = remote.getCurrentWindow();
var size = window.getSize();
var layout = hjp.layout;
var scale = {
Expand All @@ -201,7 +204,7 @@
};
hjp.scaleLayout(scale, origin, layout);
}
var window = app.getCurrentWindow();
var window = remote.getCurrentWindow();
window.on("resize", function() {
fillWindow();
//clearTimeout(t);
Expand All @@ -219,12 +222,12 @@
});

$("#min-btn").on("click", function(e) {
var window = app.getCurrentWindow();
var window = remote.getCurrentWindow();
window.minimize();
});

$("#max-btn").on("click", function(e) {
var window = app.getCurrentWindow();
var window = remote.getCurrentWindow();
if (!window.isMaximized()) {
window.maximize();
} else {
Expand All @@ -233,7 +236,7 @@
});

$("#close-btn").on("click", function(e) {
var window = app.getCurrentWindow();
var window = remote.getCurrentWindow();
window.close();
});
});
Expand Down
7 changes: 4 additions & 3 deletions js/hjplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,16 +794,17 @@ HJPlayer.prototype = {
}
});*/
},
localLoad: function(file) {
localLoad: function(dataPath) {
var _this = this;
var parser = new xml2js.Parser({ explicitArray: false }); // compatable with xml2json
var fs = require("fs");
fs.readFile(file, function(err, data) {
var path =require("path");
_this.settings.dataPath=dataPath;
fs.readFile(path.join(dataPath,_this.settings.slidesData), function(err, data) {
if (!err && data) {
parser.parseString(data, function(err, result) {
if (!err && result) {
console.log(result);
_this.settings.dataPath = "data/";
_this.prepare();
_this.parseData(result);
} else {
Expand Down
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function createWindow () {
minHeight:400,
frame: false,
resizable:true,
movable:true,
center:true,
autoHideMenuBar:true,
icon: 'icon.png',
icon: 'assert/win/hjplayer.ico',
webPreferences:{
textAreasAreResizable:false,
overlayScrollbars:true
Expand All @@ -47,7 +48,6 @@ function createWindow () {
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
rimraf.sync(path.join(__dirname,"/data/"));
})
}

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"build": "electron-packager . --platform=darwin,win32,linux --arch=ia32,x64,armv7l --out=./dist"
"build": "node build.js"
},
"repository": "https://github.com/lhttjdr/hjplayer",
"keywords": [
Expand All @@ -17,10 +17,12 @@
"author": "lhttjdr",
"license": "MIT",
"devDependencies": {
"asar": "^0.13.0",
"devtron": "^1.4.0",
"electron": "1.4.13",
"electron": "1.6.11",
"electron-debug": "^1.4.0",
"electron-packager": "8.7.2"
"electron-packager": "8.7.2",
"electron-prebuilt": "^1.4.13"
},
"dependencies": {
"decompress": "^4.2.0",
Expand Down

0 comments on commit 9fc56b9

Please sign in to comment.