|
|
|
|
@ -7,32 +7,15 @@
|
|
|
|
|
<div class="ripple"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="result" v-if="resultMessage || nextPullTime">
|
|
|
|
|
<el-alert
|
|
|
|
|
v-if="resultMessage"
|
|
|
|
|
:title="resultMessage"
|
|
|
|
|
:type="currentCatch ? 'success' : 'info'"
|
|
|
|
|
:closable="false"
|
|
|
|
|
show-icon
|
|
|
|
|
/>
|
|
|
|
|
<el-alert
|
|
|
|
|
v-if="nextPullTime"
|
|
|
|
|
:title="`下次可钓鱼时间:${nextPullTime}`"
|
|
|
|
|
type="warning"
|
|
|
|
|
:closable="false"
|
|
|
|
|
show-icon
|
|
|
|
|
/>
|
|
|
|
|
<el-alert v-if="resultMessage" :title="resultMessage" :type="currentCatch.length>0 ? 'success' : 'info'"
|
|
|
|
|
:closable="false" show-icon />
|
|
|
|
|
<el-alert v-if="nextPullTime" :title="`下次可钓鱼时间:${nextPullTime}`" type="warning" :closable="false" show-icon />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="log-area">
|
|
|
|
|
<FishingLog :logs="fishingLogs" />
|
|
|
|
|
<div class="back-button">
|
|
|
|
|
<el-button
|
|
|
|
|
@click="goHome"
|
|
|
|
|
size="small"
|
|
|
|
|
type="default"
|
|
|
|
|
icon="ArrowLeft"
|
|
|
|
|
>返回</el-button
|
|
|
|
|
>
|
|
|
|
|
<el-button @click="goHome" size="small" type="default" icon="ArrowLeft">返回</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@ -50,7 +33,7 @@ const router = useRouter();
|
|
|
|
|
const resultMessage = ref("");
|
|
|
|
|
const nextPullTime = ref("");
|
|
|
|
|
const isFishing = ref(false);
|
|
|
|
|
const currentCatch = ref(null);
|
|
|
|
|
const currentCatch = ref([]); // 改为数组
|
|
|
|
|
const fishingLogs = ref([]);
|
|
|
|
|
|
|
|
|
|
// 从localStorage加载缓存的钓鱼日志
|
|
|
|
|
@ -66,12 +49,10 @@ const saveLogs = () => {
|
|
|
|
|
localStorage.setItem("fishingLogs", JSON.stringify(fishingLogs.value));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 组件挂载时加载缓存的日志
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
loadCachedLogs();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 组件卸载前清除缓存
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
localStorage.removeItem("fishingLogs");
|
|
|
|
|
});
|
|
|
|
|
@ -80,7 +61,7 @@ const handleFish = async () => {
|
|
|
|
|
if (isFishing.value) return;
|
|
|
|
|
|
|
|
|
|
isFishing.value = true;
|
|
|
|
|
currentCatch.value = null;
|
|
|
|
|
currentCatch.value = [];
|
|
|
|
|
resultMessage.value = "正在钓鱼中...";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -92,20 +73,23 @@ const handleFish = async () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (items.length > 0) {
|
|
|
|
|
const fish = items[0];
|
|
|
|
|
currentCatch.value = fish;
|
|
|
|
|
resultMessage.value = `你钓到了一条${fish.isRare ? "稀有的" : ""}「${
|
|
|
|
|
fish.fishName
|
|
|
|
|
}」,重量 ${fish.weight}`;
|
|
|
|
|
currentCatch.value = items;
|
|
|
|
|
|
|
|
|
|
// 构建展示信息
|
|
|
|
|
const messageList = items.map(fish =>
|
|
|
|
|
`「${fish.isRare ? "稀有的" : ""}${fish.fishName}」,重量 ${fish.weight}`
|
|
|
|
|
);
|
|
|
|
|
resultMessage.value = `你钓到了:\n${messageList.join("\n")}`;
|
|
|
|
|
ElMessage.success("钓鱼成功!🎣");
|
|
|
|
|
|
|
|
|
|
// 添加到日志并保存到localStorage
|
|
|
|
|
fishingLogs.value.unshift({
|
|
|
|
|
// 添加所有钓到的鱼到日志
|
|
|
|
|
const newLogs = items.map(fish => ({
|
|
|
|
|
time: new Date(),
|
|
|
|
|
fishName: fish.fishName,
|
|
|
|
|
weight: fish.weight,
|
|
|
|
|
isRare: fish.isRare,
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
fishingLogs.value.unshift(...newLogs);
|
|
|
|
|
saveLogs();
|
|
|
|
|
} else {
|
|
|
|
|
resultMessage.value = "什么也没钓到,下次好运 🍀";
|
|
|
|
|
@ -130,6 +114,7 @@ const handleFish = async () => {
|
|
|
|
|
const goHome = () => {
|
|
|
|
|
router.push("/");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|