refactor: Organize Project Structure (#1211)

* refactor: Organize Project Structure

* fix

* fix

* rm security

* fix
This commit is contained in:
pa
2025-04-18 15:04:03 +09:00
committed by GitHub
parent 59d3ead781
commit 6bda44be52
106 changed files with 172 additions and 165 deletions
+318
View File
@@ -0,0 +1,318 @@
<template>
<div v-show="menuActiveIndex === 'favorite'" class="x-container">
<div style="font-size: 13px; position: absolute; display: flex; right: 0; z-index: 1; margin-right: 15px">
<div v-if="editFavoritesMode" style="display: inline-block; margin-right: 10px">
<el-button size="small" @click="clearBulkFavoriteSelection">{{ $t('view.favorite.clear') }}</el-button>
<el-button size="small" @click="bulkCopyFavoriteSelection">{{ $t('view.favorite.copy') }}</el-button>
<el-button size="small" @click="showBulkUnfavoriteSelectionConfirm">{{
$t('view.favorite.bulk_unfavorite')
}}</el-button>
</div>
<div style="display: flex; align-items: center; margin-right: 10px">
<span class="name">{{ $t('view.favorite.edit_mode') }}</span>
<el-switch v-model="editFavoritesMode" style="margin-left: 5px"></el-switch>
</div>
<el-tooltip placement="bottom" :content="$t('view.favorite.refresh_tooltip')" :disabled="hideTooltips">
<el-button
type="default"
:loading="API.isFavoriteLoading"
@click="
API.refreshFavorites();
getLocalWorldFavorites();
"
size="small"
icon="el-icon-refresh"
circle></el-button>
</el-tooltip>
</div>
<el-tabs v-model="currentTabName" v-loading="API.isFavoriteLoading" type="card" style="height: 100%">
<el-tab-pane name="friend" :label="$t('view.favorite.friends.header')" lazy>
<FavoritesFriendTab
:favorite-friends="favoriteFriends"
:sort-favorites.sync="isSortByTime"
:hide-tooltips="hideTooltips"
:grouped-by-group-key-favorite-friends="groupedByGroupKeyFavoriteFriends"
:edit-favorites-mode="editFavoritesMode"
@show-friend-import-dialog="showFriendImportDialog"
@save-sort-favorites-option="saveSortFavoritesOption"
@change-favorite-group-name="changeFavoriteGroupName" />
</el-tab-pane>
<el-tab-pane name="world" :label="$t('view.favorite.worlds.header')" lazy>
<FavoritesWorldTab
@show-world-import-dialog="showWorldImportDialog"
@save-sort-favorites-option="saveSortFavoritesOption"
@change-favorite-group-name="changeFavoriteGroupName"
@new-instance-self-invite="newInstanceSelfInvite"
@refresh-local-world-favorite="refreshLocalWorldFavorites"
@delete-local-world-favorite-group="deleteLocalWorldFavoriteGroup"
@remove-local-world-favorite="removeLocalWorldFavorite"
@rename-local-world-favorite-group="renameLocalWorldFavoriteGroup"
@new-local-world-favorite-group="newLocalWorldFavoriteGroup"
:sort-favorites.sync="isSortByTime"
:hide-tooltips="hideTooltips"
:favorite-worlds="favoriteWorlds"
:edit-favorites-mode="editFavoritesMode"
:shift-held="shiftHeld"
:refresh-local-world-favorites="refreshLocalWorldFavorites"
:local-world-favorite-groups="localWorldFavoriteGroups"
:local-world-favorites="localWorldFavorites"
:local-world-favorites-list="localWorldFavoritesList" />
</el-tab-pane>
<el-tab-pane name="avatar" :label="$t('view.favorite.avatars.header')" lazy>
<FavoritesAvatarTab
:sort-favorites.sync="isSortByTime"
:hide-tooltips="hideTooltips"
:shift-held="shiftHeld"
:edit-favorites-mode="editFavoritesMode"
:avatar-history-array="avatarHistoryArray"
:refreshing-local-favorites="refreshingLocalFavorites"
:local-avatar-favorite-groups="localAvatarFavoriteGroups"
:local-avatar-favorites="localAvatarFavorites"
:favorite-avatars="favoriteAvatars"
:local-avatar-favorites-list="localAvatarFavoritesList"
@show-avatar-import-dialog="showAvatarImportDialog"
@save-sort-favorites-option="saveSortFavoritesOption"
@change-favorite-group-name="changeFavoriteGroupName"
@remove-local-avatar-favorite="removeLocalAvatarFavorite"
@select-avatar-with-confirmation="selectAvatarWithConfirmation"
@prompt-clear-avatar-history="promptClearAvatarHistory"
@prompt-new-local-avatar-favorite-group="promptNewLocalAvatarFavoriteGroup"
@refresh-local-avatar-favorites="refreshLocalAvatarFavorites"
@prompt-local-avatar-favorite-group-rename="promptLocalAvatarFavoriteGroupRename"
@prompt-local-avatar-favorite-group-delete="promptLocalAvatarFavoriteGroupDelete" />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import FavoritesFriendTab from './components/FavoritesFriendTab.vue';
import FavoritesWorldTab from './components/FavoritesWorldTab.vue';
import FavoritesAvatarTab from './components/FavoritesAvatarTab.vue';
import { avatarRequest, favoriteRequest, worldRequest } from '../../api';
import * as workerTimers from 'worker-timers';
export default {
name: 'FavoritesTab',
components: {
FavoritesFriendTab,
FavoritesWorldTab,
FavoritesAvatarTab
},
inject: ['API'],
props: {
menuActiveIndex: String,
hideTooltips: Boolean,
shiftHeld: Boolean,
favoriteFriends: Array,
sortFavorites: Boolean,
groupedByGroupKeyFavoriteFriends: Object,
favoriteWorlds: Array,
localWorldFavoriteGroups: Array,
localWorldFavorites: Object,
avatarHistoryArray: Array,
localAvatarFavoriteGroups: Array,
localAvatarFavorites: Object,
favoriteAvatars: Array,
localAvatarFavoritesList: Array,
localWorldFavoritesList: Array
},
data() {
return {
editFavoritesMode: false,
refreshingLocalFavorites: false,
currentTabName: 'friend'
};
},
computed: {
isSortByTime: {
get() {
return this.sortFavorites;
},
set(value) {
this.$emit('update:sort-favorites', value);
}
}
},
methods: {
showBulkUnfavoriteSelectionConfirm() {
const elementsTicked = [];
// check favorites type
for (const ctx of this.favoriteFriends) {
if (ctx.$selected) {
elementsTicked.push(ctx.id);
}
}
for (const ctx of this.favoriteWorlds) {
if (ctx.$selected) {
elementsTicked.push(ctx.id);
}
}
for (const ctx of this.favoriteAvatars) {
if (ctx.$selected) {
elementsTicked.push(ctx.id);
}
}
if (elementsTicked.length === 0) {
return;
}
this.$confirm(
`Are you sure you want to unfavorite ${elementsTicked.length} favorites?
This action cannot be undone.`,
`Delete ${elementsTicked.length} favorites?`,
{
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
this.bulkUnfavoriteSelection(elementsTicked);
}
}
}
);
},
bulkUnfavoriteSelection(elementsTicked) {
for (const id of elementsTicked) {
favoriteRequest.deleteFavorite({
objectId: id
});
}
this.editFavoritesMode = false;
},
changeFavoriteGroupName(ctx) {
this.$prompt(
$t('prompt.change_favorite_group_name.description'),
$t('prompt.change_favorite_group_name.header'),
{
distinguishCancelAndClose: true,
cancelButtonText: $t('prompt.change_favorite_group_name.cancel'),
confirmButtonText: $t('prompt.change_favorite_group_name.change'),
inputPlaceholder: $t('prompt.change_favorite_group_name.input_placeholder'),
inputValue: ctx.displayName,
inputPattern: /\S+/,
inputErrorMessage: $t('prompt.change_favorite_group_name.input_error'),
callback: (action, instance) => {
if (action === 'confirm') {
favoriteRequest
.saveFavoriteGroup({
type: ctx.type,
group: ctx.name,
displayName: instance.inputValue
})
.then(() => {
this.$message({
message: $t('prompt.change_favorite_group_name.message.success'),
type: 'success'
});
// load new group name
this.API.refreshFavoriteGroups();
});
}
}
}
);
},
async refreshLocalAvatarFavorites() {
if (this.refreshingLocalFavorites) {
return;
}
this.refreshingLocalFavorites = true;
for (const avatarId of this.localAvatarFavoritesList) {
if (!this.refreshingLocalFavorites) {
break;
}
try {
await avatarRequest.getAvatar({
avatarId
});
} catch (err) {
console.error(err);
}
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 1000);
});
}
this.refreshingLocalFavorites = false;
},
async refreshLocalWorldFavorites() {
if (this.refreshingLocalFavorites) {
return;
}
this.refreshingLocalFavorites = true;
for (const worldId of this.localWorldFavoritesList) {
if (!this.refreshingLocalFavorites) {
break;
}
try {
await worldRequest.getWorld({
worldId
});
} catch (err) {
console.error(err);
}
await new Promise((resolve) => {
workerTimers.setTimeout(resolve, 1000);
});
}
this.refreshingLocalFavorites = false;
},
clearBulkFavoriteSelection() {
this.$emit('clear-bulk-favorite-selection');
},
bulkCopyFavoriteSelection() {
this.$emit('bulk-copy-favorite-selection', this.currentTabName);
},
getLocalWorldFavorites() {
this.$emit('get-local-world-favorites');
},
showFriendImportDialog() {
this.$emit('show-friend-import-dialog');
},
saveSortFavoritesOption() {
this.$emit('save-sort-favorites-option');
},
showWorldImportDialog() {
this.$emit('show-world-import-dialog');
},
newInstanceSelfInvite(worldId) {
this.$emit('new-instance-self-invite', worldId);
},
deleteLocalWorldFavoriteGroup(group) {
this.$emit('delete-local-world-favorite-group', group);
},
removeLocalWorldFavorite(worldId, group) {
this.$emit('remove-local-world-favorite', worldId, group);
},
showAvatarImportDialog() {
this.$emit('show-avatar-import-dialog');
},
removeLocalAvatarFavorite(avatarId, group) {
this.$emit('remove-local-avatar-favorite', avatarId, group);
},
selectAvatarWithConfirmation(id) {
this.$emit('select-avatar-with-confirmation', id);
},
promptClearAvatarHistory() {
this.$emit('prompt-clear-avatar-history');
},
promptNewLocalAvatarFavoriteGroup() {
this.$emit('prompt-new-local-avatar-favorite-group');
},
promptLocalAvatarFavoriteGroupRename(group) {
this.$emit('prompt-local-avatar-favorite-group-rename', group);
},
promptLocalAvatarFavoriteGroupDelete(group) {
this.$emit('prompt-local-avatar-favorite-group-delete', group);
},
renameLocalWorldFavoriteGroup(inputValue, group) {
this.$emit('rename-local-world-favorite-group', inputValue, group);
},
newLocalWorldFavoriteGroup(inputValue) {
this.$emit('new-local-world-favorite-group', inputValue);
}
}
};
</script>
@@ -0,0 +1,234 @@
<template>
<div @click="$emit('click')">
<div class="x-friend-item">
<template v-if="isLocalFavorite ? favorite.name : favorite.ref">
<div class="avatar">
<img v-lazy="smallThumbnail" />
</div>
<div class="detail">
<span class="name" v-text="localFavFakeRef.name"></span>
<span class="extra" v-text="localFavFakeRef.authorName"></span>
</div>
<template v-if="editFavoritesMode">
<el-dropdown trigger="click" size="mini" style="margin-left: 5px" @click.native.stop>
<el-tooltip placement="top" :content="tooltipContent" :disabled="hideTooltips">
<el-button type="default" icon="el-icon-back" size="mini" circle></el-button>
</el-tooltip>
<el-dropdown-menu slot="dropdown">
<template
v-for="groupAPI in API.favoriteAvatarGroups"
v-if="isLocalFavorite || groupAPI.name !== group.name">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="handleDropdownItemClick(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }} / {{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-button v-if="!isLocalFavorite" type="text" size="mini" style="margin-left: 5px" @click.stop>
<el-checkbox v-model="isSelected"></el-checkbox>
</el-button>
</template>
<template v-else-if="!isLocalFavorite">
<el-tooltip
v-if="favorite.deleted"
placement="left"
:content="$t('view.favorite.unavailable_tooltip')">
<i class="el-icon-warning" style="color: #f56c6c; margin-left: 5px"></i>
</el-tooltip>
<el-tooltip
v-if="favorite.ref.releaseStatus === 'private'"
placement="left"
:content="$t('view.favorite.private')">
<i class="el-icon-warning" style="color: #e6a23c; margin-left: 5px"></i>
</el-tooltip>
<el-tooltip
v-if="favorite.ref.releaseStatus !== 'private' && !favorite.deleted"
placement="left"
:content="$t('view.favorite.select_avatar_tooltip')"
:disabled="hideTooltips">
<el-button
:disabled="API.currentUser.currentAvatar === favorite.id"
size="mini"
icon="el-icon-check"
circle
style="margin-left: 5px"
@click.stop="selectAvatarWithConfirmation"></el-button>
</el-tooltip>
<el-tooltip
placement="right"
:content="$t('view.favorite.unfavorite_tooltip')"
:disabled="hideTooltips">
<el-button
v-if="shiftHeld"
size="mini"
icon="el-icon-close"
circle
style="color: #f56c6c; margin-left: 5px"
@click.stop="deleteFavorite(favorite.id)"></el-button>
<el-button
v-else
type="default"
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
@click.stop="showFavoriteDialog('avatar', favorite.id)"></el-button>
</el-tooltip>
</template>
<template v-else>
<el-tooltip
placement="left"
:content="$t('view.favorite.select_avatar_tooltip')"
:disabled="hideTooltips">
<el-button
:disabled="API.currentUser.currentAvatar === favorite.id"
size="mini"
circle
style="margin-left: 5px"
icon="el-icon-check"
@click.stop="selectAvatarWithConfirmation" />
</el-tooltip>
</template>
<el-tooltip
v-if="isLocalFavorite"
placement="right"
:content="$t('view.favorite.unfavorite_tooltip')"
:disabled="hideTooltips">
<el-button
v-if="shiftHeld"
size="mini"
icon="el-icon-close"
circle
style="color: #f56c6c; margin-left: 5px"
@click.stop="removeLocalAvatarFavorite" />
<el-button
v-else
type="default"
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
@click.stop="showFavoriteDialog('avatar', favorite.id)"
/></el-tooltip>
</template>
<template v-else>
<div class="avatar"></div>
<div class="detail">
<span class="name" v-text="favorite.name || favorite.id"></span>
</div>
<el-button
type="text"
icon="el-icon-close"
size="mini"
style="margin-left: 5px"
@click.stop="deleteFavorite(favorite.id)"></el-button>
</template>
</div>
</div>
</template>
<script>
import { favoriteRequest } from '../../../api';
export default {
name: 'FavoritesAvatarItem',
inject: ['API', 'showFavoriteDialog'],
props: {
favorite: Object,
group: [Object, String],
editFavoritesMode: Boolean,
shiftHeld: Boolean,
hideTooltips: Boolean,
isLocalFavorite: Boolean
},
computed: {
isSelected: {
get() {
return this.favorite.$selected;
},
set(value) {
this.$emit('handle-select', value);
}
},
localFavFakeRef() {
// local favorite no "ref" property
return this.isLocalFavorite ? this.favorite : this.favorite.ref;
},
tooltipContent() {
return $t(this.isLocalFavorite ? 'view.favorite.copy_tooltip' : 'view.favorite.move_tooltip');
},
smallThumbnail() {
return (
this.localFavFakeRef.thumbnailImageUrl.replace('256', '128') ||
this.localFavFakeRef.thumbnailImageUrl
);
}
},
methods: {
moveFavorite(ref, group, type) {
favoriteRequest
.deleteFavorite({
objectId: ref.id
})
.then(() => {
favoriteRequest.addFavorite({
type,
favoriteId: ref.id,
tags: group.name
});
});
},
selectAvatarWithConfirmation() {
this.$emit('select-avatar-with-confirmation', this.favorite.id);
},
deleteFavorite(objectId) {
favoriteRequest.deleteFavorite({
objectId
});
// FIXME: 메시지 수정
// this.$confirm('Continue? Delete Favorite', 'Confirm', {
// confirmButtonText: 'Confirm',
// cancelButtonText: 'Cancel',
// type: 'info',
// callback: (action) => {
// if (action === 'confirm') {
// API.deleteFavorite({
// objectId
// });
// }
// }
// });
},
addFavoriteAvatar(groupAPI) {
return favoriteRequest
.addFavorite({
type: 'avatar',
favoriteId: this.favorite.id,
tags: groupAPI.name
})
.then((args) => {
this.$message({
message: 'Avatar added to favorites',
type: 'success'
});
return args;
});
},
handleDropdownItemClick(groupAPI) {
if (this.isLocalFavorite) {
this.addFavoriteAvatar(groupAPI);
} else {
this.moveFavorite(this.favorite.ref, groupAPI, 'avatar');
}
},
removeLocalAvatarFavorite() {
this.$emit('remove-local-avatar-favorite', this.favorite.id, this.group);
}
}
};
</script>
@@ -0,0 +1,68 @@
<template>
<div @click="$emit('click')">
<div class="x-friend-item">
<div class="avatar">
<img v-lazy="smallThumbnail" />
</div>
<div class="detail">
<span class="name" v-text="favorite.name"></span>
<span class="extra" v-text="favorite.authorName"></span>
</div>
<el-tooltip placement="left" :content="$t('view.favorite.select_avatar_tooltip')" :disabled="hideTooltips">
<el-button
:disabled="API.currentUser.currentAvatar === favorite.id"
size="mini"
icon="el-icon-check"
circle
style="margin-left: 5px"
@click.stop="selectAvatarWithConfirmation"></el-button>
</el-tooltip>
<template v-if="API.cachedFavoritesByObjectId.has(favorite.id)">
<el-tooltip placement="right" content="Unfavorite" :disabled="hideTooltips">
<el-button
type="default"
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
@click.stop="showFavoriteDialog('avatar', favorite.id)"></el-button>
</el-tooltip>
</template>
<template v-else>
<el-tooltip placement="right" content="Favorite" :disabled="hideTooltips">
<el-button
type="default"
icon="el-icon-star-off"
size="mini"
circle
style="margin-left: 5px"
@click.stop="showFavoriteDialog('avatar', favorite.id)"></el-button>
</el-tooltip>
</template>
</div>
</div>
</template>
<script>
export default {
name: 'FavoritesAvatarLocalHistoryItem',
inject: ['API', 'showFavoriteDialog'],
props: {
favorite: {
type: Object,
required: true
},
hideTooltips: Boolean
},
computed: {
smallThumbnail() {
return this.favorite.thumbnailImageUrl.replace('256', '128') || this.favorite.thumbnailImageUrl;
}
},
methods: {
selectAvatarWithConfirmation() {
this.$emit('select-avatar-with-confirmation', this.favorite.id);
}
}
};
</script>
@@ -0,0 +1,400 @@
<template>
<div>
<div style="display: flex; align-items: center; justify-content: space-between">
<div>
<el-button size="small" @click="showAvatarExportDialog">
{{ $t('view.favorite.export') }}
</el-button>
<el-button size="small" style="margin-left: 5px" @click="showAvatarImportDialog">
{{ $t('view.favorite.import') }}
</el-button>
</div>
<div style="display: flex; align-items: center; font-size: 13px; margin-right: 10px">
<span class="name" style="margin-right: 5px; line-height: 10px">
{{ $t('view.favorite.sort_by') }}
</span>
<el-radio-group v-model="sortFav" style="margin-right: 12px" @change="saveSortFavoritesOption">
<el-radio :label="false">
{{ $t('view.settings.appearance.appearance.sort_favorite_by_name') }}
</el-radio>
<el-radio :label="true">
{{ $t('view.settings.appearance.appearance.sort_favorite_by_date') }}
</el-radio>
</el-radio-group>
<el-input
v-model="avatarFavoriteSearch"
clearable
size="mini"
:placeholder="$t('view.favorite.avatars.search')"
style="width: 200px"
@input="searchAvatarFavorites" />
</div>
</div>
<div class="x-friend-list" style="margin-top: 10px">
<div
v-for="favorite in avatarFavoriteSearchResults"
:key="favorite.id"
style="display: inline-block; width: 300px; margin-right: 15px"
@click="showAvatarDialog(favorite.id)">
<div class="x-friend-item">
<template v-if="favorite.name">
<div class="avatar">
<img v-lazy="favorite.thumbnailImageUrl" />
</div>
<div class="detail">
<span class="name" v-text="favorite.name" />
<span class="extra" v-text="favorite.authorName" />
</div>
</template>
<template v-else>
<div class="avatar"></div>
<div class="detail">
<span class="name" v-text="favorite.id" />
</div>
</template>
</div>
</div>
</div>
<span style="display: block; margin-top: 20px">
{{ $t('view.favorite.avatars.vrchat_favorites') }}
</span>
<el-collapse style="border: 0">
<el-collapse-item v-for="group in API.favoriteAvatarGroups" :key="group.name">
<template slot="title">
<span style="font-weight: bold; font-size: 14px; margin-left: 10px" v-text="group.displayName" />
<span style="color: #909399; font-size: 12px; margin-left: 10px">
{{ group.count }}/{{ group.capacity }}
</span>
<el-tooltip placement="top" :content="$t('view.favorite.rename_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-edit"
circle
style="margin-left: 10px"
@click.stop="changeFavoriteGroupName(group)" />
</el-tooltip>
<el-tooltip placement="right" :content="$t('view.favorite.clear_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
style="margin-left: 5px"
@click.stop="clearFavoriteGroup(group)" />
</el-tooltip>
</template>
<div v-if="group.count" class="x-friend-list" style="margin-top: 10px">
<FavoritesAvatarItem
v-for="favorite in groupedByGroupKeyFavoriteAvatars[group.key]"
:key="favorite.id"
:favorite="favorite"
:group="group"
:hide-tooltips="hideTooltips"
:shift-held="shiftHeld"
:edit-favorites-mode="editFavoritesMode"
style="display: inline-block; width: 300px; margin-right: 15px"
@handle-select="favorite.$selected = $event"
@remove-local-avatar-favorite="removeLocalAvatarFavorite"
@select-avatar-with-confirmation="selectAvatarWithConfirmation"
@click="showAvatarDialog(favorite.id)" />
</div>
<div
v-else
style="
padding-top: 25px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgb(144, 147, 153);
">
<span>No Data</span>
</div>
</el-collapse-item>
<el-collapse-item>
<template slot="title">
<span style="font-weight: bold; font-size: 14px; margin-left: 10px">Local History</span>
<span style="color: #909399; font-size: 12px; margin-left: 10px"
>{{ avatarHistoryArray.length }}/100</span
>
<el-tooltip placement="right" content="Clear" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
style="margin-left: 5px"
@click.stop="promptClearAvatarHistory"></el-button>
</el-tooltip>
</template>
<div v-if="avatarHistoryArray.length" class="x-friend-list" style="margin-top: 10px">
<FavoritesAvatarLocalHistoryItem
v-for="favorite in avatarHistoryArray"
:key="favorite.id"
style="display: inline-block; width: 300px; margin-right: 15px"
:favorite="favorite"
:hide-tooltips="hideTooltips"
@select-avatar-with-confirmation="selectAvatarWithConfirmation"
@click="showAvatarDialog(favorite.id)" />
</div>
<div
v-else
style="
padding-top: 25px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgb(144, 147, 153);
">
<span>No Data</span>
</div>
</el-collapse-item>
<span style="display: block; margin-top: 20px">{{ $t('view.favorite.avatars.local_favorites') }}</span>
<br />
<el-button size="small" :disabled="!isLocalUserVrcplusSupporter" @click="promptNewLocalAvatarFavoriteGroup">
{{ $t('view.favorite.avatars.new_group') }}
</el-button>
<el-button
v-if="!refreshingLocalFavorites"
size="small"
style="margin-left: 5px"
@click="refreshLocalAvatarFavorites">
{{ $t('view.favorite.avatars.refresh') }}
</el-button>
<el-button v-else size="small" style="margin-left: 5px" @click="refreshingLocalFavorites = false">
<i class="el-icon-loading" style="margin-right: 5px"></i>
<span>{{ $t('view.favorite.avatars.cancel_refresh') }}</span>
</el-button>
<el-collapse-item
v-for="group in localAvatarFavoriteGroups"
v-if="localAvatarFavorites[group]"
:key="group">
<template slot="title">
<span :style="{ fontWeight: 'bold', fontSize: '14px', marginLeft: '10px' }">{{ group }}</span>
<span :style="{ color: '#909399', fontSize: '12px', marginLeft: '10px' }">{{
getLocalAvatarFavoriteGroupLength(group)
}}</span>
<el-tooltip placement="top" :content="$t('view.favorite.rename_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-edit"
circle
:style="{ marginLeft: '5px' }"
@click.stop="promptLocalAvatarFavoriteGroupRename(group)"></el-button>
</el-tooltip>
<el-tooltip
placement="right"
:content="$t('view.favorite.delete_tooltip')"
:disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
:style="{ marginLeft: '5px' }"
@click.stop="promptLocalAvatarFavoriteGroupDelete(group)"></el-button>
</el-tooltip>
</template>
<div v-if="localAvatarFavorites[group].length" class="x-friend-list" :style="{ marginTop: '10px' }">
<FavoritesAvatarItem
v-for="favorite in localAvatarFavorites[group]"
:key="favorite.id"
is-local-favorite
:style="{ display: 'inline-block', width: '300px', marginRight: '15px' }"
:favorite="favorite"
:group="group"
:hide-tooltips="hideTooltips"
:shift-held="shiftHeld"
:edit-favorites-mode="editFavoritesMode"
@handle-select="favorite.$selected = $event"
@remove-local-avatar-favorite="removeLocalAvatarFavorite"
@select-avatar-with-confirmation="selectAvatarWithConfirmation"
@click="showAvatarDialog(favorite.id)" />
</div>
<div
v-else
:style="{
paddingTop: '25px',
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'rgb(144, 147, 153)'
}">
<span>No Data</span>
</div>
</el-collapse-item>
</el-collapse>
<AvatarExportDialog
:avatar-export-dialog-visible.sync="avatarExportDialogVisible"
:favorite-avatars="favoriteAvatars"
:local-avatar-favorite-groups="localAvatarFavoriteGroups"
:local-avatar-favorites="localAvatarFavorites"
:local-avatar-favorites-list="localAvatarFavoritesList" />
</div>
</template>
<script>
import FavoritesAvatarItem from './FavoritesAvatarItem.vue';
import FavoritesAvatarLocalHistoryItem from './FavoritesAvatarLocalHistoryItem.vue';
import AvatarExportDialog from '../dialogs/AvatarExportDialog.vue';
import { favoriteRequest } from '../../../api';
export default {
name: 'FavoritesAvatarTab',
components: { FavoritesAvatarItem, FavoritesAvatarLocalHistoryItem, AvatarExportDialog },
inject: ['API', 'showAvatarDialog'],
props: {
sortFavorites: Boolean,
hideTooltips: Boolean,
shiftHeld: Boolean,
editFavoritesMode: Boolean,
avatarHistoryArray: Array,
refreshingLocalFavorites: Boolean,
localAvatarFavoriteGroups: Array,
localAvatarFavorites: Object,
favoriteAvatars: Array,
localAvatarFavoritesList: Array
},
data() {
return {
avatarExportDialogVisible: false,
avatarFavoriteSearch: '',
avatarFavoriteSearchResults: []
};
},
computed: {
sortFav: {
get() {
return this.sortFavorites;
},
set(value) {
this.$emit('update:sort-favorites', value);
}
},
groupedByGroupKeyFavoriteAvatars() {
const groupedByGroupKeyFavoriteAvatars = {};
this.favoriteAvatars.forEach((avatar) => {
if (avatar.groupKey) {
if (!groupedByGroupKeyFavoriteAvatars[avatar.groupKey]) {
groupedByGroupKeyFavoriteAvatars[avatar.groupKey] = [];
}
groupedByGroupKeyFavoriteAvatars[avatar.groupKey].push(avatar);
}
});
return groupedByGroupKeyFavoriteAvatars;
},
isLocalUserVrcplusSupporter() {
return this.API.currentUser.$isVRCPlus;
}
},
methods: {
getLocalAvatarFavoriteGroupLength(group) {
const favoriteGroup = this.localAvatarFavorites[group];
if (!favoriteGroup) {
return 0;
}
return favoriteGroup.length;
},
searchAvatarFavorites() {
let ref = null;
const search = this.avatarFavoriteSearch.toLowerCase();
if (search.length < 3) {
this.avatarFavoriteSearchResults = [];
return;
}
const results = [];
for (let i = 0; i < this.localAvatarFavoriteGroups.length; ++i) {
const group = this.localAvatarFavoriteGroups[i];
if (!this.localAvatarFavorites[group]) {
continue;
}
for (let j = 0; j < this.localAvatarFavorites[group].length; ++j) {
ref = this.localAvatarFavorites[group][j];
if (
!ref ||
typeof ref.id === 'undefined' ||
typeof ref.name === 'undefined' ||
typeof ref.authorName === 'undefined'
) {
continue;
}
if (ref.name.toLowerCase().includes(search) || ref.authorName.toLowerCase().includes(search)) {
if (!results.some((r) => r.id === ref.id)) {
results.push(ref);
}
}
}
}
for (let i = 0; i < this.favoriteAvatars.length; ++i) {
ref = this.favoriteAvatars[i].ref;
if (
!ref ||
typeof ref.id === 'undefined' ||
typeof ref.name === 'undefined' ||
typeof ref.authorName === 'undefined'
) {
continue;
}
if (ref.name.toLowerCase().includes(search) || ref.authorName.toLowerCase().includes(search)) {
if (!results.some((r) => r.id === ref.id)) {
results.push(ref);
}
}
}
this.avatarFavoriteSearchResults = results;
},
clearFavoriteGroup(ctx) {
// FIXME: 메시지 수정
this.$confirm('Continue? Clear Group', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
favoriteRequest.clearFavoriteGroup({
type: ctx.type,
group: ctx.name
});
}
}
});
},
showAvatarExportDialog() {
this.avatarExportDialogVisible = true;
},
showAvatarImportDialog() {
this.$emit('show-avatar-import-dialog');
},
saveSortFavoritesOption() {
this.$emit('save-sort-favorites-option');
},
changeFavoriteGroupName(group) {
this.$emit('change-favorite-group-name', group);
},
removeLocalAvatarFavorite(id, group) {
this.$emit('remove-local-avatar-favorite', id, group);
},
selectAvatarWithConfirmation(id) {
this.$emit('select-avatar-with-confirmation', id);
},
promptClearAvatarHistory() {
this.$emit('prompt-clear-avatar-history');
},
promptNewLocalAvatarFavoriteGroup() {
this.$emit('prompt-new-local-avatar-favorite-group');
},
refreshLocalAvatarFavorites() {
this.$emit('refresh-local-avatar-favorites');
},
promptLocalAvatarFavoriteGroupRename(group) {
this.$emit('prompt-local-avatar-favorite-group-rename', group);
},
promptLocalAvatarFavoriteGroupDelete(group) {
this.$emit('prompt-local-avatar-favorite-group-delete', group);
}
}
};
</script>
@@ -0,0 +1,144 @@
<template>
<div @click="$emit('click')">
<div class="x-friend-item">
<template v-if="favorite.ref">
<div class="avatar" :class="userStatusClass(favorite.ref)">
<img v-lazy="userImage(favorite.ref, true)" />
</div>
<div class="detail">
<span
class="name"
:style="{ color: favorite.ref.$userColour }"
v-text="favorite.ref.displayName"></span>
<location
class="extra"
v-if="favorite.ref.location !== 'offline'"
:location="favorite.ref.location"
:traveling="favorite.ref.travelingToLocation"
:link="false"></location>
<span v-else v-text="favorite.ref.statusDescription"></span>
</div>
<template v-if="editFavoritesMode">
<el-dropdown trigger="click" size="mini" style="margin-left: 5px" @click.native.stop>
<el-tooltip
placement="left"
:content="$t('view.favorite.move_tooltip')"
:disabled="hideTooltips">
<el-button type="default" icon="el-icon-back" size="mini" circle></el-button>
</el-tooltip>
<el-dropdown-menu slot="dropdown">
<template v-for="groupAPI in API.favoriteFriendGroups">
<el-dropdown-item
v-if="groupAPI.name !== group.name"
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="moveFavorite(favorite.ref, groupAPI, 'friend')">
{{ groupAPI.displayName }} ({{ groupAPI.count }} / {{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-button type="text" size="mini" style="margin-left: 5px" @click.stop>
<el-checkbox v-model="favorite.$selected"></el-checkbox>
</el-button>
</template>
<template v-else>
<el-tooltip
placement="right"
:content="$t('view.favorite.unfavorite_tooltip')"
:disabled="hideTooltips">
<el-button
v-if="shiftHeld"
size="mini"
icon="el-icon-close"
circle
style="color: #f56c6c; margin-left: 5px"
@click.stop="deleteFavorite(favorite.id)"></el-button>
<el-button
v-else
type="default"
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
@click.stop="showFavoriteDialog('friend', favorite.id)"></el-button>
</el-tooltip>
</template>
</template>
<template v-else>
<div class="avatar"></div>
<div class="detail">
<span v-text="favorite.name || favorite.id"></span>
</div>
<el-button
type="text"
icon="el-icon-close"
size="mini"
style="margin-left: 5px"
@click.stop="deleteFavorite(favorite.id)"></el-button>
</template>
</div>
</div>
</template>
<script>
import Location from '../../../components/Location.vue';
import { favoriteRequest } from '../../../api';
export default {
components: { Location },
inject: ['showUserDialog', 'userImage', 'userStatusClass', 'API', 'showFavoriteDialog'],
props: {
favorite: {
type: Object,
required: true
},
hideTooltips: {
type: Boolean,
default: false
},
shiftHeld: {
type: Boolean,
default: false
},
group: {
type: Object,
required: true
},
editFavoritesMode: Boolean
},
methods: {
moveFavorite(ref, group, type) {
favoriteRequest
.deleteFavorite({
objectId: ref.id
})
.then(() => {
favoriteRequest.addFavorite({
type,
favoriteId: ref.id,
tags: group.name
});
});
},
deleteFavorite(objectId) {
favoriteRequest.deleteFavorite({
objectId
});
// FIXME: 메시지 수정
// this.$confirm('Continue? Delete Favorite', 'Confirm', {
// confirmButtonText: 'Confirm',
// cancelButtonText: 'Cancel',
// type: 'info',
// callback: (action) => {
// if (action === 'confirm') {
// API.deleteFavorite({
// objectId
// });
// }
// }
// });
}
}
};
</script>
@@ -0,0 +1,142 @@
<template>
<div>
<div style="display: flex; align-items: center; justify-content: space-between">
<div>
<el-button size="small" @click="showFriendExportDialog">{{ $t('view.favorite.export') }}</el-button>
<el-button size="small" style="margin-left: 5px" @click="showFriendImportDialog">{{
$t('view.favorite.import')
}}</el-button>
</div>
<div style="display: flex; align-items: center; font-size: 13px; margin-right: 10px">
<span class="name" style="margin-right: 5px; line-height: 10px">{{ $t('view.favorite.sort_by') }}</span>
<el-radio-group v-model="sortFav" @change="saveSortFavoritesOption">
<el-radio :label="false">{{
$t('view.settings.appearance.appearance.sort_favorite_by_name')
}}</el-radio>
<el-radio :label="true">{{
$t('view.settings.appearance.appearance.sort_favorite_by_date')
}}</el-radio>
</el-radio-group>
</div>
</div>
<span style="display: block; margin-top: 30px">{{ $t('view.favorite.avatars.vrchat_favorites') }}</span>
<el-collapse style="border: 0">
<el-collapse-item v-for="group in API.favoriteFriendGroups" :key="group.name">
<template slot="title">
<span
style="font-weight: bold; font-size: 14px; margin-left: 10px"
v-text="group.displayName"></span>
<span style="color: #909399; font-size: 12px; margin-left: 10px"
>{{ group.count }}/{{ group.capacity }}</span
>
<el-tooltip placement="top" :content="$t('view.favorite.rename_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-edit"
circle
style="margin-left: 10px"
@click.stop="changeFavoriteGroupName(group)"></el-button>
</el-tooltip>
<el-tooltip placement="right" :content="$t('view.favorite.clear_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
style="margin-left: 5px"
@click.stop="clearFavoriteGroup(group)"></el-button>
</el-tooltip>
</template>
<div v-if="group.count" class="x-friend-list" style="margin-top: 10px">
<FavoritesFriendItem
v-for="favorite in groupedByGroupKeyFavoriteFriends[group.key]"
:key="favorite.id"
style="display: inline-block; width: 300px; margin-right: 15px"
:favorite="favorite"
:edit-favorites-mode="editFavoritesMode"
:group="group"
@click="showUserDialog(favorite.id)" />
</div>
<div
v-else
style="
padding-top: 25px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgb(144, 147, 153);
">
<span>No Data</span>
</div>
</el-collapse-item>
</el-collapse>
<FriendExportDialog
:friend-export-dialog-visible.sync="friendExportDialogVisible"
:favorite-friends="favoriteFriends" />
</div>
</template>
<script>
import FavoritesFriendItem from './FavoritesFriendItem.vue';
import FriendExportDialog from '../dialogs/FriendExportDialog.vue';
import { favoriteRequest } from '../../../api';
export default {
name: 'FavoritesFriendTab',
components: { FriendExportDialog, FavoritesFriendItem },
inject: ['showUserDialog', 'API'],
props: {
favoriteFriends: Array,
sortFavorites: Boolean,
hideTooltips: Boolean,
groupedByGroupKeyFavoriteFriends: Object,
editFavoritesMode: Boolean
},
data() {
return {
friendExportDialogVisible: false
};
},
computed: {
sortFav: {
get() {
return this.sortFavorites;
},
set(value) {
this.$emit('update:sort-favorites', value);
}
}
},
methods: {
showFriendExportDialog() {
this.friendExportDialogVisible = true;
},
showFriendImportDialog() {
this.$emit('show-friend-import-dialog');
},
saveSortFavoritesOption() {
this.$emit('save-sort-favorites-option');
},
clearFavoriteGroup(ctx) {
// FIXME: 메시지 수정
this.$confirm('Continue? Clear Group', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
favoriteRequest.clearFavoriteGroup({
type: ctx.type,
group: ctx.name
});
}
}
});
},
changeFavoriteGroupName(group) {
this.$emit('change-favorite-group-name', group);
}
}
};
</script>
@@ -0,0 +1,231 @@
<template>
<div @click="$emit('click')" :style="{ display: 'inline-block', width: '300px', marginRight: '15px' }">
<div class="x-friend-item">
<template v-if="isLocalFavorite ? favorite.name : favorite.ref">
<div class="avatar">
<img v-lazy="smallThumbnail" />
</div>
<div class="detail">
<span class="name">{{ localFavFakeRef.name }}</span>
<span v-if="localFavFakeRef.occupants" class="extra"
>{{ localFavFakeRef.authorName }} ({{ localFavFakeRef.occupants }})</span
>
<span v-else class="extra">{{ localFavFakeRef.authorName }}</span>
</div>
<template v-if="editFavoritesMode">
<el-dropdown trigger="click" size="mini" style="margin-left: 5px" @click.native.stop>
<el-tooltip
placement="left"
:content="$t(localFavFakeRef ? 'view.favorite.copy_tooltip' : 'view.favorite.move_tooltip')"
:disabled="hideTooltips">
<el-button type="default" icon="el-icon-back" size="mini" circle></el-button>
</el-tooltip>
<el-dropdown-menu slot="dropdown">
<template v-for="groupAPI in API.favoriteWorldGroups">
<el-dropdown-item
v-if="isLocalFavorite || groupAPI.name !== group.name"
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="handleDropdownItemClick(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }} / {{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
<el-button v-if="!isLocalFavorite" type="text" size="mini" @click.stop style="margin-left: 5px">
<el-checkbox v-model="isSelected"></el-checkbox>
</el-button>
</el-dropdown>
</template>
<template v-else>
<el-tooltip
v-if="!isLocalFavorite && favorite.deleted"
placement="left"
:content="$t('view.favorite.unavailable_tooltip')">
<i class="el-icon-warning" style="color: #f56c6c; margin-left: 5px"></i>
</el-tooltip>
<el-tooltip
v-if="!isLocalFavorite && favorite.ref.releaseStatus === 'private'"
placement="left"
:content="$t('view.favorite.private')">
<i class="el-icon-warning" style="color: #e6a23c; margin-left: 5px"></i>
</el-tooltip>
<el-tooltip
placement="left"
:content="$t('view.favorite.self_invite_tooltip')"
:disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-message"
style="margin-left: 5px"
@click.stop="$emit('new-instance-self-invite', favorite.id)"
circle></el-button>
</el-tooltip>
<el-tooltip
v-if="!isLocalFavorite"
placement="right"
:content="$t('view.favorite.unfavorite_tooltip')"
:disabled="hideTooltips">
<el-button
v-if="shiftHeld"
size="mini"
icon="el-icon-close"
circle
style="color: #f56c6c; margin-left: 5px"
@click.stop="deleteFavorite(favorite.id)"></el-button>
<el-button
v-else
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
type="default"
@click.stop="showFavoriteDialog('world', favorite.id)"></el-button>
</el-tooltip>
</template>
<el-tooltip
v-if="isLocalFavorite"
placement="right"
:content="$t('view.favorite.unfavorite_tooltip')"
:disabled="hideTooltips">
<el-button
v-if="shiftHeld"
size="mini"
icon="el-icon-close"
circle
style="color: #f56c6c; margin-left: 5px"
@click.stop="$emit('remove-local-world-favorite', favorite.id, group)"></el-button>
<el-button
v-else
icon="el-icon-star-on"
size="mini"
circle
style="margin-left: 5px"
type="default"
@click.stop="showFavoriteDialog('world', favorite.id)"></el-button>
</el-tooltip>
</template>
<template v-else>
<div class="avatar"></div>
<div class="detail">
<span>{{ favorite.name || favorite.id }}</span>
<el-tooltip
v-if="!isLocalFavorite && favorite.deleted"
placement="left"
:content="$t('view.favorite.unavailable_tooltip')">
<i class="el-icon-warning" style="color: #f56c6c; margin-left: 5px"></i>
</el-tooltip>
<el-button
type="text"
icon="el-icon-close"
size="mini"
style="margin-left: 5px"
@click.stop="handleDeleteFavorite"></el-button>
</div>
</template>
</div>
</div>
</template>
<script>
import { favoriteRequest } from '../../../api';
export default {
name: 'FavoritesWorldItem',
inject: ['API', 'showFavoriteDialog'],
props: {
group: [Object, String],
favorite: Object,
editFavoritesMode: Boolean,
hideTooltips: Boolean,
shiftHeld: Boolean,
isLocalFavorite: { type: Boolean, required: false }
},
computed: {
isSelected: {
get() {
return this.favorite.$selected;
},
set(value) {
this.$emit('handle-select', value);
}
},
localFavFakeRef() {
// local favorite no "ref" property
return this.isLocalFavorite ? this.favorite : this.favorite.ref;
},
smallThumbnail() {
return (
this.localFavFakeRef.thumbnailImageUrl.replace('256', '128') ||
this.localFavFakeRef.thumbnailImageUrl
);
}
},
methods: {
handleDropdownItemClick(groupAPI) {
if (this.isLocalFavorite) {
this.addFavoriteWorld(this.localFavFakeRef, groupAPI, true);
} else {
this.moveFavorite(this.localFavFakeRef, groupAPI, 'world');
}
},
handleDeleteFavorite() {
if (this.isLocalFavorite) {
this.$emit('remove-local-world-favorite', this.favorite.id, this.group);
} else {
this.deleteFavorite(this.favorite.id);
}
},
moveFavorite(ref, group, type) {
favoriteRequest
.deleteFavorite({
objectId: ref.id
})
.then(() => {
favoriteRequest.addFavorite({
type,
favoriteId: ref.id,
tags: group.name
});
});
},
deleteFavorite(objectId) {
favoriteRequest.deleteFavorite({
objectId
});
// FIXME: 메시지 수정
// this.$confirm('Continue? Delete Favorite', 'Confirm', {
// confirmButtonText: 'Confirm',
// cancelButtonText: 'Cancel',
// type: 'info',
// callback: (action) => {
// if (action === 'confirm') {
// API.deleteFavorite({
// objectId
// });
// }
// }
// });
},
addFavoriteWorld(ref, group, message) {
// wait API splitting PR Merged
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;
});
}
}
};
</script>
@@ -0,0 +1,450 @@
<template>
<div>
<div style="display: flex; align-items: center; justify-content: space-between">
<div>
<el-button size="small" @click="showExportDialog">{{ $t('view.favorite.export') }}</el-button>
<el-button size="small" style="margin-left: 5px" @click="$emit('show-world-import-dialog')">{{
$t('view.favorite.import')
}}</el-button>
</div>
<div style="display: flex; align-items: center; font-size: 13px; margin-right: 10px">
<span class="name" style="margin-right: 5px; line-height: 10px">{{ $t('view.favorite.sort_by') }}</span>
<el-radio-group
v-model="sortFav"
style="margin-right: 12px"
@change="$emit('save-sort-favorites-option')">
<el-radio :label="false">{{
$t('view.settings.appearance.appearance.sort_favorite_by_name')
}}</el-radio>
<el-radio :label="true">{{
$t('view.settings.appearance.appearance.sort_favorite_by_date')
}}</el-radio>
</el-radio-group>
<el-input
v-model="worldFavoriteSearch"
clearable
size="mini"
:placeholder="$t('view.favorite.worlds.search')"
style="width: 200px"
@input="searchWorldFavorites" />
</div>
</div>
<div class="x-friend-list" style="margin-top: 10px">
<div
v-for="favorite in worldFavoriteSearchResults"
:key="favorite.id"
style="display: inline-block; width: 300px; margin-right: 15px"
@click="showWorldDialog(favorite.id)">
<div class="x-friend-item">
<template v-if="favorite.name">
<div class="avatar">
<img v-lazy="favorite.thumbnailImageUrl" />
</div>
<div class="detail">
<span class="name" v-text="favorite.name"></span>
<span v-if="favorite.occupants" class="extra"
>{{ favorite.authorName }} ({{ favorite.occupants }})</span
>
<span v-else class="extra" v-text="favorite.authorName"></span>
</div>
</template>
<template v-else>
<div class="avatar"></div>
<div class="detail">
<span v-text="favorite.id"></span>
</div>
</template>
</div>
</div>
</div>
<span style="display: block; margin-top: 20px">{{ $t('view.favorite.worlds.vrchat_favorites') }}</span>
<el-collapse style="border: 0">
<el-collapse-item v-for="group in API.favoriteWorldGroups" :key="group.name">
<template slot="title">
<div style="display: flex; align-items: center">
<span
style="font-weight: bold; font-size: 14px; margin-left: 10px"
v-text="group.displayName" />
<el-tag
style="margin: 1px 0 0 5px"
size="mini"
:type="userFavoriteWorldsStatusForFavTab(group.visibility)"
effect="plain"
>{{ group.visibility.charAt(0).toUpperCase() + group.visibility.slice(1) }}</el-tag
>
<span style="color: #909399; font-size: 12px; margin-left: 10px"
>{{ group.count }}/{{ group.capacity }}</span
>
<el-dropdown trigger="click" size="mini" style="margin-left: 10px" @click.native.stop>
<el-tooltip
placement="top"
:content="$t('view.favorite.visibility_tooltip')"
:disabled="hideTooltips">
<el-button type="default" icon="el-icon-view" size="mini" circle />
</el-tooltip>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="visibility in worldGroupVisibilityOptions"
v-if="group.visibility !== visibility"
:key="visibility"
style="display: block; margin: 10px 0"
@click.native="changeWorldGroupVisibility(group.name, visibility)"
>{{ visibility.charAt(0).toUpperCase() + visibility.slice(1) }}</el-dropdown-item
>
</el-dropdown-menu>
<el-tooltip
placement="top"
:content="$t('view.favorite.rename_tooltip')"
:disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-edit"
circle
style="margin-left: 5px"
@click.stop="changeFavoriteGroupName(group)" />
</el-tooltip>
<el-tooltip
placement="right"
:content="$t('view.favorite.clear_tooltip')"
:disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
style="margin-left: 5px"
@click.stop="clearFavoriteGroup(group)" />
</el-tooltip>
</el-dropdown>
</div>
</template>
<div v-if="group.count" class="x-friend-list" style="margin-top: 10px">
<FavoritesWorldItem
v-for="favorite in groupedByGroupKeyFavoriteWorlds[group.key]"
:key="favorite.id"
:group="group"
:favorite="favorite"
:edit-favorites-mode="editFavoritesMode"
:hide-tooltips="hideTooltips"
:shift-held="shiftHeld"
@click="showWorldDialog(favorite.id)"
@handle-select="favorite.$selected = $event"
@new-instance-self-invite="newInstanceSelfInvite" />
</div>
<div
v-else
style="
padding-top: 25px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgb(144, 147, 153);
">
<span>No Data</span>
</div>
</el-collapse-item>
</el-collapse>
<span style="display: block; margin-top: 20px">{{ $t('view.favorite.worlds.local_favorites') }}</span>
<br />
<el-button size="small" @click="promptNewLocalWorldFavoriteGroup">{{
$t('view.favorite.worlds.new_group')
}}</el-button>
<el-button
v-if="!refreshingLocalFavorites"
size="small"
style="margin-left: 5px"
@click="$emit('refresh-local-world-favorite')"
>{{ $t('view.favorite.worlds.refresh') }}</el-button
>
<el-button v-else size="small" style="margin-left: 5px" @click="refreshingLocalFavorites = false">
<i class="el-icon-loading" style="margin-right: 5px" />
<span>{{ $t('view.favorite.worlds.cancel_refresh') }}</span>
</el-button>
<el-collapse style="border: 0">
<el-collapse-item v-for="group in localWorldFavoriteGroups" v-if="localWorldFavorites[group]" :key="group">
<template slot="title">
<span style="font-weight: bold; font-size: 14px; margin-left: 10px" v-text="group" />
<span style="color: #909399; font-size: 12px; margin-left: 10px">{{
getLocalWorldFavoriteGroupLength(group)
}}</span>
<el-tooltip placement="top" :content="$t('view.favorite.rename_tooltip')" :disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-edit"
circle
style="margin-left: 10px"
@click.stop="promptLocalWorldFavoriteGroupRename(group)" />
</el-tooltip>
<el-tooltip
placement="right"
:content="$t('view.favorite.delete_tooltip')"
:disabled="hideTooltips">
<el-button
size="mini"
icon="el-icon-delete"
circle
style="margin-left: 5px"
@click.stop="promptLocalWorldFavoriteGroupDelete(group)" />
</el-tooltip>
</template>
<div v-if="localWorldFavorites[group].length" class="x-friend-list" style="margin-top: 10px">
<FavoritesWorldItem
v-for="favorite in localWorldFavorites[group]"
:key="favorite.id"
is-local-favorite
:group="group"
:favorite="favorite"
:edit-favorites-mode="editFavoritesMode"
:hide-tooltips="hideTooltips"
:shift-held="shiftHeld"
@click="showWorldDialog(favorite.id)"
@new-instance-self-invite="newInstanceSelfInvite"
@remove-local-world-favorite="removeLocalWorldFavorite" />
</div>
<div
v-else
style="
padding-top: 25px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
color: rgb(144, 147, 153);
">
<span>No Data</span>
</div>
</el-collapse-item>
</el-collapse>
<WorldExportDialog
:favorite-worlds="favoriteWorlds"
:world-export-dialog-visible.sync="worldExportDialogVisible"
:local-world-favorites="localWorldFavorites"
:local-world-favorite-groups="localWorldFavoriteGroups"
:local-world-favorites-list="localWorldFavoritesList" />
</div>
</template>
<script>
import FavoritesWorldItem from './FavoritesWorldItem.vue';
import WorldExportDialog from '../dialogs/WorldExportDialog.vue';
import { favoriteRequest } from '../../../api';
export default {
name: 'FavoritesWorldTab',
components: {
FavoritesWorldItem,
WorldExportDialog
},
inject: ['API', 'showWorldDialog'],
props: {
sortFavorites: Boolean,
hideTooltips: Boolean,
favoriteWorlds: Array,
editFavoritesMode: Boolean,
shiftHeld: Boolean,
refreshingLocalFavorites: Boolean,
localWorldFavoriteGroups: Array,
localWorldFavorites: Object,
localWorldFavoritesList: Array
},
data() {
return {
worldGroupVisibilityOptions: ['private', 'friends', 'public'],
worldFavoriteSearch: '',
worldExportDialogVisible: false,
worldFavoriteSearchResults: []
};
},
computed: {
groupedByGroupKeyFavoriteWorlds() {
const groupedByGroupKeyFavoriteWorlds = {};
this.favoriteWorlds.forEach((world) => {
if (world.groupKey) {
if (!groupedByGroupKeyFavoriteWorlds[world.groupKey]) {
groupedByGroupKeyFavoriteWorlds[world.groupKey] = [];
}
groupedByGroupKeyFavoriteWorlds[world.groupKey].push(world);
}
});
return groupedByGroupKeyFavoriteWorlds;
},
sortFav: {
get() {
return this.sortFavorites;
},
set(value) {
this.$emit('update:sort-favorites', value);
}
}
},
methods: {
showExportDialog() {
this.worldExportDialogVisible = true;
},
userFavoriteWorldsStatusForFavTab(visibility) {
let style = '';
if (visibility === 'public') {
style = '';
} else if (visibility === 'friends') {
style = 'success';
} else {
style = 'info';
}
return style;
},
changeWorldGroupVisibility(name, visibility) {
const params = {
type: 'world',
group: name,
visibility
};
favoriteRequest.saveFavoriteGroup(params).then((args) => {
this.$message({
message: 'Group visibility changed',
type: 'success'
});
return args;
});
},
promptNewLocalWorldFavoriteGroup() {
this.$prompt(
$t('prompt.new_local_favorite_group.description'),
$t('prompt.new_local_favorite_group.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: $t('prompt.new_local_favorite_group.ok'),
cancelButtonText: $t('prompt.new_local_favorite_group.cancel'),
inputPattern: /\S+/,
inputErrorMessage: $t('prompt.new_local_favorite_group.input_error'),
callback: (action, instance) => {
if (action === 'confirm' && instance.inputValue) {
this.$emit('new-local-world-favorite-group', instance.inputValue);
}
}
}
);
},
promptLocalWorldFavoriteGroupRename(group) {
this.$prompt(
$t('prompt.local_favorite_group_rename.description'),
$t('prompt.local_favorite_group_rename.header'),
{
distinguishCancelAndClose: true,
confirmButtonText: $t('prompt.local_favorite_group_rename.save'),
cancelButtonText: $t('prompt.local_favorite_group_rename.cancel'),
inputPattern: /\S+/,
inputErrorMessage: $t('prompt.local_favorite_group_rename.input_error'),
inputValue: group,
callback: (action, instance) => {
if (action === 'confirm' && instance.inputValue) {
this.$emit('rename-local-world-favorite-group', instance.inputValue, group);
}
}
}
);
},
promptLocalWorldFavoriteGroupDelete(group) {
this.$confirm(`Delete Group? ${group}`, 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
this.$emit('delete-local-world-favorite-group', group);
}
}
});
},
getLocalWorldFavoriteGroupLength(group) {
const favoriteGroup = this.localWorldFavorites[group];
if (!favoriteGroup) {
return 0;
}
return favoriteGroup.length;
},
clearFavoriteGroup(ctx) {
// FIXME: 메시지 수정
this.$confirm('Continue? Clear Group', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
favoriteRequest.clearFavoriteGroup({
type: ctx.type,
group: ctx.name
});
}
}
});
},
searchWorldFavorites(worldFavoriteSearch) {
let ref = null;
const search = worldFavoriteSearch.toLowerCase();
if (search.length < 3) {
this.worldFavoriteSearchResults = [];
return;
}
const results = [];
for (let i = 0; i < this.localWorldFavoriteGroups.length; ++i) {
const group = this.localWorldFavoriteGroups[i];
if (!this.localWorldFavorites[group]) {
continue;
}
for (let j = 0; j < this.localWorldFavorites[group].length; ++j) {
ref = this.localWorldFavorites[group][j];
if (
!ref ||
typeof ref.id === 'undefined' ||
typeof ref.name === 'undefined' ||
typeof ref.authorName === 'undefined'
) {
continue;
}
if (ref.name.toLowerCase().includes(search) || ref.authorName.toLowerCase().includes(search)) {
if (!results.some((r) => r.id === ref.id)) {
results.push(ref);
}
}
}
}
for (let i = 0; i < this.favoriteWorlds.length; ++i) {
ref = this.favoriteWorlds[i].ref;
if (
!ref ||
typeof ref.id === 'undefined' ||
typeof ref.name === 'undefined' ||
typeof ref.authorName === 'undefined'
) {
continue;
}
if (ref.name.toLowerCase().includes(search) || ref.authorName.toLowerCase().includes(search)) {
if (!results.some((r) => r.id === ref.id)) {
results.push(ref);
}
}
}
this.worldFavoriteSearchResults = results;
},
changeFavoriteGroupName(group) {
this.$emit('change-favorite-group-name', group);
},
newInstanceSelfInvite(event) {
this.$emit('new-instance-self-invite', event);
},
removeLocalWorldFavorite(param1, param2) {
this.$emit('remove-local-world-favorite', param1, param2);
}
}
};
</script>
<style scoped></style>
@@ -0,0 +1,229 @@
<template>
<el-dialog
:before-close="beforeDialogClose"
:visible.sync="isDialogVisible"
:title="$t('dialog.avatar_export.header')"
width="650px"
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<el-checkbox-group
v-model="exportSelectedOptions"
style="margin-bottom: 10px"
@change="updateAvatarExportDialog()">
<template v-for="option in exportSelectOptions">
<el-checkbox :key="option.value" :label="option.label"></el-checkbox>
</template>
</el-checkbox-group>
<el-dropdown trigger="click" size="small" @click.native.stop>
<el-button size="mini">
<span v-if="avatarExportFavoriteGroup">
{{ avatarExportFavoriteGroup.displayName }} ({{ avatarExportFavoriteGroup.count }}/{{
avatarExportFavoriteGroup.capacity
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
All Favorites
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item style="display: block; margin: 10px 0" @click.native="selectAvatarExportGroup(null)">
All Favorites
</el-dropdown-item>
<template v-for="groupAPI in API.favoriteAvatarGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
@click.native="selectAvatarExportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-dropdown trigger="click" size="small" style="margin-left: 10px" @click.native.stop>
<el-button size="mini">
<span v-if="avatarExportLocalFavoriteGroup">
{{ avatarExportLocalFavoriteGroup }} ({{
getLocalAvatarFavoriteGroupLength(avatarExportLocalFavoriteGroup)
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
Select Group
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
style="display: block; margin: 10px 0"
@click.native="selectAvatarExportLocalGroup(null)">
None
</el-dropdown-item>
<template v-for="group in localAvatarFavoriteGroups">
<el-dropdown-item
:key="group"
style="display: block; margin: 10px 0"
@click.native="selectAvatarExportLocalGroup(group)">
{{ group }} ({{ getLocalAvatarFavoriteGroupLength(group) }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<br />
<el-input
v-model="avatarExportContent"
type="textarea"
size="mini"
rows="15"
resize="none"
readonly
style="margin-top: 15px"
@click.native="handleCopyAvatarExportData"></el-input>
</el-dialog>
</template>
<script>
export default {
name: 'AvatarExportDialog',
inject: ['API', 'beforeDialogClose', 'dialogMouseDown', 'dialogMouseUp'],
props: {
avatarExportDialogVisible: Boolean,
favoriteAvatars: Array,
localAvatarFavoriteGroups: Array,
localAvatarFavorites: Object,
localAvatarFavoritesList: Array
},
data() {
return {
avatarExportContent: '',
avatarExportFavoriteGroup: null,
avatarExportLocalFavoriteGroup: null,
exportSelectedOptions: ['ID', 'Name'],
exportSelectOptions: [
{ label: 'ID', value: 'id' },
{ label: 'Name', value: 'name' },
{ label: 'Author ID', value: 'authorId' },
{ label: 'Author Name', value: 'authorName' },
{ label: 'Thumbnail', value: 'thumbnailImageUrl' }
]
};
},
computed: {
isDialogVisible: {
get() {
return this.avatarExportDialogVisible;
},
set(value) {
this.$emit('update:avatar-export-dialog-visible', value);
}
}
},
watch: {
avatarExportDialogVisible(visible) {
if (visible) {
this.showAvatarExportDialog();
}
}
},
methods: {
showAvatarExportDialog() {
this.avatarExportFavoriteGroup = null;
this.avatarExportLocalFavoriteGroup = null;
this.updateAvatarExportDialog();
},
handleCopyAvatarExportData(event) {
if (event.target.tagName === 'TEXTAREA') {
event.target.select();
}
navigator.clipboard
.writeText(this.avatarExportContent)
.then(() => {
this.$message({
message: 'Copied successfully!',
type: 'success',
duration: 2000
});
})
.catch((err) => {
console.error('Copy failed:', err);
this.$message.error('Copy failed!');
});
},
updateAvatarExportDialog() {
const formatter = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
};
const propsForQuery = this.exportSelectOptions
.filter((option) => this.exportSelectedOptions.includes(option.label))
.map((option) => option.value);
function resText(ref) {
let resArr = [];
propsForQuery.forEach((e) => {
resArr.push(formatter(ref?.[e]));
});
return resArr.join(',');
}
const lines = [this.exportSelectedOptions.join(',')];
if (this.avatarExportFavoriteGroup) {
this.API.favoriteAvatarGroups.forEach((group) => {
if (!this.avatarExportFavoriteGroup || this.avatarExportFavoriteGroup === group) {
this.favoriteAvatars.forEach((ref) => {
if (group.key === ref.groupKey) {
lines.push(resText(ref.ref));
}
});
}
});
} else if (this.avatarExportLocalFavoriteGroup) {
const favoriteGroup = this.localAvatarFavorites[this.avatarExportLocalFavoriteGroup];
if (!favoriteGroup) {
return;
}
for (let i = 0; i < favoriteGroup.length; ++i) {
const ref = favoriteGroup[i];
lines.push(resText(ref));
}
} else {
// export all
this.favoriteAvatars.forEach((ref) => {
lines.push(resText(ref.ref));
});
for (let i = 0; i < this.localAvatarFavoritesList.length; ++i) {
const avatarId = this.localAvatarFavoritesList[i];
const ref = this.API.cachedAvatars.get(avatarId);
if (typeof ref !== 'undefined') {
lines.push(resText(ref));
}
}
}
this.avatarExportContent = lines.join('\n');
},
selectAvatarExportGroup(group) {
this.avatarExportFavoriteGroup = group;
this.avatarExportLocalFavoriteGroup = null;
this.updateAvatarExportDialog();
},
selectAvatarExportLocalGroup(group) {
this.avatarExportLocalFavoriteGroup = group;
this.avatarExportFavoriteGroup = null;
this.updateAvatarExportDialog();
},
getLocalAvatarFavoriteGroupLength(group) {
const favoriteGroup = this.localAvatarFavorites[group];
if (!favoriteGroup) {
return 0;
}
return favoriteGroup.length;
}
}
};
</script>
@@ -0,0 +1,368 @@
<template>
<el-dialog
ref="avatarImportDialog"
:before-close="beforeDialogClose"
:visible.sync="isVisible"
:title="$t('dialog.avatar_import.header')"
width="650px"
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<div style="display: flex; align-items: center; justify-content: space-between">
<div style="font-size: 12px">{{ $t('dialog.avatar_import.description') }}</div>
<div style="display: flex; align-items: center">
<div v-if="avatarImportDialog.progress">
{{ $t('dialog.avatar_import.process_progress') }} {{ avatarImportDialog.progress }} /
{{ avatarImportDialog.progressTotal }}
<i class="el-icon-loading" style="margin: 0 5px"></i>
</div>
<el-button v-if="avatarImportDialog.loading" size="small" @click="cancelAvatarImport">
{{ $t('dialog.avatar_import.cancel') }}
</el-button>
<el-button v-else size="small" :disabled="!avatarImportDialog.input" @click="processAvatarImportList">
{{ $t('dialog.avatar_import.process_list') }}
</el-button>
</div>
</div>
<el-input
v-model="avatarImportDialog.input"
type="textarea"
size="mini"
rows="10"
resize="none"
style="margin-top: 10px"></el-input>
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 5px">
<div>
<el-dropdown trigger="click" size="small" @click.native.stop>
<el-button size="mini">
<span v-if="avatarImportDialog.avatarImportFavoriteGroup">
{{ avatarImportDialog.avatarImportFavoriteGroup.displayName }} ({{
avatarImportDialog.avatarImportFavoriteGroup.count
}}/{{ avatarImportDialog.avatarImportFavoriteGroup.capacity }})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $t('dialog.avatar_import.select_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.favoriteAvatarGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="selectAvatarImportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-dropdown trigger="click" size="small" style="margin: 5px" @click.native.stop>
<el-button size="mini">
<span v-if="avatarImportDialog.avatarImportLocalFavoriteGroup">
{{ avatarImportDialog.avatarImportLocalFavoriteGroup }} ({{
getLocalAvatarFavoriteGroupLength(avatarImportDialog.avatarImportLocalFavoriteGroup)
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $t('dialog.avatar_import.select_group_placeholder') }}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<template v-for="group in localAvatarFavoriteGroups">
<el-dropdown-item
:key="group"
style="display: block; margin: 10px 0"
@click.native="selectAvatarImportLocalGroup(group)">
{{ group }} ({{ getLocalAvatarFavoriteGroupLength(group) }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<span v-if="avatarImportDialog.avatarImportFavoriteGroup" style="margin-left: 5px">
{{ avatarImportTable.data.length }} /
{{
avatarImportDialog.avatarImportFavoriteGroup.capacity -
avatarImportDialog.avatarImportFavoriteGroup.count
}}
</span>
</div>
<div>
<el-button size="small" @click="clearAvatarImportTable">
{{ $t('dialog.avatar_import.clear_table') }}
</el-button>
<el-button
size="small"
type="primary"
style="margin: 5px"
:disabled="
avatarImportTable.data.length === 0 ||
(!avatarImportDialog.avatarImportFavoriteGroup &&
!avatarImportDialog.avatarImportLocalFavoriteGroup)
"
@click="importAvatarImportTable">
{{ $t('dialog.avatar_import.import') }}
</el-button>
</div>
</div>
<span v-if="avatarImportDialog.importProgress" style="margin: 10px">
<i class="el-icon-loading" style="margin-right: 5px"></i>
{{ $t('dialog.avatar_import.import_progress') }}
{{ avatarImportDialog.importProgress }}/{{ avatarImportDialog.importProgressTotal }}
</span>
<br />
<template v-if="avatarImportDialog.errors">
<el-button size="small" @click="avatarImportDialog.errors = ''">
{{ $t('dialog.avatar_import.clear_errors') }}
</el-button>
<h2 style="font-weight: bold; margin: 5px 0">
{{ $t('dialog.avatar_import.errors') }}
</h2>
<pre style="white-space: pre-wrap; font-size: 12px" v-text="avatarImportDialog.errors"></pre>
</template>
<data-tables v-loading="avatarImportDialog.loading" v-bind="avatarImportTable" style="margin-top: 10px">
<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" />
<img
v-lazy="scope.row.imageUrl"
class="friends-list-avatar"
style="height: 500px; cursor: pointer"
@click="showFullscreenImageDialog(scope.row.imageUrl)" />
</el-popover>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.name')" prop="name">
<template slot-scope="scope">
<span class="x-link" @click="showAvatarDialog(scope.row.id)">
{{ scope.row.name }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.author')" width="120" prop="authorName">
<template slot-scope="scope">
<span class="x-link" @click="showUserDialog(scope.row.authorId)">
{{ scope.row.authorName }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.status')" width="70" prop="releaseStatus">
<template slot-scope="scope">
<span
:style="{
color:
scope.row.releaseStatus === 'public'
? '#67c23a'
: scope.row.releaseStatus === 'private'
? '#f56c6c'
: undefined
}">
{{ scope.row.releaseStatus.charAt(0).toUpperCase() + scope.row.releaseStatus.slice(1) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.action')" width="90" align="right">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-close" size="mini" @click="deleteItemAvatarImport(scope.row)">
</el-button>
</template>
</el-table-column>
</data-tables>
</el-dialog>
</template>
<script>
import { avatarRequest, favoriteRequest } from '../../../api';
import utils from '../../../classes/utils';
export default {
name: 'AvatarImportDialog',
inject: [
'API',
'beforeDialogClose',
'dialogMouseDown',
'dialogMouseUp',
'adjustDialogZ',
'showFullscreenImageDialog',
'showUserDialog',
'showAvatarDialog'
],
props: {
getLocalAvatarFavoriteGroupLength: Function,
localAvatarFavoriteGroups: Array,
avatarImportDialogInput: String,
avatarImportDialogVisible: Boolean
},
data() {
return {
avatarImportDialog: {
loading: false,
progress: 0,
progressTotal: 0,
input: '',
avatarIdList: new Set(),
errors: '',
avatarImportFavoriteGroup: null,
avatarImportLocalFavoriteGroup: null,
importProgress: 0,
importProgressTotal: 0
},
avatarImportTable: {
data: [],
tableProps: {
stripe: true,
size: 'mini'
},
layout: 'table'
}
};
},
computed: {
isVisible: {
get() {
return this.avatarImportDialogVisible;
},
set(value) {
this.$emit('update:avatar-import-dialog-visible', value);
}
}
},
watch: {
avatarImportDialogVisible(value) {
if (value) {
this.adjustDialogZ(this.$refs.avatarImportDialog.$el);
this.clearAvatarImportTable();
this.resetAvatarImport();
if (this.avatarImportDialogInput) {
this.avatarImportDialog.input = this.avatarImportDialogInput;
this.processAvatarImportList();
this.$emit('update:avatar-import-dialog-input', '');
}
}
}
},
methods: {
async processAvatarImportList() {
const D = this.avatarImportDialog;
D.loading = true;
const regexAvatarId = /avtr_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
let match = [];
const avatarIdList = new Set();
while ((match = regexAvatarId.exec(D.input)) !== null) {
avatarIdList.add(match[0]);
}
D.input = '';
D.errors = '';
D.progress = 0;
D.progressTotal = avatarIdList.size;
const data = Array.from(avatarIdList);
for (let i = 0; i < data.length; ++i) {
if (!this.isVisible) {
this.resetAvatarImport();
}
if (!D.loading || !this.isVisible) {
break;
}
const avatarId = data[i];
if (!D.avatarIdList.has(avatarId)) {
try {
const args = await avatarRequest.getAvatar({
avatarId
});
this.avatarImportTable.data.push(args.ref);
D.avatarIdList.add(avatarId);
} catch (err) {
D.errors = D.errors.concat(`AvatarId: ${avatarId}\n${err}\n\n`);
}
}
D.progress++;
if (D.progress === avatarIdList.size) {
D.progress = 0;
}
}
D.loading = false;
},
deleteItemAvatarImport(ref) {
utils.removeFromArray(this.avatarImportTable.data, ref);
this.avatarImportDialog.avatarIdList.delete(ref.id);
},
resetAvatarImport() {
this.avatarImportDialog.input = '';
this.avatarImportDialog.errors = '';
},
clearAvatarImportTable() {
this.avatarImportTable.data = [];
this.avatarImportDialog.avatarIdList = new Set();
},
selectAvatarImportGroup(group) {
this.avatarImportDialog.avatarImportLocalFavoriteGroup = null;
this.avatarImportDialog.avatarImportFavoriteGroup = group;
},
selectAvatarImportLocalGroup(group) {
this.avatarImportDialog.avatarImportFavoriteGroup = null;
this.avatarImportDialog.avatarImportLocalFavoriteGroup = group;
},
cancelAvatarImport() {
this.avatarImportDialog.loading = false;
},
addFavoriteAvatar(ref, group, message) {
return favoriteRequest
.addFavorite({
type: 'avatar',
favoriteId: ref.id,
tags: group.name
})
.then((args) => {
if (message) {
this.$message({
message: 'Avatar added to favorites',
type: 'success'
});
}
return args;
});
},
async importAvatarImportTable() {
const D = this.avatarImportDialog;
if (!D.avatarImportFavoriteGroup && !D.avatarImportLocalFavoriteGroup) {
return;
}
D.loading = true;
const data = [...this.avatarImportTable.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.avatarImportFavoriteGroup) {
await this.addFavoriteAvatar(ref, D.avatarImportFavoriteGroup, false);
} else if (D.avatarImportLocalFavoriteGroup) {
this.$emit('add-local-avatar-favorite', ref.id, D.avatarImportLocalFavoriteGroup);
}
utils.removeFromArray(this.avatarImportTable.data, ref);
D.avatarIdList.delete(ref.id);
D.importProgress++;
}
} catch (err) {
D.errors = `Name: ${ref.name}\nAvatarId: ${ref.id}\n${err}\n\n`;
} finally {
D.importProgress = 0;
D.importProgressTotal = 0;
D.loading = false;
}
}
}
};
</script>
@@ -0,0 +1,130 @@
<template>
<el-dialog
:before-close="beforeDialogClose"
:visible.sync="isDialogVisible"
class="x-dialog"
:title="$t('dialog.friend_export.header')"
width="650px"
destroy-on-close
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<el-dropdown trigger="click" size="small" @click.native.stop>
<el-button size="mini">
<span v-if="friendExportFavoriteGroup">
{{ friendExportFavoriteGroup.displayName }} ({{ friendExportFavoriteGroup.count }}/{{
friendExportFavoriteGroup.capacity
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>All Favorites <i class="el-icon-arrow-down el-icon--right"></i></span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item style="display: block; margin: 10px 0" @click.native="selectFriendExportGroup(null)">
All Favorites
</el-dropdown-item>
<template v-for="groupAPI in API.favoriteFriendGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
@click.native="selectFriendExportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<br />
<el-input
v-model="friendExportContent"
type="textarea"
size="mini"
rows="15"
resize="none"
readonly
style="margin-top: 15px"
@click.native="handleCopyFriendExportData"></el-input>
</el-dialog>
</template>
<script>
export default {
name: 'FriendExportDialog',
inject: ['API', 'beforeDialogClose', 'dialogMouseDown', 'dialogMouseUp'],
props: {
friendExportDialogVisible: Boolean,
favoriteFriends: Array
},
data() {
return {
friendExportFavoriteGroup: null,
friendExportContent: ''
};
},
computed: {
isDialogVisible: {
get() {
return this.friendExportDialogVisible;
},
set(value) {
this.$emit('update:friend-export-dialog-visible', value);
}
}
},
watch: {
friendExportDialogVisible(value) {
if (value) {
this.showFriendExportDialog();
}
}
},
methods: {
showFriendExportDialog() {
this.friendExportFavoriteGroup = null;
this.updateFriendExportDialog();
},
handleCopyFriendExportData(event) {
if (event.target.tagName === 'TEXTAREA') {
event.target.select();
}
navigator.clipboard
.writeText(this.friendExportContent)
.then(() => {
this.$message({
message: 'Copied successfully!',
type: 'success',
duration: 2000
});
})
.catch((err) => {
console.error('Copy failed:', err);
this.$message.error('Copy failed!');
});
},
updateFriendExportDialog() {
const _ = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
};
const lines = ['UserID,Name'];
this.API.favoriteFriendGroups.forEach((group) => {
if (!this.friendExportFavoriteGroup || this.friendExportFavoriteGroup === group) {
this.favoriteFriends.forEach((ref) => {
if (group.key === ref.groupKey) {
lines.push(`${_(ref.id)},${_(ref.name)}`);
}
});
}
});
this.friendExportContent = lines.join('\n');
},
selectFriendExportGroup(group) {
this.friendExportFavoriteGroup = group;
this.updateFriendExportDialog();
}
}
};
</script>
@@ -0,0 +1,309 @@
<template>
<el-dialog
ref="friendImportDialog"
:before-close="beforeDialogClose"
:visible.sync="isVisible"
:title="$t('dialog.friend_import.header')"
width="650px"
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<div style="display: flex; align-items: center; justify-content: space-between">
<div style="font-size: 12px">{{ $t('dialog.friend_import.description') }}</div>
<div style="display: flex; align-items: center">
<div v-if="friendImportDialog.progress">
{{ $t('dialog.friend_import.process_progress') }} {{ friendImportDialog.progress }} /
{{ friendImportDialog.progressTotal }}
<i class="el-icon-loading" style="margin: 0 5px"></i>
</div>
<el-button v-if="friendImportDialog.loading" size="small" @click="cancelFriendImport">
{{ $t('dialog.friend_import.cancel') }}
</el-button>
<el-button v-else size="small" :disabled="!friendImportDialog.input" @click="processFriendImportList">
{{ $t('dialog.friend_import.process_list') }}
</el-button>
</div>
</div>
<el-input
v-model="friendImportDialog.input"
type="textarea"
size="mini"
rows="10"
resize="none"
style="margin-top: 10px" />
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 5px">
<div>
<el-dropdown trigger="click" size="small" @click.native.stop>
<el-button size="mini">
<span v-if="friendImportDialog.friendImportFavoriteGroup">
{{ friendImportDialog.friendImportFavoriteGroup.displayName }} ({{
friendImportDialog.friendImportFavoriteGroup.count
}}/{{ friendImportDialog.friendImportFavoriteGroup.capacity }})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else
>{{ $t('dialog.friend_import.select_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.favoriteFriendGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="selectFriendImportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<span v-if="friendImportDialog.friendImportFavoriteGroup" style="margin-left: 5px">
{{ friendImportTable.data.length }} /
{{
friendImportDialog.friendImportFavoriteGroup.capacity -
friendImportDialog.friendImportFavoriteGroup.count
}}
</span>
</div>
<div>
<el-button size="small" :disabled="friendImportTable.data.length === 0" @click="clearFriendImportTable">
{{ $t('dialog.friend_import.clear_table') }}
</el-button>
<el-button
size="small"
type="primary"
style="margin: 5px"
:disabled="friendImportTable.data.length === 0 || !friendImportDialog.friendImportFavoriteGroup"
@click="importFriendImportTable">
{{ $t('dialog.friend_import.import') }}
</el-button>
</div>
</div>
<span v-if="friendImportDialog.importProgress" style="margin: 10px">
<i class="el-icon-loading" style="margin-right: 5px"></i>
{{ $t('dialog.friend_import.import_progress') }} {{ friendImportDialog.importProgress }}/{{
friendImportDialog.importProgressTotal
}}
</span>
<br />
<template v-if="friendImportDialog.errors">
<el-button size="small" @click="friendImportDialog.errors = ''">
{{ $t('dialog.friend_import.clear_errors') }}
</el-button>
<h2 style="font-weight: bold; margin: 5px 0">{{ $t('dialog.friend_import.errors') }}</h2>
<pre style="white-space: pre-wrap; font-size: 12px" v-text="friendImportDialog.errors"></pre>
</template>
<data-tables v-loading="friendImportDialog.loading" v-bind="friendImportTable" style="margin-top: 10px">
<el-table-column :label="$t('table.import.image')" width="70" prop="currentAvatarThumbnailImageUrl">
<template slot-scope="scope">
<el-popover placement="right" height="500px" trigger="hover">
<template slot="reference">
<img class="friends-list-avatar" :src="userImage(scope.row)" />
</template>
<img
class="friends-list-avatar"
:src="userImageFull(scope.row)"
style="height: 500px; cursor: pointer"
@click="showFullscreenImageDialog(userImageFull(scope.row))" />
</el-popover>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.name')" prop="displayName">
<template slot-scope="scope">
<span class="x-link" :title="scope.row.displayName" @click="showUserDialog(scope.row.id)">
{{ scope.row.displayName }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.action')" width="90" align="right">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-close" size="mini" @click="deleteItemFriendImport(scope.row)">
</el-button>
</template>
</el-table-column>
</data-tables>
</el-dialog>
</template>
<script>
import utils from '../../../classes/utils';
import { favoriteRequest, userRequest } from '../../../api';
export default {
name: 'FriendImportDialog',
inject: [
'API',
'userImage',
'userImageFull',
'showFullscreenImageDialog',
'showUserDialog',
'beforeDialogClose',
'dialogMouseDown',
'dialogMouseUp',
'adjustDialogZ'
],
props: {
friendImportDialogVisible: {
type: Boolean,
required: true
},
friendImportDialogInput: {
type: String,
required: false,
default: ''
}
},
data() {
return {
friendImportDialog: {
loading: false,
progress: 0,
progressTotal: 0,
input: '',
userIdList: new Set(),
errors: '',
friendImportFavoriteGroup: null,
importProgress: 0,
importProgressTotal: 0
},
friendImportTable: {
data: [],
tableProps: {
stripe: true,
size: 'mini'
},
layout: 'table'
}
};
},
computed: {
isVisible: {
get() {
return this.friendImportDialogVisible;
},
set(value) {
this.$emit('update:friend-import-dialog-visible', value);
}
}
},
watch: {
friendImportDialogVisible(value) {
if (value) {
this.adjustDialogZ(this.$refs.friendImportDialog.$el);
this.clearFriendImportTable();
this.resetFriendImport();
if (this.friendImportDialogInput) {
this.friendImportDialog.input = this.friendImportDialogInput;
this.processFriendImportList();
this.$emit('update:friend-import-dialog-input', '');
}
}
}
},
methods: {
cancelFriendImport() {
this.friendImportDialog.loading = false;
},
deleteItemFriendImport(ref) {
utils.removeFromArray(this.friendImportTable.data, ref);
this.friendImportDialog.userIdList.delete(ref.id);
},
clearFriendImportTable() {
this.friendImportTable.data = [];
this.friendImportDialog.userIdList = new Set();
},
selectFriendImportGroup(group) {
this.friendImportDialog.friendImportFavoriteGroup = group;
},
async importFriendImportTable() {
const D = this.friendImportDialog;
D.loading = true;
if (!D.friendImportFavoriteGroup) {
return;
}
const data = [...this.friendImportTable.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];
await this.addFavoriteUser(ref, D.friendImportFavoriteGroup, false);
utils.removeFromArray(this.friendImportTable.data, ref);
D.userIdList.delete(ref.id);
D.importProgress++;
}
} catch (err) {
D.errors = `Name: ${ref.displayName}\nUserId: ${ref.id}\n${err}\n\n`;
} finally {
D.importProgress = 0;
D.importProgressTotal = 0;
D.loading = false;
}
},
addFavoriteUser(ref, group, message) {
return favoriteRequest
.addFavorite({
type: 'friend',
favoriteId: ref.id,
tags: group.name
})
.then((args) => {
if (message) {
this.$message({
message: 'Friend added to favorites',
type: 'success'
});
}
return args;
});
},
async processFriendImportList() {
const D = this.friendImportDialog;
D.loading = true;
const regexFriendId = /usr_[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}/g;
let match = [];
const userIdList = new Set();
while ((match = regexFriendId.exec(D.input)) !== null) {
userIdList.add(match[0]);
}
D.input = '';
D.errors = '';
D.progress = 0;
D.progressTotal = userIdList.size;
const data = Array.from(userIdList);
for (let i = 0; i < data.length; ++i) {
if (!this.isVisible) {
this.resetFriendImport();
}
if (!D.loading || !this.isVisible) {
break;
}
const userId = data[i];
if (!D.userIdList.has(userId)) {
try {
const args = await userRequest.getUser({
userId
});
this.friendImportTable.data.push(args.ref);
D.userIdList.add(userId);
} catch (err) {
D.errors = D.errors.concat(`UserId: ${userId}\n${err}\n\n`);
}
}
D.progress++;
if (D.progress === userIdList.size) {
D.progress = 0;
}
}
D.loading = false;
},
resetFriendImport() {
this.friendImportDialog.input = '';
this.friendImportDialog.errors = '';
}
}
};
</script>
@@ -0,0 +1,237 @@
<template>
<el-dialog
:before-close="beforeDialogClose"
:visible.sync="isDialogVisible"
:title="$t('dialog.world_export.header')"
width="650px"
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<el-checkbox-group
v-model="exportSelectedOptions"
style="margin-bottom: 10px"
@change="updateWorldExportDialog">
<template v-for="option in exportSelectOptions">
<el-checkbox :key="option.value" :label="option.label"></el-checkbox>
</template>
</el-checkbox-group>
<el-dropdown trigger="click" size="small" @click.native.stop>
<el-button size="mini">
<span v-if="worldExportFavoriteGroup">
{{ worldExportFavoriteGroup.displayName }} ({{ worldExportFavoriteGroup.count }}/{{
worldExportFavoriteGroup.capacity
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
All Favorites
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item style="display: block; margin: 10px 0" @click.native="selectWorldExportGroup(null)">
None
</el-dropdown-item>
<template v-for="groupAPI in API.favoriteWorldGroups">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
@click.native="selectWorldExportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-dropdown trigger="click" size="small" style="margin-left: 10px" @click.native.stop>
<el-button size="mini">
<span v-if="worldExportLocalFavoriteGroup">
{{ worldExportLocalFavoriteGroup }} ({{
getLocalWorldFavoriteGroupLength(worldExportLocalFavoriteGroup)
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
Select Group
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
style="display: block; margin: 10px 0"
@click.native="selectWorldExportLocalGroup(null)">
None
</el-dropdown-item>
<template v-for="group in localWorldFavoriteGroups">
<el-dropdown-item
:key="group"
style="display: block; margin: 10px 0"
@click.native="selectWorldExportLocalGroup(group)">
{{ group }} ({{ localWorldFavorites[group].length }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<br />
<el-input
v-model="worldExportContent"
type="textarea"
size="mini"
rows="15"
resize="none"
readonly
style="margin-top: 15px"
@click.native="handleCopyWorldExportData"></el-input>
</el-dialog>
</template>
<script>
export default {
name: 'WorldExportDialog',
inject: ['API', 'beforeDialogClose', 'dialogMouseDown', 'dialogMouseUp'],
props: {
favoriteWorlds: Array,
worldExportDialogVisible: Boolean,
localWorldFavorites: Object,
localWorldFavoriteGroups: Array,
localWorldFavoritesList: Array
},
data() {
return {
worldExportContent: '',
worldExportFavoriteGroup: null,
worldExportLocalFavoriteGroup: null,
// Storage of selected filtering options for model and world export
exportSelectedOptions: ['ID', 'Name'],
exportSelectOptions: [
{ label: 'ID', value: 'id' },
{ label: 'Name', value: 'name' },
{ label: 'Author ID', value: 'authorId' },
{ label: 'Author Name', value: 'authorName' },
{ label: 'Thumbnail', value: 'thumbnailImageUrl' }
]
};
},
computed: {
isDialogVisible: {
get() {
return this.worldExportDialogVisible;
},
set(value) {
this.$emit('update:world-export-dialog-visible', value);
}
}
},
watch: {
worldExportDialogVisible(value) {
if (value) {
this.showWorldExportDialog();
}
}
},
methods: {
showWorldExportDialog() {
this.worldExportFavoriteGroup = null;
this.worldExportLocalFavoriteGroup = null;
this.updateWorldExportDialog();
},
handleCopyWorldExportData(event) {
if (event.target.tagName === 'TEXTAREA') {
event.target.select();
}
navigator.clipboard
.writeText(this.worldExportContent)
.then(() => {
this.$message({
message: 'Copied successfully!',
type: 'success',
duration: 2000
});
})
.catch((err) => {
console.error('Copy failed:', err);
this.$message.error('Copy failed!');
});
},
updateWorldExportDialog() {
const formatter = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
};
const propsForQuery = this.exportSelectOptions
.filter((option) => this.exportSelectedOptions.includes(option.label))
.map((option) => option.value);
function resText(ref) {
let resArr = [];
propsForQuery.forEach((e) => {
resArr.push(formatter(ref?.[e]));
});
return resArr.join(',');
}
const lines = [this.exportSelectedOptions.join(',')];
if (this.worldExportFavoriteGroup) {
this.API.favoriteWorldGroups.forEach((group) => {
if (this.worldExportFavoriteGroup === group) {
this.favoriteWorlds.forEach((ref) => {
if (group.key === ref.groupKey) {
lines.push(resText(ref.ref));
}
});
}
});
} else if (this.worldExportLocalFavoriteGroup) {
const favoriteGroup = this.localWorldFavorites[this.worldExportLocalFavoriteGroup];
if (!favoriteGroup) {
return;
}
for (let i = 0; i < favoriteGroup.length; ++i) {
const ref = favoriteGroup[i];
lines.push(resText(ref));
}
} else {
// export all
this.favoriteWorlds.forEach((ref) => {
lines.push(resText(ref.ref));
});
for (let i = 0; i < this.localWorldFavoritesList.length; ++i) {
const worldId = this.localWorldFavoritesList[i];
const ref = this.API.cachedWorlds.get(worldId);
if (typeof ref !== 'undefined') {
lines.push(resText(ref));
}
}
}
this.worldExportContent = lines.join('\n');
},
selectWorldExportGroup(group) {
this.worldExportFavoriteGroup = group;
this.worldExportLocalFavoriteGroup = null;
this.updateWorldExportDialog();
},
selectWorldExportLocalGroup(group) {
this.worldExportLocalFavoriteGroup = group;
this.worldExportFavoriteGroup = null;
this.updateWorldExportDialog();
},
getLocalWorldFavoriteGroupLength(group) {
const favoriteGroup = this.localWorldFavorites[group];
if (!favoriteGroup) {
return 0;
}
return favoriteGroup.length;
}
}
};
</script>
@@ -0,0 +1,372 @@
<template>
<el-dialog
ref="worldImportDialog"
:before-close="beforeDialogClose"
:visible.sync="isVisible"
:title="$t('dialog.world_import.header')"
width="650px"
top="10vh"
class="x-dialog"
@mousedown.native="dialogMouseDown"
@mouseup.native="dialogMouseUp">
<div style="display: flex; align-items: center; justify-content: space-between">
<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') }}
{{ 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') }}
</el-button>
<el-button v-else size="small" :disabled="!worldImportDialog.input" @click="processWorldImportList">
{{ $t('dialog.world_import.process_list') }}
</el-button>
</div>
</div>
<el-input
v-model="worldImportDialog.input"
type="textarea"
size="mini"
rows="10"
resize="none"
style="margin-top: 10px"></el-input>
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 5px">
<div>
<el-dropdown trigger="click" size="small" style="margin-right: 5px" @click.native.stop>
<el-button size="mini">
<span v-if="worldImportDialog.worldImportFavoriteGroup">
{{ worldImportDialog.worldImportFavoriteGroup.displayName }}
({{ worldImportDialog.worldImportFavoriteGroup.count }}/{{
worldImportDialog.worldImportFavoriteGroup.capacity
}})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $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">
<el-dropdown-item
:key="groupAPI.name"
style="display: block; margin: 10px 0"
:disabled="groupAPI.count >= groupAPI.capacity"
@click.native="selectWorldImportGroup(groupAPI)">
{{ groupAPI.displayName }} ({{ groupAPI.count }}/{{ groupAPI.capacity }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<el-dropdown trigger="click" size="small" style="margin: 5px" @click.native.stop>
<el-button size="mini">
<span v-if="worldImportDialog.worldImportLocalFavoriteGroup">
{{ worldImportDialog.worldImportLocalFavoriteGroup }}
({{ getLocalWorldFavoriteGroupLength(worldImportDialog.worldImportLocalFavoriteGroup) }})
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<span v-else>
{{ $t('dialog.world_import.select_local_group_placeholder') }}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
</el-button>
<el-dropdown-menu slot="dropdown">
<template v-for="group in localWorldFavoriteGroups">
<el-dropdown-item
:key="group"
style="display: block; margin: 10px 0"
@click.native="selectWorldImportLocalGroup(group)">
{{ group }} ({{ getLocalWorldFavoriteGroupLength(group) }})
</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
<span v-if="worldImportDialog.worldImportFavoriteGroup" style="margin-left: 5px">
{{ worldImportTable.data.length }} /
{{
worldImportDialog.worldImportFavoriteGroup.capacity -
worldImportDialog.worldImportFavoriteGroup.count
}}
</span>
</div>
<div>
<el-button size="small" :disabled="worldImportTable.data.length === 0" @click="clearWorldImportTable">
{{ $t('dialog.world_import.clear_table') }}
</el-button>
<el-button
size="small"
type="primary"
style="margin: 5px"
:disabled="
worldImportTable.data.length === 0 ||
(!worldImportDialog.worldImportFavoriteGroup &&
!worldImportDialog.worldImportLocalFavoriteGroup)
"
@click="importWorldImportTable">
{{ $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') }}
{{ worldImportDialog.importProgress }}/{{ worldImportDialog.importProgressTotal }}
</span>
<br />
<template v-if="worldImportDialog.errors">
<el-button size="small" @click="worldImportDialog.errors = ''">
{{ $t('dialog.world_import.clear_errors') }}
</el-button>
<h2 style="font-weight: bold; margin: 5px 0">
{{ $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">
<template slot-scope="scope">
<el-popover placement="right" height="500px" trigger="hover">
<img slot="reference" v-lazy="scope.row.thumbnailImageUrl" class="friends-list-avatar" />
<img
v-lazy="scope.row.imageUrl"
class="friends-list-avatar"
style="height: 500px; cursor: pointer"
@click="showFullscreenImageDialog(scope.row.imageUrl)" />
</el-popover>
</template>
</el-table-column>
<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">
<template slot-scope="scope">
<span
class="x-link"
@click="showUserDialog(scope.row.authorId)"
v-text="scope.row.authorName"></span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.status')" width="70" prop="releaseStatus">
<template slot-scope="scope">
<span
:style="{
color:
scope.row.releaseStatus === 'public'
? '#67c23a'
: scope.row.releaseStatus === 'private'
? '#f56c6c'
: undefined
}"
v-text="
scope.row.releaseStatus.charAt(0).toUpperCase() + scope.row.releaseStatus.slice(1)
"></span>
</template>
</el-table-column>
<el-table-column :label="$t('table.import.action')" width="90" align="right">
<template slot-scope="scope">
<el-button
type="text"
icon="el-icon-close"
size="mini"
@click="deleteItemWorldImport(scope.row)"></el-button>
</template>
</el-table-column>
</data-tables>
</el-dialog>
</template>
<script>
import { favoriteRequest, worldRequest } from '../../../api';
import utils from '../../../classes/utils';
export default {
name: 'WorldImportDialog',
inject: [
'API',
'beforeDialogClose',
'dialogMouseDown',
'dialogMouseUp',
'showFullscreenImageDialog',
'showUserDialog',
'adjustDialogZ',
'showWorldDialog'
],
props: {
worldImportDialogVisible: Boolean,
worldImportDialogInput: String,
getLocalWorldFavoriteGroupLength: Function,
localWorldFavoriteGroups: Array
},
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'
}
};
},
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);
},
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;
}
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('add-local-world-favorite', 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;
});
}
}
};
</script>