This commit is contained in:
akun
2025-04-16 15:03:49 +08:00
4 changed files with 254 additions and 162 deletions
+1 -19
View File
@@ -1,25 +1,7 @@
# 构建阶段
FROM node:18-alpine as builder
WORKDIR /app
# 复制项目文件
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制源代码
COPY . .
# 构建项目
RUN npm run build
# 生产阶段
FROM nginx:1.25.3-alpine FROM nginx:1.25.3-alpine
# 从构建阶段复制构建结果到nginx目录 # 从构建阶段复制构建结果到nginx目录
COPY --from=builder /app/dist /usr/share/nginx/html ADD go_fish_web.tar.gz /usr/share/nginx/html
# 复制nginx配置 # 复制nginx配置
COPY ./nginx.conf /etc/nginx/conf.d/default.conf COPY ./nginx.conf /etc/nginx/conf.d/default.conf
Vendored
+64
View File
@@ -0,0 +1,64 @@
pipeline {
agent any
stages {
stage('📄文件信息') {
steps {
sh 'pwd'
sh 'ls -al'
echo '🚀开始推送文件到坤爷服务器'
sh 'scp Dockerfile root@47.109.22.188:~/go_fish_web'
sh 'scp nginx.conf root@47.109.22.188:~/go_fish_web'
echo '✨推送完成'
}
}
stage('🛠️构建项目') {
steps {
withDockerContainer('node:18-alpine') {
sh 'npm -v'
sh 'npm config set registry https://registry.npmmirror.com'
sh 'npm install'
sh 'npm run build'
sh 'ls -al'
}
}
}
stage('🎁打包制品'){
steps {
dir('dist') {
sh 'ls -al'
sh 'tar -zcvf go_fish_web.tar.gz *'
archiveArtifacts artifacts: 'go_fish_web.tar.gz',
allowEmptyArchive: true,
fingerprint: true,
onlyIfSuccessful: true
sh 'ls -al'
echo '🚀开始推送制品到坤爷服务器'
sh 'scp go_fish_web.tar.gz root@47.109.22.188:~/go_fish_web'
echo '✨推送完成'
}
}
}
stage('🏓远程部署') {
steps {
echo '🚀开始远程部署'
sh 'ssh root@47.109.22.188 "docker stop go_fish_web && docker rm go_fish_web && docker rmi go_fish_web && docker build -t go_fish_web ~/go_fish_web"'
sh 'ssh root@47.109.22.188 "docker run --restart=always --name go_fish_web -d -p 30030:80 -v /etc/localtime:/etc/localtime:ro go_fish_web"'
sh 'ssh root@47.109.22.188 "docker ps -a"'
echo '✨远程部署完成'
}
}
}
post {
success {
echo 'Deployment successful!'
}
failure {
echo 'Deployment failed.'
}
}
}
+19 -12
View File
@@ -156,19 +156,26 @@ const handleProcessFish = async () => {
// 手动处理鱼 // 手动处理鱼
const handleFish = async (fishId) => { const handleFish = async (fishId) => {
try { loading.value = true
loading.value = true; try {
const res = await handleFishById(fishId); const res = await handleFishById(fishId)
if (res) { if (res.success) {
ElMessage.success(res + " 🎉"); ElMessage.success(res.message + ' 🎉')
await fetchFishList(); fetchFishList()
}
else{
ElMessage.error(res.message + ' 😢')
}
} catch (err) {
console.log('====================================');
console.log(err);
console.log('====================================');
ElMessage.warning('处理失败,请稍后再试 ⏳')
} }
} catch (err) { finally {
ElMessage.warning("处理失败,请稍后再试 ⏳"); loading.value = false
} finally { }
loading.value = false; }
}
};
// 处理出售操作 // 处理出售操作
const handleSell = async (fish) => { const handleSell = async (fish) => {
+170 -131
View File
@@ -1,4 +1,5 @@
<template> <template>
<<<<<<< HEAD
<div class="fishing-page"> <div class="fishing-page">
<div class="fishing-container"> <div class="fishing-container">
<div class="fishing-area"> <div class="fishing-area">
@@ -11,38 +12,29 @@
> >
<div class="fishing-scene" @click="handleFish"></div> <div class="fishing-scene" @click="handleFish"></div>
<div class="ripple"></div> <div class="ripple"></div>
=======
<div class="fishing-page">
<div class="fishing-container">
<div class="fishing-area">
<div class="fishing-animation" :class="{ 'fishing-active': isFishing }">
<div class="fishing-scene" @click="handleFish"></div>
<div class="ripple"></div>
</div>
<div class="result" v-if="resultMessage || nextPullTime">
<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>
</div>
</div>
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
</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
/>
</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
>
</div>
</div>
</div> </div>
</div>
</template> </template>
<script setup> <script setup>
@@ -56,7 +48,7 @@ const router = useRouter();
const resultMessage = ref(""); const resultMessage = ref("");
const nextPullTime = ref(""); const nextPullTime = ref("");
const isFishing = ref(false); const isFishing = ref(false);
const currentCatch = ref(null); const currentCatch = ref([]); // 改为数组
const fishingLogs = ref([]); const fishingLogs = ref([]);
const clickCount = ref(0); const clickCount = ref(0);
const targetClicks = ref(0); const targetClicks = ref(0);
@@ -66,17 +58,18 @@ const fishEscapeTimer = ref(null);
// 从localStorage加载缓存的钓鱼日志 // 从localStorage加载缓存的钓鱼日志
const loadCachedLogs = () => { const loadCachedLogs = () => {
const cachedLogs = localStorage.getItem("fishingLogs"); const cachedLogs = localStorage.getItem("fishingLogs");
if (cachedLogs) { if (cachedLogs) {
fishingLogs.value = JSON.parse(cachedLogs); fishingLogs.value = JSON.parse(cachedLogs);
} }
}; };
// 保存钓鱼日志到localStorage // 保存钓鱼日志到localStorage
const saveLogs = () => { const saveLogs = () => {
localStorage.setItem("fishingLogs", JSON.stringify(fishingLogs.value)); localStorage.setItem("fishingLogs", JSON.stringify(fishingLogs.value));
}; };
<<<<<<< HEAD
// 生成随机点击阈值(1-5秒内的随机次数) // 生成随机点击阈值(1-5秒内的随机次数)
const generateRandomTarget = () => { const generateRandomTarget = () => {
return Math.floor(Math.random() * 15) + 5; // 5-20次随机点击 return Math.floor(Math.random() * 15) + 5; // 5-20次随机点击
@@ -98,10 +91,13 @@ const willReelFail = () => {
}; };
// 组件挂载时加载缓存的日志 // 组件挂载时加载缓存的日志
=======
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
onMounted(() => { onMounted(() => {
loadCachedLogs(); loadCachedLogs();
}); });
<<<<<<< HEAD
// 组件卸载时清除定时器 // 组件卸载时清除定时器
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (fishEscapeTimer.value) { if (fishEscapeTimer.value) {
@@ -179,103 +175,120 @@ const handleFish = async () => {
// 调用钓鱼接口 // 调用钓鱼接口
currentCatch.value = null; currentCatch.value = null;
resultMessage.value = "正在钓鱼中..."; resultMessage.value = "正在钓鱼中...";
=======
onBeforeUnmount(() => {
localStorage.removeItem("fishingLogs");
});
try { const handleFish = async () => {
const res = await fishingClick(); if (isFishing.value) return;
if (res.success && res.data) {
const items = res.data.items || [];
if (res.data.nextPullTime) {
nextPullTime.value = new Date(res.data.nextPullTime).toLocaleString();
}
if (items.length > 0) { isFishing.value = true;
const fish = items[0]; currentCatch.value = [];
currentCatch.value = fish; resultMessage.value = "正在钓鱼中...";
resultMessage.value = `你钓到了一条${fish.isRare ? "稀有的" : ""}${ >>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
fish.fishName
}」,重量 ${fish.weight}`;
ElMessage.success("钓鱼成功!🎣");
// 添加到日志并保存到localStorage try {
fishingLogs.value.unshift({ const res = await fishingClick();
time: new Date(), if (res.success && res.data) {
fishName: fish.fishName, const items = res.data.items || [];
weight: fish.weight, if (res.data.nextPullTime) {
isRare: fish.isRare, nextPullTime.value = new Date(res.data.nextPullTime).toLocaleString();
}); }
saveLogs();
} else { if (items.length > 0) {
resultMessage.value = "什么也没钓到,下次好运 🍀"; currentCatch.value = items;
ElMessage.warning("什么也没钓到,下次好运 🍀");
} // 构建展示信息
} else { const messageList = items.map(fish =>
resultMessage.value = res.message || "钓鱼失败"; `${fish.isRare ? "稀有的" : ""}${fish.fishName}」,重量 ${fish.weight}`
if (res.data?.nextPullTime) { );
nextPullTime.value = new Date(res.data.nextPullTime).toLocaleString(); resultMessage.value = `你钓到了:\n${messageList.join("\n")}`;
} ElMessage.success("钓鱼成功!🎣");
ElMessage.error(res.message || "钓鱼失败 🎣");
// 添加所有钓到的鱼到日志
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 = "什么也没钓到,下次好运 🍀";
ElMessage.warning("什么也没钓到,下次好运 🍀");
}
} else {
resultMessage.value = res.message || "钓鱼失败";
if (res.data?.nextPullTime) {
nextPullTime.value = new Date(res.data.nextPullTime).toLocaleString();
}
ElMessage.error(res.message || "钓鱼失败 🎣");
}
} catch (err) {
resultMessage.value = "钓鱼出错,请稍后重试";
ElMessage.error("钓鱼出错,请稍后重试 🌊");
console.error(err);
} finally {
isFishing.value = false;
} }
} catch (err) {
resultMessage.value = "钓鱼出错,请稍后重试";
ElMessage.error("钓鱼出错,请稍后重试 🌊");
console.error(err);
} finally {
isFishing.value = false;
}
}; };
const goHome = () => { const goHome = () => {
router.push("/"); router.push("/");
}; };
</script> </script>
<style scoped> <style scoped>
.fishing-page { .fishing-page {
padding: 20px; padding: 20px;
} }
.fishing-container { .fishing-container {
display: grid; display: grid;
grid-template-columns: 1fr 400px; grid-template-columns: 1fr 400px;
gap: 20px; gap: 20px;
max-width: 1200px; max-width: 1200px;
margin: 0 auto; margin: 0 auto;
min-height: calc(100vh - 40px); min-height: calc(100vh - 40px);
} }
.back-button { .back-button {
margin-top: 20px; margin-top: 20px;
text-align: center; text-align: center;
} }
.back-button .el-button { .back-button .el-button {
padding: 12px 24px; padding: 12px 24px;
font-size: 16px; font-size: 16px;
border-radius: 24px; border-radius: 24px;
transition: all 0.3s ease; transition: all 0.3s ease;
background: #409eff; background: #409eff;
border: 1px solid #409eff; border: 1px solid #409eff;
color: white; color: white;
font-weight: bold; font-weight: bold;
} }
.back-button .el-button:hover { .back-button .el-button:hover {
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(64, 158, 255, 0.3); box-shadow: 0 4px 16px rgba(64, 158, 255, 0.3);
background: #66b1ff; background: #66b1ff;
border-color: #66b1ff; border-color: #66b1ff;
} }
.fishing-area { .fishing-area {
text-align: center; text-align: center;
background: #fff; background: #fff;
padding: 20px; padding: 20px;
border-radius: 8px; border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
position: relative; position: relative;
} }
.fishing-animation { .fishing-animation {
<<<<<<< HEAD
height: 500px; height: 500px;
position: relative; position: relative;
margin: 20px 0; margin: 20px 0;
@@ -296,10 +309,29 @@ const goHome = () => {
background-size: cover; background-size: cover;
transition: transform 0.2s ease; transition: transform 0.2s ease;
pointer-events: auto; pointer-events: auto;
=======
height: 500px;
position: relative;
margin: 20px 0;
overflow: hidden;
border-radius: 8px;
background: #fff;
cursor: pointer;
}
.fishing-scene {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: url("@/assets/fishing-scene.svg") no-repeat center;
background-size: cover;
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
} }
.fishing-active .fishing-scene { .fishing-active .fishing-scene {
animation: scene-active 3s ease-in-out infinite; animation: scene-active 3s ease-in-out infinite;
} }
.reeling .fishing-scene { .reeling .fishing-scene {
@@ -307,44 +339,51 @@ const goHome = () => {
} }
.ripple { .ripple {
position: absolute; position: absolute;
width: 30px; width: 30px;
height: 30px; height: 30px;
background: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.7);
border-radius: 50%; border-radius: 50%;
left: 60%; left: 60%;
top: 70%; top: 70%;
transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0);
opacity: 0; opacity: 0;
} }
.fishing-active .ripple { .fishing-active .ripple {
animation: ripple 2s infinite; animation: ripple 2s infinite;
} }
<<<<<<< HEAD
=======
.fishing-controls {
margin: 20px 0;
}
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
.result { .result {
margin-top: 20px; margin-top: 20px;
} }
@keyframes ripple { @keyframes ripple {
0% { 0% {
transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0);
opacity: 1; opacity: 1;
} }
100% { 100% {
transform: translate(-50%, -50%) scale(4); transform: translate(-50%, -50%) scale(4);
opacity: 0; opacity: 0;
} }
} }
@keyframes scene-active { @keyframes scene-active {
0%, 0%,
100% { 100% {
transform: scale(1); transform: scale(1);
} }
50% { 50% {
transform: scale(1.02); transform: scale(1.02);
} }
} }
@keyframes reel { @keyframes reel {