akun 1 year ago
commit 7ebb1ab648

@ -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
# 从构建阶段复制构建结果到nginx目录
COPY --from=builder /app/dist /usr/share/nginx/html
ADD go_fish_web.tar.gz /usr/share/nginx/html
# 复制nginx配置
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

64
Jenkinsfile vendored

@ -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.'
}
}
}

@ -156,19 +156,26 @@ const handleProcessFish = async () => {
//
const handleFish = async (fishId) => {
loading.value = true
try {
loading.value = true;
const res = await handleFishById(fishId);
if (res) {
ElMessage.success(res + " 🎉");
await fetchFishList();
const res = await handleFishById(fishId)
if (res.success) {
ElMessage.success(res.message + ' 🎉')
fetchFishList()
}
else{
ElMessage.error(res.message + ' 😢')
}
} catch (err) {
ElMessage.warning("处理失败,请稍后再试 ⏳");
} finally {
loading.value = false;
console.log('====================================');
console.log(err);
console.log('====================================');
ElMessage.warning('处理失败,请稍后再试 ⏳')
}
finally {
loading.value = false
}
}
};
//
const handleSell = async (fish) => {

@ -1,4 +1,5 @@
<template>
<<<<<<< HEAD
<div class="fishing-page">
<div class="fishing-container">
<div class="fishing-area">
@ -11,36 +12,27 @@
>
<div class="fishing-scene" @click="handleFish"></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 ? '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>
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
</div>
</div>
</template>
@ -56,7 +48,7 @@ const router = useRouter();
const resultMessage = ref("");
const nextPullTime = ref("");
const isFishing = ref(false);
const currentCatch = ref(null);
const currentCatch = ref([]); //
const fishingLogs = ref([]);
const clickCount = ref(0);
const targetClicks = ref(0);
@ -77,6 +69,7 @@ const saveLogs = () => {
localStorage.setItem("fishingLogs", JSON.stringify(fishingLogs.value));
};
<<<<<<< HEAD
// 1-5
const generateRandomTarget = () => {
return Math.floor(Math.random() * 15) + 5; // 5-20
@ -98,10 +91,13 @@ const willReelFail = () => {
};
//
=======
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
onMounted(() => {
loadCachedLogs();
});
<<<<<<< HEAD
//
onBeforeUnmount(() => {
if (fishEscapeTimer.value) {
@ -179,6 +175,18 @@ const handleFish = async () => {
//
currentCatch.value = null;
resultMessage.value = "正在钓鱼中...";
=======
onBeforeUnmount(() => {
localStorage.removeItem("fishingLogs");
});
const handleFish = async () => {
if (isFishing.value) return;
isFishing.value = true;
currentCatch.value = [];
resultMessage.value = "正在钓鱼中...";
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
try {
const res = await fishingClick();
@ -189,20 +197,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 = "什么也没钓到,下次好运 🍀";
@ -227,6 +238,7 @@ const handleFish = async () => {
const goHome = () => {
router.push("/");
};
</script>
<style scoped>
@ -276,6 +288,7 @@ const goHome = () => {
}
.fishing-animation {
<<<<<<< HEAD
height: 500px;
position: relative;
margin: 20px 0;
@ -296,6 +309,25 @@ const goHome = () => {
background-size: cover;
transition: transform 0.2s ease;
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 {
@ -322,6 +354,13 @@ const goHome = () => {
animation: ripple 2s infinite;
}
<<<<<<< HEAD
=======
.fishing-controls {
margin: 20px 0;
}
>>>>>>> 4a4857fa8239db297faeeaf348f16654927c8bb7
.result {
margin-top: 20px;
}

Loading…
Cancel
Save