chore: sync latest changes

This commit is contained in:
2026-06-09 17:21:54 +08:00
parent bca137535b
commit 451c6ea025
12 changed files with 503 additions and 28 deletions

View File

@@ -0,0 +1,156 @@
<script setup lang="ts">
import type { AchievementDef } from '@engine/types'
defineProps<{
definitions: AchievementDef[]
unlockedIds: Set<string>
}>()
const emit = defineEmits<{
close: []
}>()
</script>
<template>
<div class="ach-overlay" @click.self="emit('close')" @keydown.escape="emit('close')">
<div class="ach-panel">
<h2 class="ach-title">成就</h2>
<div class="ach-list">
<div
v-for="ach in definitions"
:key="ach.id"
class="ach-card"
:class="{ locked: !unlockedIds.has(ach.id), hidden: ach.hidden && !unlockedIds.has(ach.id) }"
>
<div class="ach-icon">
<img v-if="ach.icon" :src="ach.icon" class="ach-img" />
<span v-else class="ach-star">{{ unlockedIds.has(ach.id) ? '⭐' : '🔒' }}</span>
</div>
<div class="ach-body">
<div class="ach-title-text">
{{ !unlockedIds.has(ach.id) && ach.hidden ? '???' : ach.title }}
</div>
<div class="ach-desc-text">
{{ !unlockedIds.has(ach.id) && ach.hidden ? '' : ach.description }}
</div>
</div>
</div>
</div>
<button class="ach-close" @click="emit('close')">关闭</button>
</div>
</div>
</template>
<style scoped>
.ach-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.88);
display: flex;
align-items: center;
justify-content: center;
z-index: 200;
}
.ach-panel {
background: #1a1a2e;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 10px;
padding: 36px 40px;
min-width: 420px;
max-width: 520px;
max-height: 80vh;
display: flex;
flex-direction: column;
}
.ach-title {
text-align: center;
font-size: 22px;
font-weight: 400;
color: #ddd;
letter-spacing: 3px;
margin-bottom: 24px;
}
.ach-list {
display: flex;
flex-direction: column;
gap: 8px;
overflow-y: auto;
padding-right: 8px;
}
.ach-card {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 14px;
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 6px;
}
.ach-card.locked {
opacity: 0.4;
}
.ach-card.hidden {
opacity: 0.2;
}
.ach-icon {
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.ach-star {
font-size: 20px;
}
.ach-img {
width: 100%;
height: 100%;
object-fit: contain;
}
.ach-body {
display: flex;
flex-direction: column;
gap: 2px;
}
.ach-title-text {
font-size: 14px;
color: #eee;
}
.ach-desc-text {
font-size: 12px;
color: #888;
}
.ach-close {
margin-top: 20px;
padding: 10px 36px;
font-size: 14px;
color: #888;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 4px;
cursor: pointer;
transition: background 0.15s, color 0.15s;
align-self: center;
}
.ach-close:hover {
background: rgba(255, 255, 255, 0.1);
color: #ccc;
}
</style>

View File

@@ -0,0 +1,108 @@
<script setup lang="ts">
import { computed, watch, ref } from 'vue'
import type { AchievementDef } from '@engine/types'
const props = defineProps<{
achievementId: string
definitions: AchievementDef[]
}>()
const emit = defineEmits<{
done: []
}>()
const visible = ref(false)
const def = computed(() => props.definitions.find((d) => d.id === props.achievementId))
watch(() => props.achievementId, (id) => {
if (!id) return
visible.value = true
setTimeout(() => {
visible.value = false
setTimeout(() => emit('done'), 400)
}, 3000)
}, { immediate: true })
</script>
<template>
<div class="achievement-toast" v-if="visible && def" :class="{ show: visible }">
<div class="toast-icon">
<img v-if="def.icon" :src="def.icon" class="toast-img" />
<span v-else class="toast-star"></span>
</div>
<div class="toast-body">
<div class="toast-label">成就解锁</div>
<div class="toast-title">{{ def.title }}</div>
<div class="toast-desc">{{ def.description }}</div>
</div>
</div>
</template>
<style scoped>
.achievement-toast {
position: fixed;
bottom: 24px;
left: 50%;
transform: translateX(-50%) translateY(100px);
background: rgba(20, 20, 40, 0.95);
border: 1px solid rgba(255, 193, 7, 0.4);
border-radius: 8px;
padding: 14px 20px;
display: flex;
align-items: center;
gap: 14px;
z-index: 300;
min-width: 320px;
opacity: 0;
transition: transform 0.4s ease, opacity 0.4s ease;
}
.achievement-toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
.toast-icon {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.toast-star {
font-size: 24px;
}
.toast-img {
width: 100%;
height: 100%;
object-fit: contain;
}
.toast-body {
display: flex;
flex-direction: column;
gap: 2px;
}
.toast-label {
font-size: 11px;
color: #ffc107;
text-transform: uppercase;
letter-spacing: 1px;
}
.toast-title {
font-size: 15px;
color: #fff;
font-weight: 600;
}
.toast-desc {
font-size: 12px;
color: #aaa;
}
</style>