feat: 前端更新改为定时拉取
This commit is contained in:
@@ -25,13 +25,6 @@
|
||||
@confirmed="onNoticeConfirmed"
|
||||
/>
|
||||
|
||||
<!-- 更新模态框 -->
|
||||
<UpdateModal
|
||||
v-model:visible="updateVisible"
|
||||
:update-data="updateData"
|
||||
@confirmed="onUpdateConfirmed"
|
||||
/>
|
||||
|
||||
<div class="content">
|
||||
<!-- 当期活动关卡 -->
|
||||
<a-card
|
||||
@@ -253,7 +246,6 @@ import { Service } from '@/api/services/Service'
|
||||
import NoticeModal from '@/components/NoticeModal.vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { API_ENDPOINTS } from '@/config/mirrors.ts'
|
||||
import UpdateModal from '@/components/UpdateModal.vue'
|
||||
|
||||
interface ActivityInfo {
|
||||
Tip: string
|
||||
@@ -308,11 +300,6 @@ const noticeVisible = ref(false)
|
||||
const noticeData = ref<Record<string, string>>({})
|
||||
const noticeLoading = ref(false)
|
||||
|
||||
// 更新相关
|
||||
const version = import.meta.env.VITE_APP_VERSION || '获取版本失败!'
|
||||
const updateVisible = ref(false)
|
||||
const updateData = ref<Record<string, string[]>>({})
|
||||
|
||||
// 获取当前活动信息
|
||||
const currentActivity = computed(() => {
|
||||
if (!activityData.value.length) return null
|
||||
@@ -492,35 +479,9 @@ const showNotice = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const checkUpdate = async () => {
|
||||
try {
|
||||
const response = await Service.checkUpdateApiUpdateCheckPost({
|
||||
current_version: version,
|
||||
})
|
||||
if (response.code === 200) {
|
||||
if (response.if_need_update) {
|
||||
updateData.value = response.update_info
|
||||
updateVisible.value = true
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
message.error(response.message || '获取更新失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取更新失败:', error)
|
||||
return '获取更新失败!'
|
||||
}
|
||||
}
|
||||
|
||||
// 确认回调
|
||||
const onUpdateConfirmed = () => {
|
||||
updateVisible.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchActivityData()
|
||||
fetchNoticeData()
|
||||
checkUpdate()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -549,11 +510,6 @@ onMounted(() => {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
/* 公告相关样式 */
|
||||
.notice-modal {
|
||||
/* 自定义公告模态框样式 */
|
||||
}
|
||||
|
||||
.activity-card {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
@@ -221,6 +221,7 @@ const checkUpdate = async () => {
|
||||
try {
|
||||
const response = await Service.checkUpdateApiUpdateCheckPost({
|
||||
current_version: version,
|
||||
if_force: true, // 手动检查强制获取最新信息
|
||||
})
|
||||
if (response.code === 200) {
|
||||
if (response.if_need_update) {
|
||||
@@ -234,7 +235,7 @@ const checkUpdate = async () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取更新失败:', error)
|
||||
return '获取更新失败!'
|
||||
message.error('获取更新失败!')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user