From 9186414d370017160b6da44d0da60b873145738d Mon Sep 17 00:00:00 2001 From: XZiar Date: Wed, 2 May 2018 11:54:45 -0700 Subject: [PATCH] fix update notify --- ZhiHuExt/background.js | 6 +++++- ZhiHuExt/popup.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ZhiHuExt/background.js b/ZhiHuExt/background.js index 8283b98..c614da0 100644 --- a/ZhiHuExt/background.js +++ b/ZhiHuExt/background.js @@ -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); @@ -530,7 +534,7 @@ chrome.runtime.onMessageExternal.addListener( chrome.notifications.create("UpdInfo", { type: "basic", - title: "【知乎疯牛病】更新提示", + title: `【知乎疯牛病】更新提示[${verToStr(verinfo.newver)}]`, message: `插件似乎发布新版本了,快去看看作者又加了什么华而不实的功能吧?!`, iconUrl: "icon.png" }); diff --git a/ZhiHuExt/popup.js b/ZhiHuExt/popup.js index 6e80962..4495090 100644 --- a/ZhiHuExt/popup.js +++ b/ZhiHuExt/popup.js @@ -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();