Skip to content

Commit

Permalink
bump version to v2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kirainmoe committed Apr 28, 2020
1 parent 52439e3 commit 3b30d6b
Show file tree
Hide file tree
Showing 24 changed files with 310 additions and 162 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/project-starbeat.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion starbeat-client/build/asset-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"static/js/2.chunk.js": "./static/js/2.chunk.js",
"static/js/2.chunk.js.map": "./static/js/2.chunk.js.map",
"index.html": "./index.html",
"precache-manifest.483fd395da2c0e71989e409cecb88e26.js": "./precache-manifest.483fd395da2c0e71989e409cecb88e26.js",
"precache-manifest.0d6dae9ba78843429027558a7bb8556e.js": "./precache-manifest.0d6dae9ba78843429027558a7bb8556e.js",
"service-worker.js": "./service-worker.js",
"static/css/2.chunk.css.map": "./static/css/2.chunk.css.map",
"static/css/main.chunk.css.map": "./static/css/main.chunk.css.map",
Expand Down
168 changes: 110 additions & 58 deletions starbeat-client/build/electron/electronCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,65 @@ const electronCompatLayer = () => {
return fs.readFileSync(filename).toString();
};

const downloadFile = (url, savePath, callback, setPercent) => {
const fetch = require("node-fetch"),
fs = require("fs");
let downloadedSize = 0,
totalLength = 0;
fetch(url, {
method: "GET",
headers: { "Content-Type": "application/octet-stream" }
})
.then(res => {
const body = res.body;
totalLength = res.headers.get("content-length");

if (!totalLength) {
totalLength = 8642344; // tmp

fetch('https://api.kirainmoe.com/starbeatVersion')
.then(res => res.json())
.then(res => totalLength = res.fileSize);
}
body.on('readable', () => {
let chunk;
while (null !== (chunk = body.read())) {
downloadedSize += chunk.length;
const percent = Math.round(downloadedSize / totalLength * 100);

if (setPercent)
setPercent(percent);
const downloadFile = async(url, savePath, callback, setPercent) => {
const fs = require("fs"),
fetch = require('node-fetch');
let totalLength = 0,
resolved = false,
done = false,
retry = 0;

const doFetch = (index) => {
let downloadedSize = 0;

return fetch(url)
.then(res => {
resolved = true;
retry = 0;
const body = res.body;
totalLength = res.headers.get("content-length");
resolved = true;

if (!totalLength) {
totalLength = 8642344; // tmp
fetch('https://api.kirainmoe.com/starbeatVersion')
.then(res => res.json())
.then(res => totalLength = res.fileSize);
}
body.on('readable', () => {
let chunk;
retry = 0;
while (null !== (chunk = body.read())) {
downloadedSize += chunk.length;
const percent = Math.round(downloadedSize / totalLength * 100);

if (setPercent)
setPercent(percent);
}
});
return res;
})
.then(res => res.buffer())
.then(data => {
done = true;
fs.writeFileSync(savePath, data, "binary");
callback();
})
.catch(err => {
alert(err);
});
return res;
})
.then(res => res.buffer())
.then(data => {
fs.writeFileSync(savePath, data, "binary");
callback();
});
};

doFetch(1);

const retryDaemon = setInterval(() => {
if (done)
clearInterval(retryDaemon);
retry++;
if (retry >= 10)
window.location.reload();
}, 1000);

};

const getUserDir = () => {
Expand Down Expand Up @@ -174,6 +196,28 @@ const electronCompatLayer = () => {
updateSpecificFile(0, version);
};

const getWMIC = () => {
const cp = require('child_process');
const res = cp.execSync('echo "csproduct" | wmic').toString(),
tmp = res.split('\n');
let wmic = "";

for (let i = 0; i < tmp.length; i++) {
if (tmp[i].indexOf("SKUNumber") >= 0) {
wmic = tmp[i+1];
break;
}
}
wmic = wmic.replace(/\s\s+/g, '/');

const smbiosinfo = wmic.split('/');
return {
sn: smbiosinfo[2],
model: smbiosinfo[3],
uuid: smbiosinfo[4]
};
}

return {
getPlatform: () => process.platform,
isWin,
Expand All @@ -182,30 +226,32 @@ const electronCompatLayer = () => {
exec,
sudoExec,
getMacSerial: () => {
if (!isMac()) return false;
const remote = require("electron").remote;
const p = remote.app.getAppPath();
// macOS
if (isMac()) {
const remote = require("electron").remote;
const p = remote.app.getAppPath();

let macserialPath = (p + "/macserial/macserial").replace(/ /g, "\\ ");
const output = exec(macserialPath).toString();
let result = {};
try {
const model = output.match(/Model:\s(.*)/),
sn = output.match(/Serial\sNumber:\s(.*)/),
smuuid = output.match(/System\sID:\s(.*)/),
mlb = output.match(/MLB:\s(.*)/);

let macserialPath = (p + "/macserial/macserial").replace(/ /g, "\\ ");
const output = exec(macserialPath).toString();

let result = {};
try {
const model = output.match(/Model:\s(.*)/),
sn = output.match(/Serial\sNumber:\s(.*)/),
smuuid = output.match(/System\sID:\s(.*)/),
mlb = output.match(/MLB:\s(.*)/);

result = {
model: model[1],
sn: sn[1],
smuuid: smuuid[1],
mlb: mlb[1]
};
} catch(err) {
result = null;
result = {
model: model[1],
sn: sn[1],
smuuid: smuuid[1],
mlb: mlb[1]
};
} catch (err) {
result = null;
}
return result;
}
return result;
return false;
},
generateMacSerial: () => {
let macserial;
Expand All @@ -226,7 +272,13 @@ const electronCompatLayer = () => {

const uuidGen = require("node-uuid");
const output = exec(macserial + " --model 43 --generate --num 1").toString();
const uuid = uuidGen.v4();
let uuid = uuidGen.v4();

if (isWin()) {
const wmic = getWMIC();
if (wmic.uuid)
uuid = wmic.uuid;
}

const res = output.split("|");
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "./index.html"
},
{
"revision": "8136eaa97bcc074f91f3",
"revision": "af039fd9a87ec1967122",
"url": "./static/css/2.chunk.css"
},
{
"revision": "1a7c8253425b56544abd",
"revision": "929b4c02ad994dd2e4aa",
"url": "./static/css/main.chunk.css"
},
{
"revision": "8136eaa97bcc074f91f3",
"revision": "af039fd9a87ec1967122",
"url": "./static/js/2.chunk.js"
},
{
"revision": "a366888eb77243c004483cd2ac7ea0cc",
"revision": "4947a88052be21cc6beaebe2a22afa34",
"url": "./static/js/2.chunk.js.LICENSE.txt"
},
{
"revision": "1a7c8253425b56544abd",
"revision": "929b4c02ad994dd2e4aa",
"url": "./static/js/main.chunk.js"
},
{
"revision": "4f7676623aa0345a8bf8",
"revision": "f06a99569d39edf49307",
"url": "./static/js/runtime-main.js"
},
{
Expand Down
4 changes: 2 additions & 2 deletions starbeat-client/build/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");

importScripts(
"./precache-manifest.483fd395da2c0e71989e409cecb88e26.js"
"./precache-manifest.0d6dae9ba78843429027558a7bb8556e.js"
);

self.addEventListener('message', (event) => {
Expand All @@ -35,5 +35,5 @@ workbox.precaching.precacheAndRoute(self.__precacheManifest, {});

workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("./index.html"), {

blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/],
blacklist: [/^\/_/,/\/[^\/?]+\.[^\/]+$/],
});
2 changes: 1 addition & 1 deletion starbeat-client/build/static/css/2.chunk.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion starbeat-client/build/static/css/2.chunk.css.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3b30d6b

Please sign in to comment.