v1.5更新
事务大厅以此为准;
This commit is contained in:
@@ -11,7 +11,7 @@ export const getMaps = async (params = {}) => {
|
||||
search: params.search || '',
|
||||
player_count: params.player_count || '',
|
||||
tags: params.tags || '',
|
||||
ordering: params.ordering || '-download_count'
|
||||
ordering: params.ordering || ''
|
||||
}
|
||||
})
|
||||
return response.data
|
||||
@@ -22,18 +22,18 @@ export const getMaps = async (params = {}) => {
|
||||
}
|
||||
|
||||
// 获取每周推荐地图
|
||||
export const getWeeklyTopMaps = async () => {
|
||||
export const getWeeklyTopMaps = async (params = {}) => {
|
||||
try {
|
||||
const response = await axios.get('https://ra3.z31.xyz/v1/maps/', {
|
||||
const response = await axios.get(`${API_BASE_URL}/maps/`, {
|
||||
params: {
|
||||
ordering: '-download_count',
|
||||
p: params.page || 1,
|
||||
format: 'json',
|
||||
p: 1
|
||||
ordering: params.ordering || ''
|
||||
}
|
||||
})
|
||||
return response.data.results.slice(0, 10)
|
||||
return response.data.results
|
||||
} catch (error) {
|
||||
console.error('获取每周推荐地图失败:', error)
|
||||
console.error('获取地图列表失败:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ const fetchDemands = async () => {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await fetch('/api/demands/getlist', {
|
||||
const response = await fetch('http://zybdatasupport.online:8000/demands/getlist', {
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
@@ -235,7 +235,7 @@ async function submitAddForm() {
|
||||
date: dateStr,
|
||||
qq_code: addForm.value.qq_code
|
||||
};
|
||||
const response = await fetch('/api/demands/add', {
|
||||
const response = await fetch('http://zybdatasupport.online:8000/demands/add', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<template>
|
||||
<div class="maps">
|
||||
<div class="page-header">
|
||||
<h1>最近上传地图</h1>
|
||||
<h1>最近地图上传</h1>
|
||||
</div>
|
||||
<div class="filters">
|
||||
搜索:
|
||||
<div class="search-box">
|
||||
<input
|
||||
type="text"
|
||||
@@ -13,14 +14,17 @@
|
||||
@blur="handleSearchBlur"
|
||||
>
|
||||
</div>
|
||||
玩家数:
|
||||
<select v-model="playerCountFilter" class="filter-select" @change="handleFilterChange">
|
||||
<option value="">玩家数</option>
|
||||
<option value="">全部</option>
|
||||
<option v-for="n in [2,3,4,5,6,7,8]" :key="n" :value="n">{{ n }}人</option>
|
||||
</select>
|
||||
分类:
|
||||
<select v-model="tagFilter" class="filter-select" @change="handleFilterChange">
|
||||
<option value="">分类</option>
|
||||
<option value="">全部</option>
|
||||
<option v-for="tag in tagOptions" :key="tag" :value="tag">{{ tag }}</option>
|
||||
</select>
|
||||
排序:
|
||||
<select v-model="selectedOrder" class="filter-select" @change="handleFilterChange">
|
||||
<option v-for="opt in orderOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</select>
|
||||
@@ -123,14 +127,14 @@ const jumpPage = ref('')
|
||||
|
||||
// 排序和筛选相关
|
||||
const orderOptions = [
|
||||
{ label: '创建时间降序', value: '-create_time' },
|
||||
{ label: '创建时间降序', value: ' -create_time' },
|
||||
{ label: '创建时间升序', value: 'create_time' },
|
||||
{ label: '下载量降序', value: '-download_count' },
|
||||
{ label: '下载量降序', value: ' -download_count' },
|
||||
{ label: '下载量升序', value: 'download_count' },
|
||||
{ label: '收藏数降序', value: '-favourite_count' },
|
||||
{ label: '收藏数降序', value: ' -favourite_count' },
|
||||
{ label: '收藏数升序', value: 'favourite_count' }
|
||||
]
|
||||
const selectedOrder = ref('-create_time')
|
||||
const selectedOrder = ref(' -create_time')
|
||||
const searchValue = ref('')
|
||||
const playerCountFilter = ref('')
|
||||
const tagFilter = ref('')
|
||||
@@ -170,39 +174,8 @@ const fetchMaps = async (page = 1) => {
|
||||
ordering: selectedOrder.value
|
||||
}
|
||||
const data = await getMaps(params)
|
||||
|
||||
// 只在创建时间排序时进行日期分组和下载量排序
|
||||
if (selectedOrder.value === '-create_time' || selectedOrder.value === 'create_time') {
|
||||
// 按日期分组并排序
|
||||
const groupedMaps = data.results.reduce((groups, map) => {
|
||||
const date = new Date(map.create_time).toLocaleDateString('zh-CN')
|
||||
if (!groups[date]) {
|
||||
groups[date] = []
|
||||
}
|
||||
groups[date].push(map)
|
||||
return groups
|
||||
}, {})
|
||||
|
||||
// 对每个日期组内的地图按下载量降序排序
|
||||
Object.keys(groupedMaps).forEach(date => {
|
||||
groupedMaps[date].sort((a, b) => b.download_count - a.download_count)
|
||||
})
|
||||
|
||||
// 获取所有日期并排序
|
||||
const sortedDates = Object.keys(groupedMaps).sort((a, b) => {
|
||||
return selectedOrder.value === '-create_time'
|
||||
? new Date(b) - new Date(a) // 降序
|
||||
: new Date(a) - new Date(b) // 升序
|
||||
})
|
||||
|
||||
// 按日期顺序拼接所有地图
|
||||
maps.value = sortedDates.reduce((acc, date) => {
|
||||
return acc.concat(groupedMaps[date])
|
||||
}, [])
|
||||
} else {
|
||||
maps.value = data.results
|
||||
}
|
||||
|
||||
maps.value = data.results
|
||||
hasNextPage.value = !!data.next
|
||||
totalPages.value = Math.ceil(data.count / 20)
|
||||
currentPage.value = page
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<template>
|
||||
<div class="weekly-recommend">
|
||||
<div class="page-header">
|
||||
<h1>热门下载地图</h1>
|
||||
<h1>每周热门下载地图</h1>
|
||||
<div class="header-subtitle">
|
||||
<span class="date-range">{{ currentWeekRange }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<table class="maps-table">
|
||||
<thead>
|
||||
@@ -43,6 +42,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -58,10 +58,10 @@ const recommendedMaps = ref([])
|
||||
|
||||
// 获取当前周的范围
|
||||
const currentWeekRange = computed(() => {
|
||||
const now = new Date()
|
||||
const start = new Date(now.setDate(now.getDate() - now.getDay()))
|
||||
const end = new Date(now.setDate(now.getDate() - now.getDay() + 6))
|
||||
return `${start.toLocaleDateString('zh-CN')} - ${end.toLocaleDateString('zh-CN')}`
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
start.setDate(start.getDate() - 6) // 往前推6天,这样加上今天就是7天
|
||||
return `${start.toLocaleDateString('zh-CN')} - 今天 ${end.toLocaleDateString('zh-CN')}`
|
||||
})
|
||||
|
||||
const goToMapDetail = (id) => {
|
||||
@@ -74,7 +74,42 @@ const formatDate = (dateString) => {
|
||||
|
||||
const fetchRecommendedMaps = async () => {
|
||||
try {
|
||||
recommendedMaps.value = await getWeeklyTopMaps()
|
||||
const maps = await getWeeklyTopMaps()
|
||||
|
||||
// 计算7天前的日期
|
||||
const sevenDaysAgo = new Date()
|
||||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6) // 往前推6天,加上今天就是7天
|
||||
|
||||
// 过滤出最近7天的地图
|
||||
const recentMaps = maps.filter(map => {
|
||||
const mapDate = new Date(map.create_time)
|
||||
return mapDate >= sevenDaysAgo
|
||||
})
|
||||
|
||||
// 按日期分组
|
||||
const groupedMaps = recentMaps.reduce((groups, map) => {
|
||||
const date = new Date(map.create_time).toLocaleDateString('zh-CN')
|
||||
if (!groups[date]) {
|
||||
groups[date] = []
|
||||
}
|
||||
groups[date].push(map)
|
||||
return groups
|
||||
}, {})
|
||||
|
||||
// 对每个日期组内的地图按下载量降序排序
|
||||
Object.keys(groupedMaps).forEach(date => {
|
||||
groupedMaps[date].sort((a, b) => b.download_count - a.download_count)
|
||||
})
|
||||
|
||||
// 获取所有日期并按降序排序
|
||||
const sortedDates = Object.keys(groupedMaps).sort((a, b) =>
|
||||
new Date(b) - new Date(a)
|
||||
)
|
||||
|
||||
// 按日期顺序拼接所有地图
|
||||
recommendedMaps.value = sortedDates.reduce((acc, date) => {
|
||||
return acc.concat(groupedMaps[date])
|
||||
}, [])
|
||||
} catch (error) {
|
||||
console.error('获取推荐地图失败:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user