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