mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-27 18:53:47 +02:00
rewrite web request logging function
This commit is contained in:
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { AppDebug } from '../../services/appConfig';
|
||||
import { logWebRequest } from '../../services/appConfig';
|
||||
import { database } from '../../services/database';
|
||||
import { languageCodes } from '../../localization';
|
||||
import { useGameStore } from '../game';
|
||||
@@ -464,9 +464,12 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
}
|
||||
|
||||
const data = JSON.parse(response.data);
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(modelsURL, data, response);
|
||||
}
|
||||
logWebRequest(
|
||||
'[EXTERNAL GET]',
|
||||
modelsURL,
|
||||
`(${response.status})`,
|
||||
data
|
||||
);
|
||||
|
||||
if (data.data && Array.isArray(data.data)) {
|
||||
return data.data
|
||||
@@ -703,9 +706,7 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
}
|
||||
});
|
||||
const json = JSON.parse(response.data);
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(url, json, response);
|
||||
}
|
||||
logWebRequest('[EXTERNAL GET]', url, `(${response.status})`, json);
|
||||
if (response.status === 200) {
|
||||
data = json;
|
||||
} else {
|
||||
@@ -753,9 +754,12 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
);
|
||||
}
|
||||
const data = JSON.parse(response.data);
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(url, data, response);
|
||||
}
|
||||
logWebRequest(
|
||||
'[EXTERNAL POST]',
|
||||
url,
|
||||
`(${response.status})`,
|
||||
data
|
||||
);
|
||||
return data.data.translations[0].translatedText;
|
||||
} catch (err) {
|
||||
toast.error(`Translation failed: ${err.message}`);
|
||||
@@ -817,9 +821,12 @@ export const useAdvancedSettingsStore = defineStore('AdvancedSettings', () => {
|
||||
}
|
||||
|
||||
const data = JSON.parse(response.data);
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(endpoint, data, response);
|
||||
}
|
||||
logWebRequest(
|
||||
'[EXTERNAL POST]',
|
||||
endpoint,
|
||||
`(${response.status})`,
|
||||
data
|
||||
);
|
||||
|
||||
const translated = data?.choices?.[0]?.message?.content;
|
||||
return typeof translated === 'string' ? translated.trim() : null;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { AppDebug } from '../services/appConfig';
|
||||
import { logWebRequest } from '../services/appConfig';
|
||||
import { branches } from '../shared/constants';
|
||||
import { changeLogRemoveLinks } from '../shared/utils';
|
||||
|
||||
@@ -222,9 +222,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
|
||||
return;
|
||||
}
|
||||
pendingVRCXUpdate.value = false;
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(url, json, response);
|
||||
}
|
||||
logWebRequest('[EXTERNAL GET]', url, `(${response.status})`, json);
|
||||
if (json === Object(json) && json.name && json.published_at) {
|
||||
changeLogDialog.value.buildName = json.name;
|
||||
changeLogDialog.value.changeLog = changeLogRemoveLinks(json.body);
|
||||
@@ -309,9 +307,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (AppDebug.debugWebRequests) {
|
||||
console.log(url, json, response);
|
||||
}
|
||||
logWebRequest('[EXTERNAL GET]', url, `(${response.status})`, json);
|
||||
const releases = [];
|
||||
if (typeof json !== 'object' || json.message) {
|
||||
toast.error(
|
||||
|
||||
Reference in New Issue
Block a user