From 0946941e599c28b5be0b7b5e6a7d8006874ae77a Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 2 Oct 2022 15:31:42 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D0=B1=D1=80=D0=B0=D1=83?= =?UTF-8?q?=D0=B7=D0=B5=D1=80=D0=B5=20=D0=BF=D1=80=D0=B8=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=B0=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Api/Api.vue | 14 ++++++++++++++ client/store/root.js | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/components/Api/Api.vue b/client/components/Api/Api.vue index 23d9cb8..129bfd4 100644 --- a/client/components/Api/Api.vue +++ b/client/components/Api/Api.vue @@ -36,6 +36,7 @@ import wsc from './webSocketConnection'; import * as utils from '../../share/utils'; import * as cryptoUtils from '../../share/cryptoUtils'; import LockQueue from '../../share/LockQueue'; +import packageJson from '../../../package.json'; const rotor = '|/-\\'; const stepBound = [ @@ -92,6 +93,15 @@ class Api { try { const config = await this.getConfig(); this.commit('setConfig', config); + + //проверим на новую версию, обновимся при необходимости + if (this.config.version) { + if (this.config.version != packageJson.version && Date.now() - this.lastReloadTime > 15*1000) { + this.commit('setLastReloadTime', Date.now());//на всякий случай, чтобы исключить зацикливание в reload + + document.location.reload(); + } + } } catch (e) { this.$root.stdDialog.alert(e.message, 'Ошибка'); } @@ -101,6 +111,10 @@ class Api { return this.$store.state.config; } + get lastReloadTime() { + return this.$store.state.lastReloadTime; + } + get settings() { return this.$store.state.settings; } diff --git a/client/store/root.js b/client/store/root.js index b808aa8..c7c2a06 100644 --- a/client/store/root.js +++ b/client/store/root.js @@ -1,6 +1,7 @@ // initial state const state = { config: {}, + lastReloadTime: 0, settings: { accessToken: '', limit: 20, @@ -12,7 +13,7 @@ const state = { showDeleted: false, abCacheEnabled: true, langDefault: '', - }, + }, }; // getters @@ -26,6 +27,9 @@ const mutations = { setConfig(state, value) { state.config = value; }, + setLastReloadTime(state, value) { + state.lastReloadTime = value; + }, setSettings(state, value) { state.settings = Object.assign({}, state.settings, value); },