feat:實作 Admin Panel — 平台管理後台

後端:
- AdminStatsController:總會員/教練/課程數統計 API
- AdminUserController:會員與教練列表、詳情、啟用/停用、教練驗證(toggle 反轉語意)
- AdminOfferController:全平台課程列表與刪除
- routes/api.php:新增 /api/admin/stats、members、providers、offers 等路由

前端(frontend/):
- adminAuth store、adminAxios(第三套獨立認證)
- /admin/* 路由群組 + requiresAdmin guard
- AdminNavBar、AdminLayout
- App.vue:isCoachPage → isBackofficePage(/coach/* 和 /admin/* 皆隱藏會員 NavBar)
- LoginView、DashboardView(統計卡片)
- MembersView、ProvidersView(含驗證操作)、OffersView(含刪除確認)

OpenSpec:
- 新增 specs:admin-auth / admin-user-management / admin-offer-management / admin-stats / admin-panel-ui
- 歸檔:openspec/changes/archive/2026-05-10-admin-panel

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 04:07:13 +08:00
parent 3827223be3
commit 24145419b0
29 changed files with 1439 additions and 10 deletions
+21 -7
View File
@@ -1,6 +1,7 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { useCoachAuthStore } from '../stores/coachAuth'
import { useAdminAuthStore } from '../stores/adminAuth'
const routes = [
// Member
@@ -15,7 +16,7 @@ const routes = [
// Coach (public)
{ path: '/coach/login', component: () => import('../views/coach/LoginView.vue') },
{ path: '/coach/register', component: () => import('../views/coach/RegisterView.vue') },
// Coach (protected) — wrapped in CoachLayout
// Coach (protected)
{
path: '/coach',
component: () => import('../layouts/CoachLayout.vue'),
@@ -27,6 +28,21 @@ const routes = [
{ path: 'profile', component: () => import('../views/coach/ProfileView.vue') },
],
},
// Admin (public)
{ path: '/admin/login', component: () => import('../views/admin/LoginView.vue') },
// Admin (protected)
{
path: '/admin',
component: () => import('../layouts/AdminLayout.vue'),
meta: { requiresAdmin: true },
children: [
{ path: 'dashboard', component: () => import('../views/admin/DashboardView.vue') },
{ path: 'members', component: () => import('../views/admin/MembersView.vue') },
{ path: 'providers', component: () => import('../views/admin/ProvidersView.vue') },
{ path: 'offers', component: () => import('../views/admin/OffersView.vue') },
],
},
]
const router = createRouter({
@@ -37,13 +53,11 @@ const router = createRouter({
router.beforeEach((to) => {
const auth = useAuthStore()
const coachAuth = useCoachAuthStore()
const adminAuth = useAdminAuthStore()
if (to.meta.requiresAuth && !auth.isLoggedIn) {
return { path: '/login' }
}
if (to.meta.requiresCoach && !coachAuth.isLoggedIn) {
return { path: '/coach/login' }
}
if (to.meta.requiresAuth && !auth.isLoggedIn) return { path: '/login' }
if (to.meta.requiresCoach && !coachAuth.isLoggedIn) return { path: '/coach/login' }
if (to.meta.requiresAdmin && !adminAuth.isLoggedIn) return { path: '/admin/login' }
})
export default router