v0
This commit is contained in:
43
frontend/src/views/Dashboard.vue
Normal file
43
frontend/src/views/Dashboard.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Dashboard</h2>
|
||||
<button @click="logout">Logout</button>
|
||||
<h3>Users</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>ID</th><th>Login</th><th>Created</th><th>IP</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in users" :key="user.id">
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.login }}</td>
|
||||
<td>{{ user.created }}</td>
|
||||
<td>{{ user.ip }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import axios from 'axios'
|
||||
|
||||
const router = useRouter()
|
||||
const users = ref([])
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await axios.get('/api/admin/users')
|
||||
users.value = res.data
|
||||
} catch {
|
||||
router.push('/login')
|
||||
}
|
||||
})
|
||||
|
||||
async function logout() {
|
||||
await axios.post('/api/logout')
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user