|
|
|
@ -110,43 +110,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 排行榜管理 -->
|
|
|
|
|
<div v-if="activeTab === 'leaderboard'" class="tab-content">
|
|
|
|
|
<h2>排行榜管理</h2>
|
|
|
|
|
<div class="leaderboard-actions">
|
|
|
|
|
<button @click="confirmResetAllScores" class="danger-btn">
|
|
|
|
|
重置所有分数
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="table-wrapper">
|
|
|
|
|
<table class="leaderboard-table">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>排名</th>
|
|
|
|
|
<th>用户名</th>
|
|
|
|
|
<th>最高分</th>
|
|
|
|
|
<th>最后游戏</th>
|
|
|
|
|
<th>操作</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr v-for="(user, index) in leaderboard" :key="user.id">
|
|
|
|
|
<td>{{ index + 1 }}</td>
|
|
|
|
|
<td>{{ user.username }}</td>
|
|
|
|
|
<td>{{ user.high_score }}</td>
|
|
|
|
|
<td>{{ formatDate(user.last_login) }}</td>
|
|
|
|
|
<td class="actions">
|
|
|
|
|
<button @click="editUser(user)" class="edit-btn">编辑</button>
|
|
|
|
|
<button @click="resetUserScore(user.id)" class="reset-btn">
|
|
|
|
|
重置分数
|
|
|
|
|
</button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 排行榜管理已移除 -->
|
|
|
|
|
|
|
|
|
|
<!-- 游戏历史管理 -->
|
|
|
|
|
<div v-if="activeTab === 'history'" class="tab-content">
|
|
|
|
@ -222,7 +186,6 @@ export default {
|
|
|
|
|
activeTab: 'users',
|
|
|
|
|
tabs: [
|
|
|
|
|
{ id: 'users', name: '用户管理' },
|
|
|
|
|
{ id: 'leaderboard', name: '排行榜管理' },
|
|
|
|
|
{ id: 'history', name: '游戏历史' }
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
@ -231,8 +194,6 @@ export default {
|
|
|
|
|
filteredUsers: [],
|
|
|
|
|
userSearchTerm: '',
|
|
|
|
|
|
|
|
|
|
// 排行榜相关
|
|
|
|
|
leaderboard: [],
|
|
|
|
|
|
|
|
|
|
// 游戏历史相关
|
|
|
|
|
gameHistory: [],
|
|
|
|
@ -329,7 +290,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
this.loadUsers(),
|
|
|
|
|
this.loadLeaderboard(),
|
|
|
|
|
this.loadGameHistory()
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
@ -360,37 +320,8 @@ export default {
|
|
|
|
|
this.loadUsers()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 排行榜管理
|
|
|
|
|
async loadLeaderboard() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get('/api/leaderboard')
|
|
|
|
|
this.leaderboard = response.data.leaderboard
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('加载排行榜失败:', error)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async confirmResetAllScores() {
|
|
|
|
|
this.showConfirmDialog = true
|
|
|
|
|
this.confirmDialogTitle = '重置所有分数'
|
|
|
|
|
this.confirmDialogMessage = '确定要重置所有用户的分数吗?此操作不可撤销!'
|
|
|
|
|
this.confirmDialogAction = this.resetAllScores
|
|
|
|
|
},
|
|
|
|
|
async resetAllScores() {
|
|
|
|
|
try {
|
|
|
|
|
await axios.post('/api/admin/leaderboard/reset')
|
|
|
|
|
this.showConfirmDialog = false
|
|
|
|
|
|
|
|
|
|
// 重新加载数据
|
|
|
|
|
await this.loadUsers()
|
|
|
|
|
await this.loadLeaderboard()
|
|
|
|
|
await this.loadGameHistory()
|
|
|
|
|
|
|
|
|
|
alert('所有分数已重置')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('重置分数失败:', error)
|
|
|
|
|
alert('重置分数失败: ' + (error.response?.data?.error || '未知错误'))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 排行榜管理相关功能已移除
|
|
|
|
|
|
|
|
|
|
async resetUserScore(userId) {
|
|
|
|
|
this.showConfirmDialog = true
|
|
|
|
|
this.confirmDialogTitle = '重置用户分数'
|
|
|
|
@ -402,7 +333,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 重新加载数据
|
|
|
|
|
await this.loadUsers()
|
|
|
|
|
await this.loadLeaderboard()
|
|
|
|
|
await this.loadGameHistory()
|
|
|
|
|
|
|
|
|
|
alert('用户分数已重置')
|
|
|
|
@ -483,7 +413,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 重新加载数据
|
|
|
|
|
await this.loadUsers()
|
|
|
|
|
await this.loadLeaderboard()
|
|
|
|
|
|
|
|
|
|
// 如果修改的是当前用户,更新localStorage信息
|
|
|
|
|
const userData = JSON.parse(localStorage.getItem('user'))
|
|
|
|
@ -544,7 +473,6 @@ export default {
|
|
|
|
|
|
|
|
|
|
// 重新加载数据
|
|
|
|
|
await this.loadUsers()
|
|
|
|
|
await this.loadLeaderboard()
|
|
|
|
|
await this.loadGameHistory()
|
|
|
|
|
|
|
|
|
|
alert('用户已删除')
|
|
|
|
|