Skip to content

Commit

Permalink
fix update notify
Browse files Browse the repository at this point in the history
  • Loading branch information
XZiar committed May 2, 2018
1 parent 7212843 commit 9186414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ZhiHuExt/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function strToVer(str)
const verstr = str.replace(/[^0-9.]/g, "").split(".").map(Number);
return verstr[0] * 10000 + verstr[1] * 100 + verstr[2];
}
function verToStr(ver)
{
return `v${Math.floor(ver / 10000)}.${Math.floor((ver % 10000) / 10)}.${ver % 10}`;
}
async function getVersion()
{
const curver = strToVer(chrome.runtime.getManifest().version);
Expand Down Expand Up @@ -530,7 +534,7 @@ chrome.runtime.onMessageExternal.addListener(
chrome.notifications.create("UpdInfo",
{
type: "basic",
title: "【知乎疯牛病】更新提示",
title: `【知乎疯牛病】更新提示[${verToStr(verinfo.newver)}]`,
message: `插件似乎发布新版本了,快去看看作者又加了什么华而不实的功能吧?!`,
iconUrl: "icon.png"
});
Expand Down
2 changes: 1 addition & 1 deletion ZhiHuExt/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ chrome.runtime.sendMessage({ action: "chkver" }, resp =>
{
$("#curver").text(verToStr(resp.curver));
$("#newver").text(verToStr(resp.newver));
if (curver < newver)
if (resp.curver < resp.newver)
{
$("#newver")[0].style.color = "red";
$("#upd").show();
Expand Down

0 comments on commit 9186414

Please sign in to comment.