mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
Add missing updates checking
This commit is contained in:
parent
94652f4257
commit
f3fab514a5
30
resources/assets/src/js/check-updates.js
Normal file
30
resources/assets/src/js/check-updates.js
Normal file
@ -0,0 +1,30 @@
|
||||
import { init } from './net';
|
||||
|
||||
async function checkForUpdates() {
|
||||
const response = await fetch(`${blessing.base_url}/admin/update/check`, init);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.available) {
|
||||
const dom = `<span class="pull-right-container"><span class="label label-primary pull-right">v${data.latest}</span></span>`;
|
||||
|
||||
$(`[href="${blessing.base_url}/admin/update"]`).append(dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkForPluginUpdates() {
|
||||
const response = await fetch(`${blessing.base_url}/admin/plugins/market/check`, init);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.available) {
|
||||
const dom = `<span class="pull-right-container"><span class="label label-success pull-right">${data.plugins.length}</span></span>`;
|
||||
|
||||
$(`[href="${blessing.base_url}/admin/plugins/market"]`).append(dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.checkForUpdates = checkForUpdates;
|
||||
window.checkForPluginUpdates = checkForPluginUpdates;
|
@ -3,6 +3,7 @@ import './i18n';
|
||||
import './net';
|
||||
import './layout';
|
||||
import './logout';
|
||||
import './check-updates';
|
||||
import './feedback';
|
||||
|
||||
console.log(
|
||||
|
@ -5,7 +5,8 @@ import { showAjaxError } from './notify';
|
||||
const csrfField = document.querySelector('meta[name="csrf-token"]');
|
||||
|
||||
const empty = Object.create(null);
|
||||
const init = {
|
||||
/** @type Request */
|
||||
export const init = {
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
|
Loading…
Reference in New Issue
Block a user