update notification

This commit is contained in:
SpikeHD 2022-04-30 01:56:00 -07:00
parent 364b6c64f5
commit db522bf82c
3 changed files with 82 additions and 0 deletions

View File

@ -248,5 +248,13 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Download notification -->
<div id="downloadNotif" onclick="openLatestDownload()">
<img src="icons/alert.svg" />
<span id="updateNotifText">
A new update is available! Newest version:
</span><span id="newestVersion"></span>
</div>
</body> </body>
</html> </html>

View File

@ -57,6 +57,37 @@ async function proxyIsInstalled() {
return false return false
} }
async function checkForUpdates() {
const url = 'https://api.github.com/repos/Grasscutters/GrassClipper/releases/latest'
const { data } = await axios.get(url)
const latest = data.tag_name
return latest
}
async function displayUpdate(version) {
const latest = await checkForUpdates()
const versionDisplay = document.querySelector('#newestVersion')
const notif = document.querySelector('#downloadNotif')
//if (latest === `v${NL_APPVERSION}`) return
versionDisplay.innerText = latest
notif.classList.add('displayed')
setTimeout(() => {
notif.classList.remove('displayed')
}, 5000)
}
async function openLatestDownload() {
const downloadLink = 'https://github.com/Grasscutters/GrassClipper/releases/latest/'
Neutralino.os.open(downloadLink)
}
async function openGameFolder() { async function openGameFolder() {
const config = await getCfg() const config = await getCfg()
const folder = config.gameexe.match(/.*\\/g, '')[0] const folder = config.gameexe.match(/.*\\/g, '')[0]

View File

@ -7,6 +7,10 @@ body {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
a {
color: #fff;
}
.darken { .darken {
filter: brightness(0.6); filter: brightness(0.6);
} }
@ -535,4 +539,43 @@ body {
#serverInput img:hover { #serverInput img:hover {
cursor: pointer; cursor: pointer;
}
#downloadNotif {
z-index: 99;
position: absolute;
color: #fff;
background: #141414;
border: 1px solid #ccc;
padding: 1em;
top: 80%;
left: 110%;
width: 20%;
border-radius: 5px;
text-align: center;
transition: left 0.4s ease-in-out;
}
#downloadNotif:hover {
cursor: pointer;
border-color: #fff;
}
#downloadNotif img {
height: 20px;
vertical-align: middle;
margin-right: 4px;
filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(16deg) brightness(103%) contrast(101%);
}
#downloadNotif.displayed {
left: 70%;
}
#newestVersion {
font-weight: bold;
} }