mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
VRC status checking
This commit is contained in:
@@ -83,6 +83,11 @@ namespace VRCX
|
||||
{
|
||||
logger.Debug(consoleMessageEventArgs.Message + " (" + consoleMessageEventArgs.Source + ":" + consoleMessageEventArgs.Line + ")");
|
||||
};
|
||||
Browser.GotFocus += (_, _) =>
|
||||
{
|
||||
if (Browser != null && !Browser.IsLoading && Browser.CanExecuteJavascriptInMainFrame)
|
||||
Browser.ExecuteScriptAsync("$pinia.vrcStatus.onBrowserFocus()");
|
||||
};
|
||||
|
||||
JavascriptBindings.ApplyAppJavascriptBindings(Browser.JavascriptObjectRepository);
|
||||
Controls.Add(Browser);
|
||||
|
||||
@@ -396,6 +396,10 @@ function createWindow() {
|
||||
mainWindow.on('restore', () => {
|
||||
mainWindow.webContents.send('setWindowState', '0');
|
||||
});
|
||||
|
||||
mainWindow.on('focus', () => {
|
||||
mainWindow.webContents.send('onBrowserFocus');
|
||||
});
|
||||
}
|
||||
|
||||
let wristOverlayWindow = undefined;
|
||||
|
||||
@@ -31,6 +31,7 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
ipcRenderer.on('setWindowSize', callback),
|
||||
onWindowStateChange: (callback) =>
|
||||
ipcRenderer.on('setWindowState', callback),
|
||||
onBrowserFocus: (callback) => ipcRenderer.on('onBrowserFocus', callback),
|
||||
desktopNotification: (title, body, icon) =>
|
||||
ipcRenderer.invoke('notification:showNotification', title, body, icon),
|
||||
restartApp: () => ipcRenderer.invoke('app:restart'),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<!DOCTYPE html>
|
||||
<el-config-provider :locale="currentLocale">
|
||||
<VrcStatus></VrcStatus>
|
||||
<div
|
||||
id="x-app"
|
||||
class="x-app"
|
||||
@@ -104,6 +105,8 @@
|
||||
import zhTW from 'element-plus/es/locale/lang/zh-tw';
|
||||
import th from 'element-plus/es/locale/lang/th';
|
||||
|
||||
import VrcStatus from './components/VrcStatus.vue';
|
||||
|
||||
import Login from './views/Login/Login.vue';
|
||||
import NavMenu from './components/NavMenu.vue';
|
||||
import Sidebar from './views/Sidebar/Sidebar.vue';
|
||||
|
||||
20
src/components/VrcStatus.vue
Normal file
20
src/components/VrcStatus.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<el-alert
|
||||
v-if="lastStatus"
|
||||
:title="lastStatus"
|
||||
type="warning"
|
||||
show-icon
|
||||
center
|
||||
:closable="true"
|
||||
@close="onAlertClose"></el-alert>
|
||||
</template>
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useVrcStatusStore } from '../stores';
|
||||
|
||||
const { lastStatus, isAlertClosed } = storeToRefs(useVrcStatusStore());
|
||||
|
||||
function onAlertClose() {
|
||||
isAlertClosed.value = true;
|
||||
}
|
||||
</script>
|
||||
@@ -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
src/stores/vrcStatus.js
Normal file
59
src/stores/vrcStatus.js
Normal 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
|
||||
};
|
||||
});
|
||||
@@ -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(
|
||||
|
||||
1
src/types/globals.d.ts
vendored
1
src/types/globals.d.ts
vendored
@@ -58,6 +58,7 @@ declare global {
|
||||
onWindowStateChange: (
|
||||
Function: (event: any, state: { windowState: any }) => void
|
||||
) => void;
|
||||
onBrowserFocus: (Function: (event: any) => void) => void;
|
||||
restartApp: () => Promise<void>;
|
||||
getWristOverlayWindow: () => Promise<boolean>;
|
||||
getHmdOverlayWindow: () => Promise<boolean>;
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
<template>
|
||||
<div style="float: left; margin: 5px">
|
||||
<el-tooltip placement="top" :content="t('view.login.updater')">
|
||||
<el-button type="default" size="small" :icon="Download" circle @click="showVRCXUpdateDialog"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="top" :content="t('view.login.proxy_settings')">
|
||||
<el-button
|
||||
type="default"
|
||||
size="small"
|
||||
:icon="Connection"
|
||||
style="margin-left: 5px"
|
||||
circle
|
||||
@click="promptProxySettings"></el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div v-loading="loginForm.loading" class="x-login-container">
|
||||
<div class="x-login">
|
||||
<div style="position: fixed; top: 0; left: 0; margin: 5px">
|
||||
<el-tooltip placement="top" :content="t('view.login.updater')">
|
||||
<el-button
|
||||
type="default"
|
||||
size="small"
|
||||
:icon="Download"
|
||||
circle
|
||||
@click="showVRCXUpdateDialog"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="top" :content="t('view.login.proxy_settings')">
|
||||
<el-button
|
||||
type="default"
|
||||
size="small"
|
||||
:icon="Connection"
|
||||
style="margin-left: 5px"
|
||||
circle
|
||||
@click="promptProxySettings"></el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="x-login-form-container">
|
||||
<div>
|
||||
<h2 style="font-weight: bold; text-align: center; margin: 0">{{ t('view.login.login') }}</h2>
|
||||
|
||||
Reference in New Issue
Block a user