mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
simplfiy favorite world item
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import { computed, reactive, ref, toRaw, watch } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -342,6 +342,9 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
let ref;
|
||||
const favorite = getCachedFavoritesByObjectId(objectId);
|
||||
let ctx = state.favoriteObjects.get(objectId);
|
||||
if (ctx) {
|
||||
ctx = toRaw(ctx);
|
||||
}
|
||||
if (typeof favorite !== 'undefined') {
|
||||
let isTypeChanged = false;
|
||||
if (typeof ctx === 'undefined') {
|
||||
|
||||
@@ -23,28 +23,16 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<template v-else>
|
||||
<el-tooltip
|
||||
<i
|
||||
v-if="favorite.deleted"
|
||||
placement="left"
|
||||
:content="t('view.favorite.unavailable_tooltip')"
|
||||
:teleported="false">
|
||||
<el-icon><Warning /></el-icon>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
:title="t('view.favorite.unavailable_tooltip')"
|
||||
class="ri-error-warning-line"></i>
|
||||
<i
|
||||
v-if="favorite.ref.releaseStatus === 'private'"
|
||||
placement="left"
|
||||
:content="t('view.favorite.private')"
|
||||
:teleported="false">
|
||||
<el-icon><Warning /></el-icon>
|
||||
</el-tooltip>
|
||||
:title="t('view.favorite.private')"
|
||||
class="ri-lock-line"></i>
|
||||
<el-tooltip placement="left" :teleported="false">
|
||||
<template #content>
|
||||
{{
|
||||
canOpenInstanceInGame
|
||||
? t('dialog.world.actions.new_instance_and_open_ingame')
|
||||
: t('dialog.world.actions.new_instance_and_self_invite')
|
||||
}}
|
||||
</template>
|
||||
<template #content> {{ inviteOrLaunchText }} </template>
|
||||
<el-button
|
||||
size="small"
|
||||
:icon="Message"
|
||||
@@ -52,34 +40,27 @@
|
||||
@click.stop="newInstanceSelfInvite(favorite.id)"
|
||||
circle></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="right" :content="t('view.favorite.unfavorite_tooltip')" :teleported="false">
|
||||
<el-button
|
||||
:icon="Star"
|
||||
size="small"
|
||||
circle
|
||||
style="margin-left: 5px"
|
||||
type="default"
|
||||
@click.stop="showFavoriteDialog('world', favorite.id)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
size="small"
|
||||
circle
|
||||
style="margin-left: 5px"
|
||||
type="default"
|
||||
@click.stop="showFavoriteDialog('world', favorite.id)"
|
||||
><i class="ri-delete-bin-line"></i
|
||||
></el-button>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="avatar"></div>
|
||||
<div class="detail" v-once>
|
||||
<span>{{ favorite.name || favorite.id }}</span>
|
||||
<el-tooltip
|
||||
<i
|
||||
v-if="favorite.deleted"
|
||||
placement="left"
|
||||
:content="t('view.favorite.unavailable_tooltip')"
|
||||
:teleported="false">
|
||||
<el-icon><Warning /></el-icon>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="Close"
|
||||
size="small"
|
||||
style="margin-left: 5px"
|
||||
@click.stop="handleDeleteFavorite"></el-button>
|
||||
:title="t('view.favorite.unavailable_tooltip')"
|
||||
class="ri-error-warning-line"></i>
|
||||
<el-button type="text" size="small" style="margin-left: 5px" @click.stop="handleDeleteFavorite"
|
||||
><i class="ri-delete-bin-line"></i
|
||||
></el-button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -87,7 +68,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Close, Message, Star, Warning } from '@element-plus/icons-vue';
|
||||
import { Message } from '@element-plus/icons-vue';
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -120,6 +101,12 @@
|
||||
return url || props.favorite.ref.thumbnailImageUrl;
|
||||
});
|
||||
|
||||
const inviteOrLaunchText = computed(() => {
|
||||
return canOpenInstanceInGame
|
||||
? t('dialog.world.actions.new_instance_and_open_ingame')
|
||||
: t('dialog.world.actions.new_instance_and_self_invite');
|
||||
});
|
||||
|
||||
function handleDeleteFavorite() {
|
||||
if (props.isLocalFavorite) {
|
||||
emit('remove-local-world-favorite', props.favorite.id, props.group);
|
||||
|
||||
@@ -21,11 +21,7 @@
|
||||
<template v-else>
|
||||
<el-tooltip placement="left">
|
||||
<template #content>
|
||||
{{
|
||||
canOpenInstanceInGame
|
||||
? t('dialog.world.actions.new_instance_and_open_ingame')
|
||||
: t('dialog.world.actions.new_instance_and_self_invite')
|
||||
}}
|
||||
{{ inviteOrLaunchText }}
|
||||
</template>
|
||||
<el-button
|
||||
size="small"
|
||||
@@ -34,23 +30,24 @@
|
||||
@click.stop="newInstanceSelfInvite(favorite.id)"
|
||||
circle></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip placement="right" :content="t('view.favorite.unfavorite_tooltip')" :teleported="false">
|
||||
<el-button
|
||||
v-if="shiftHeld"
|
||||
size="small"
|
||||
: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="Star"
|
||||
size="small"
|
||||
circle
|
||||
style="margin-left: 5px"
|
||||
type="default"
|
||||
@click.stop="showFavoriteDialog('world', favorite.id)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-button
|
||||
v-if="shiftHeld"
|
||||
size="small"
|
||||
:icon="Close"
|
||||
circle
|
||||
style="color: #f56c6c; margin-left: 5px"
|
||||
@click.stop="$emit('remove-local-world-favorite', favorite.id, group)"
|
||||
><i class="ri-delete-bin-line"></i
|
||||
></el-button>
|
||||
<el-button
|
||||
v-else
|
||||
size="small"
|
||||
circle
|
||||
style="margin-left: 5px"
|
||||
type="default"
|
||||
@click.stop="showFavoriteDialog('world', favorite.id)"
|
||||
><i class="ri-delete-bin-line"></i
|
||||
></el-button>
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -70,7 +67,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Close, Message, Star } from '@element-plus/icons-vue';
|
||||
import { Close, Message } from '@element-plus/icons-vue';
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -97,6 +94,12 @@
|
||||
return url || props.favorite.thumbnailImageUrl;
|
||||
});
|
||||
|
||||
const inviteOrLaunchText = computed(() => {
|
||||
return canOpenInstanceInGame
|
||||
? t('dialog.world.actions.new_instance_and_open_ingame')
|
||||
: t('dialog.world.actions.new_instance_and_self_invite');
|
||||
});
|
||||
|
||||
function handleDeleteFavorite() {
|
||||
emit('remove-local-world-favorite', props.favorite.id, props.group);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user