VRC status checking

This commit is contained in:
Natsumi
2025-10-02 14:13:16 +13:00
parent f4d4754230
commit cac7bf6f17
10 changed files with 118 additions and 22 deletions
+5 -2
View File
@@ -31,6 +31,7 @@ import { useVrStore } from './vr';
import { useVrcxStore } from './vrcx';
import { useVRCXUpdaterStore } from './vrcxUpdater';
import { useWorldStore } from './world';
import { useVrcStatusStore } from './vrcStatus';
import { createSentryPiniaPlugin } from '@sentry/vue';
@@ -70,7 +71,8 @@ export function createGlobalStores() {
vrcx: useVrcxStore(),
sharedFeed: useSharedFeedStore(),
updateLoop: useUpdateLoopStore(),
auth: useAuthStore()
auth: useAuthStore(),
vrcStatus: useVrcStatusStore()
};
}
@@ -106,5 +108,6 @@ export {
useVRCXUpdaterStore,
useWorldStore,
useSharedFeedStore,
useUpdateLoopStore
useUpdateLoopStore,
useVrcStatusStore
};
+59
View File
@@ -0,0 +1,59 @@
import { defineStore } from 'pinia';
import webApiService from '../service/webapi';
import { ref } from 'vue';
export const useVrcStatusStore = defineStore('VrcStatus', () => {
const vrcStatusApiUrl = 'https://status.vrchat.com/api/v2';
const lastStatus = ref('');
const lastTimeFetched = ref(0);
const isAlertClosed = ref(false);
const pollingInterval = ref(0);
async function getVrcStatus() {
const response = await webApiService.execute({
url: `${vrcStatusApiUrl}/status.json`,
method: 'GET',
headers: {
Referer: 'https://vrcx.app'
}
});
lastTimeFetched.value = Date.now();
const data = JSON.parse(response.data);
if (data.status.description === 'All Systems Operational') {
lastStatus.value = '';
pollingInterval.value = 15 * 60 * 1000; // 15 minutes
return;
}
lastStatus.value = data.status.description;
pollingInterval.value = 2 * 60 * 1000; // 2 minutes
}
// ran from Cef and Electron when browser is focused
function onBrowserFocus() {
if (Date.now() - lastTimeFetched.value > 60 * 1000) {
getVrcStatus();
}
}
function init() {
getVrcStatus();
setInterval(() => {
if (isAlertClosed.value) {
return;
}
if (Date.now() - lastTimeFetched.value > pollingInterval.value) {
getVrcStatus();
}
}, 60 * 1000);
}
init();
return {
lastStatus,
isAlertClosed,
onBrowserFocus,
getVrcStatus
};
});
+6
View File
@@ -25,6 +25,7 @@ import { useAdvancedSettingsStore } from './settings/advanced';
import { useUpdateLoopStore } from './updateLoop';
import { useUserStore } from './user';
import { useWorldStore } from './world';
import { useVrcStatusStore } from './vrcStatus';
import { useI18n } from 'vue-i18n';
import Noty from 'noty';
@@ -45,6 +46,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
const avatarProviderStore = useAvatarProviderStore();
const gameLogStore = useGameLogStore();
const updateLoopStore = useUpdateLoopStore();
const vrcStatusStore = useVrcStatusStore();
const { t } = useI18n();
const state = reactive({
@@ -87,6 +89,10 @@ export const useVrcxStore = defineStore('Vrcx', () => {
state.windowState = newState.windowState;
debounce(saveVRCXWindowOption, 300)();
});
window.electron.onBrowserFocus(() => {
vrcStatusStore.onBrowserFocus();
});
}
state.databaseVersion = await configRepository.getInt(