refactor: app.js (#1291)

* refactor: frontend

* Fix avatar gallery sort

* Update .NET dependencies

* Update npm dependencies

electron v37.1.0

* bulkRefreshFriends

* fix dark theme

* Remove crowdin

* Fix config.json dialog not updating

* VRCX log file fixes & add Cef log

* Remove SharedVariable, fix startup

* Revert init theme change

* Logging date not working? Fix WinformThemer designer error

* Add Cef request hander, no more escaping main page

* clean

* fix

* fix

* clean

* uh

* Apply thememode at startup, fixes random user colours

* Split database into files

* Instance info remove empty lines

* Open external VRC links with VRCX

* Electron fixes

* fix userdialog style

* ohhhh

* fix store

* fix store

* fix: load all group members after kicking a user

* fix: world dialog favorite button style

* fix: Clear VRCX Cache Timer input value

* clean

* Fix VR overlay

* Fix VR overlay 2

* Fix Discord discord rich presence for RPC worlds

* Clean up age verified user tags

* Fix playerList being occupied after program reload

* no `this`

* Fix login stuck loading

* writable: false

* Hide dialogs on logout

* add flush sync option

* rm LOGIN event

* rm LOGOUT event

* remove duplicate event listeners

* remove duplicate event listeners

* clean

* remove duplicate event listeners

* clean

* fix theme style

* fix t

* clearable

* clean

* fix ipcEvent

* Small changes

* Popcorn Palace support

* Remove checkActiveFriends

* Clean up

* Fix dragEnterCef

* Block API requests when not logged in

* Clear state on login & logout

* Fix worldDialog instances not updating

* use <script setup>

* Fix avatar change event, CheckGameRunning at startup

* Fix image dragging

* fix

* Remove PWI

* fix updateLoop

* add webpack-dev-server to dev environment

* rm unnecessary chunks

* use <script setup>

* webpack-dev-server changes

* use <script setup>

* use <script setup>

* Fix UGC text size

* Split login event

* t

* use <script setup>

* fix

* Update .gitignore and enable checkJs in jsconfig

* fix i18n t

* use <script setup>

* use <script setup>

* clean

* global types

* fix

* use checkJs for debugging

* Add watchState for login watchers

* fix .vue template

* type fixes

* rm Vue.filter

* Cef v138.0.170, VC++ 2022

* Settings fixes

* Remove 'USER:CURRENT'

* clean up 2FA callbacks

* remove userApply

* rm i18n import

* notification handling to use notification store methods

* refactor favorite handling to use favorite store methods and clean up event emissions

* refactor moderation handling to use dedicated functions for player moderation events

* refactor friend handling to use dedicated functions for friend events

* Fix program startup, move lang init

* Fix friend state

* Fix status change error

* Fix user notes diff

* fix

* rm group event

* rm auth event

* rm avatar event

* clean

* clean

* getUser

* getFriends

* getFavoriteWorlds, getFavoriteAvatars

* AvatarGalleryUpload btn style & package.json update

* Fix friend requests

* Apply user

* Apply world

* Fix note diff

* Fix VR overlay

* Fixes

* Update build scripts

* Apply avatar

* Apply instance

* Apply group

* update hidden VRC+ badge

* Fix sameInstance "private"

* fix 502/504 API errors

* fix 502/504 API errors

* clean

* Fix friend in same instance on orange showing twice in friends list

* Add back in broken friend state repair methods

* add types

---------

Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
pa
2025-07-14 12:00:08 +09:00
committed by GitHub
parent 952fd77ed5
commit f4f78bb5ec
323 changed files with 47745 additions and 43326 deletions

View File

@@ -1,24 +1,24 @@
<template>
<safe-dialog
ref="worldImportDialog"
ref="worldImportDialogRef"
:visible.sync="isVisible"
:title="$t('dialog.world_import.header')"
:title="t('dialog.world_import.header')"
width="650px"
top="10vh"
class="x-dialog">
<div style="display: flex; align-items: center; justify-content: space-between">
<div style="font-size: 12px">{{ $t('dialog.world_import.description') }}</div>
<div style="font-size: 12px">{{ t('dialog.world_import.description') }}</div>
<div style="display: flex; align-items: center">
<div v-if="worldImportDialog.progress">
{{ $t('dialog.world_import.process_progress') }}
{{ t('dialog.world_import.process_progress') }}
{{ worldImportDialog.progress }} / {{ worldImportDialog.progressTotal }}
<i class="el-icon-loading" style="margin: 0 5px"></i>
</div>
<el-button v-if="worldImportDialog.loading" size="small" @click="cancelWorldImport">
{{ $t('dialog.world_import.cancel') }}
{{ t('dialog.world_import.cancel') }}
</el-button>
<el-button v-else size="small" :disabled="!worldImportDialog.input" @click="processWorldImportList">
{{ $t('dialog.world_import.process_list') }}
{{ t('dialog.world_import.process_list') }}
</el-button>
</div>
</div>
@@ -41,12 +41,12 @@
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $t('dialog.world_import.select_vrchat_group_placeholder') }}
{{ t('dialog.world_import.select_vrchat_group_placeholder') }}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<template v-for="groupAPI in API.favoriteWorldGroups">
<template v-for="groupAPI in favoriteWorldGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
@@ -65,7 +65,7 @@
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $t('dialog.world_import.select_local_group_placeholder') }}
{{ t('dialog.world_import.select_local_group_placeholder') }}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
@@ -90,7 +90,7 @@
</div>
<div>
<el-button size="small" :disabled="worldImportTable.data.length === 0" @click="clearWorldImportTable">
{{ $t('dialog.world_import.clear_table') }}
{{ t('dialog.world_import.clear_table') }}
</el-button>
<el-button
size="small"
@@ -102,27 +102,27 @@
!worldImportDialog.worldImportLocalFavoriteGroup)
"
@click="importWorldImportTable">
{{ $t('dialog.world_import.import') }}
{{ t('dialog.world_import.import') }}
</el-button>
</div>
</div>
<span v-if="worldImportDialog.importProgress" style="margin: 10px">
<i class="el-icon-loading" style="margin-right: 5px"></i>
{{ $t('dialog.world_import.import_progress') }}
{{ t('dialog.world_import.import_progress') }}
{{ worldImportDialog.importProgress }}/{{ worldImportDialog.importProgressTotal }}
</span>
<br />
<template v-if="worldImportDialog.errors">
<el-button size="small" @click="worldImportDialog.errors = ''">
{{ $t('dialog.world_import.clear_errors') }}
{{ t('dialog.world_import.clear_errors') }}
</el-button>
<h2 style="font-weight: bold; margin: 5px 0">
{{ $t('dialog.world_import.errors') }}
{{ t('dialog.world_import.errors') }}
</h2>
<pre style="white-space: pre-wrap; font-size: 12px" v-text="worldImportDialog.errors"></pre>
</template>
<data-tables v-loading="worldImportDialog.loading" v-bind="worldImportTable" style="margin-top: 10px">
<el-table-column :label="$t('table.import.image')" width="70" prop="thumbnailImageUrl">
<el-table-column :label="t('table.import.image')" width="70" prop="thumbnailImageUrl">
<template slot-scope="scope">
<el-popover placement="right" height="500px" trigger="hover">
<img slot="reference" v-lazy="scope.row.thumbnailImageUrl" class="friends-list-avatar" />
@@ -134,12 +134,12 @@
</el-popover>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.name')" prop="name">
<el-table-column :label="t('table.import.name')" prop="name">
<template slot-scope="scope">
<span class="x-link" @click="showWorldDialog(scope.row.id)" v-text="scope.row.name"></span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.author')" width="120" prop="authorName">
<el-table-column :label="t('table.import.author')" width="120" prop="authorName">
<template slot-scope="scope">
<span
class="x-link"
@@ -147,7 +147,7 @@
v-text="scope.row.authorName"></span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.status')" width="70" prop="releaseStatus">
<el-table-column :label="t('table.import.status')" width="70" prop="releaseStatus">
<template slot-scope="scope">
<span
:style="{
@@ -163,7 +163,7 @@
"></span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.action')" width="90" align="right">
<el-table-column :label="t('table.import.action')" width="90" align="right">
<template slot-scope="scope">
<el-button
type="text"
@@ -176,185 +176,193 @@
</safe-dialog>
</template>
<script>
<script setup>
import { ref, watch, computed, getCurrentInstance } from 'vue';
import { useI18n } from 'vue-i18n-bridge';
import { storeToRefs } from 'pinia';
import { favoriteRequest, worldRequest } from '../../../api';
import utils from '../../../classes/utils';
import { adjustDialogZ, removeFromArray } from '../../../shared/utils';
import { useFavoriteStore, useGalleryStore, useUserStore, useWorldStore } from '../../../stores';
export default {
name: 'WorldImportDialog',
inject: ['API', 'showFullscreenImageDialog', 'showUserDialog', 'adjustDialogZ', 'showWorldDialog'],
props: {
worldImportDialogVisible: Boolean,
worldImportDialogInput: String,
getLocalWorldFavoriteGroupLength: Function,
localWorldFavoriteGroups: Array
const { showUserDialog } = useUserStore();
const { favoriteWorldGroups, worldImportDialogInput, worldImportDialogVisible, localWorldFavoriteGroups } =
storeToRefs(useFavoriteStore());
const { getLocalWorldFavoriteGroupLength, addLocalWorldFavorite } = useFavoriteStore();
const { showWorldDialog } = useWorldStore();
const { showFullscreenImageDialog } = useGalleryStore();
const emit = defineEmits(['update:worldImportDialogInput']);
const { proxy } = getCurrentInstance();
const { t } = useI18n();
const worldImportDialogRef = ref(null);
const worldImportDialog = ref({
loading: false,
progress: 0,
progressTotal: 0,
input: '',
worldIdList: new Set(),
errors: '',
worldImportFavoriteGroup: null,
worldImportLocalFavoriteGroup: null,
importProgress: 0,
importProgressTotal: 0
});
const worldImportTable = ref({
data: [],
tableProps: {
stripe: true,
size: 'mini'
},
data() {
return {
worldImportDialog: {
loading: false,
progress: 0,
progressTotal: 0,
input: '',
worldIdList: new Set(),
errors: '',
worldImportFavoriteGroup: null,
worldImportLocalFavoriteGroup: null,
importProgress: 0,
importProgressTotal: 0
},
worldImportTable: {
data: [],
tableProps: {
stripe: true,
size: 'mini'
},
layout: 'table'
}
};
layout: 'table'
});
const isVisible = computed({
get() {
return worldImportDialogVisible.value;
},
computed: {
isVisible: {
get() {
return this.worldImportDialogVisible;
},
set(visible) {
this.$emit('update:world-import-dialog-visible', visible);
}
}
},
watch: {
worldImportDialogVisible(visible) {
if (visible) {
this.adjustDialogZ(this.$refs.worldImportDialog.$el);
this.clearWorldImportTable();
this.resetWorldImport();
if (this.worldImportDialogInput) {
this.worldImportDialog.input = this.worldImportDialogInput;
this.processWorldImportList();
this.$emit('update:world-import-dialog-input', '');
}
}
}
},
methods: {
resetWorldImport() {
this.worldImportDialog.input = '';
this.worldImportDialog.errors = '';
},
async processWorldImportList() {
const D = this.worldImportDialog;
D.loading = true;
const regexWorldId = /wrld_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
let match = [];
const worldIdList = new Set();
while ((match = regexWorldId.exec(D.input)) !== null) {
worldIdList.add(match[0]);
}
D.input = '';
D.errors = '';
D.progress = 0;
D.progressTotal = worldIdList.size;
const data = Array.from(worldIdList);
for (let i = 0; i < data.length; ++i) {
if (!this.isVisible) {
this.resetWorldImport();
}
if (!D.loading || !this.isVisible) {
break;
}
const worldId = data[i];
if (!D.worldIdList.has(worldId)) {
try {
const args = await worldRequest.getWorld({
worldId
});
this.worldImportTable.data.push(args.ref);
D.worldIdList.add(worldId);
} catch (err) {
D.errors = D.errors.concat(`WorldId: ${worldId}\n${err}\n\n`);
}
}
D.progress++;
if (D.progress === worldIdList.size) {
D.progress = 0;
}
}
D.loading = false;
},
deleteItemWorldImport(ref) {
utils.removeFromArray(this.worldImportTable.data, ref);
this.worldImportDialog.worldIdList.delete(ref.id);
},
set(visible) {
worldImportDialogVisible.value = visible;
}
});
clearWorldImportTable() {
this.worldImportTable.data = [];
this.worldImportDialog.worldIdList = new Set();
},
selectWorldImportGroup(group) {
this.worldImportDialog.worldImportLocalFavoriteGroup = null;
this.worldImportDialog.worldImportFavoriteGroup = group;
},
selectWorldImportLocalGroup(group) {
this.worldImportDialog.worldImportFavoriteGroup = null;
this.worldImportDialog.worldImportLocalFavoriteGroup = group;
},
cancelWorldImport() {
this.worldImportDialog.loading = false;
},
async importWorldImportTable() {
const D = this.worldImportDialog;
if (!D.worldImportFavoriteGroup && !D.worldImportLocalFavoriteGroup) {
return;
watch(
() => worldImportDialogVisible.value,
(visible) => {
if (visible) {
adjustDialogZ(worldImportDialogRef.value.$el);
clearWorldImportTable();
resetWorldImport();
if (worldImportDialogInput.value) {
worldImportDialog.value.input = worldImportDialogInput.value;
processWorldImportList();
emit('update:worldImportDialogInput', '');
}
D.loading = true;
const data = [...this.worldImportTable.data].reverse();
D.importProgressTotal = data.length;
let ref = '';
try {
for (let i = data.length - 1; i >= 0; i--) {
if (!D.loading || !this.isVisible) {
break;
}
ref = data[i];
if (D.worldImportFavoriteGroup) {
await this.addFavoriteWorld(ref, D.worldImportFavoriteGroup, false);
} else if (D.worldImportLocalFavoriteGroup) {
this.$emit('addLocalWorldFavorite', ref.id, D.worldImportLocalFavoriteGroup);
}
utils.removeFromArray(this.worldImportTable.data, ref);
D.worldIdList.delete(ref.id);
D.importProgress++;
}
} catch (err) {
D.errors = `Name: ${ref.name}\nWorldId: ${ref.id}\n${err}\n\n`;
} finally {
D.importProgress = 0;
D.importProgressTotal = 0;
D.loading = false;
}
},
addFavoriteWorld(ref, group, message) {
return favoriteRequest
.addFavorite({
type: 'world',
favoriteId: ref.id,
tags: group.name
})
.then((args) => {
if (message) {
this.$message({
message: 'World added to favorites',
type: 'success'
});
}
return args;
});
}
}
};
);
function resetWorldImport() {
worldImportDialog.value.input = '';
worldImportDialog.value.errors = '';
}
async function processWorldImportList() {
const D = worldImportDialog.value;
D.loading = true;
const regexWorldId = /wrld_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
let match = [];
const worldIdList = new Set();
while ((match = regexWorldId.exec(D.input)) !== null) {
worldIdList.add(match[0]);
}
D.input = '';
D.errors = '';
D.progress = 0;
D.progressTotal = worldIdList.size;
const data = Array.from(worldIdList);
for (let i = 0; i < data.length; ++i) {
if (!isVisible.value) {
resetWorldImport();
}
if (!D.loading || !isVisible.value) {
break;
}
const worldId = data[i];
if (!D.worldIdList.has(worldId)) {
try {
const args = await worldRequest.getWorld({
worldId
});
worldImportTable.value.data.push(args.ref);
D.worldIdList.add(worldId);
} catch (err) {
D.errors = D.errors.concat(`WorldId: ${worldId}\n${err}\n\n`);
}
}
D.progress++;
if (D.progress === worldIdList.size) {
D.progress = 0;
}
}
D.loading = false;
}
function deleteItemWorldImport(ref) {
removeFromArray(worldImportTable.value.data, ref);
worldImportDialog.value.worldIdList.delete(ref.id);
}
function clearWorldImportTable() {
worldImportTable.value.data = [];
worldImportDialog.value.worldIdList = new Set();
}
function selectWorldImportGroup(group) {
worldImportDialog.value.worldImportLocalFavoriteGroup = null;
worldImportDialog.value.worldImportFavoriteGroup = group;
}
function selectWorldImportLocalGroup(group) {
worldImportDialog.value.worldImportFavoriteGroup = null;
worldImportDialog.value.worldImportLocalFavoriteGroup = group;
}
function cancelWorldImport() {
worldImportDialog.value.loading = false;
}
async function importWorldImportTable() {
const D = worldImportDialog.value;
if (!D.worldImportFavoriteGroup && !D.worldImportLocalFavoriteGroup) {
return;
}
D.loading = true;
const data = [...worldImportTable.value.data].reverse();
D.importProgressTotal = data.length;
let ref = '';
try {
for (let i = data.length - 1; i >= 0; i--) {
if (!D.loading || !isVisible.value) {
break;
}
ref = data[i];
if (D.worldImportFavoriteGroup) {
await addFavoriteWorld(ref, D.worldImportFavoriteGroup, false);
} else if (D.worldImportLocalFavoriteGroup) {
addLocalWorldFavorite(ref, D.worldImportLocalFavoriteGroup);
}
removeFromArray(worldImportTable.value.data, ref);
D.worldIdList.delete(ref.id);
D.importProgress++;
}
} catch (err) {
D.errors = `Name: ${ref.name}\nWorldId: ${ref.id}\n${err}\n\n`;
} finally {
D.importProgress = 0;
D.importProgressTotal = 0;
D.loading = false;
}
}
function addFavoriteWorld(ref, group, message) {
return favoriteRequest
.addFavorite({
type: 'world',
favoriteId: ref.id,
tags: group.name
})
.then((args) => {
if (message) {
proxy.$message({
message: 'World added to favorites',
type: 'success'
});
}
return args;
});
}
</script>