@@ -7,11 +7,12 @@ import { ArrowTowerHeader } from '@/components/maps/ArrowTowerHeader';
77import { AdminTable } from '@/components/admin/AdminTable' ;
88import { AdminModal } from '@/components/admin/AdminModal' ;
99import { ChainStats } from '@/components/admin/ChainStats' ;
10+ import { QRBulkGenerator } from '@/components/admin/QRBulkGenerator' ;
1011import { Card } from '@/components/ui/card' ;
1112import { Button } from '@/components/ui/button' ;
1213import { Badge } from '@/components/ui/badge' ;
1314
14- type TabType = 'chain' | 'users' | 'routes' | 'pois' | 'checkins' | 'vouchers' ;
15+ type TabType = 'chain' | 'users' | 'routes' | 'pois' | 'checkins' | 'vouchers' | 'qr_bulk' ;
1516
1617interface User {
1718 id : string ;
@@ -99,14 +100,15 @@ export default function AdminDashboard() {
99100
100101 // 加载数据
101102 const fetchData = async ( type : TabType ) => {
102- if ( type === 'chain' ) return ; // 链上数据由组件自己处理
103+ if ( type === 'chain' || type === 'qr_bulk' ) return ; // 这些标签页有自己的数据处理逻辑
103104
104105 setLoading ( true ) ;
105106 setError ( null ) ;
106107
107108 try {
108109 const endpoints : Record < TabType , string > = {
109110 chain : '' ,
111+ qr_bulk : '' ,
110112 users : '/api/admin/users' ,
111113 routes : '/api/admin/routes' ,
112114 pois : '/api/admin/pois' ,
@@ -158,6 +160,7 @@ export default function AdminDashboard() {
158160
159161 const defaults : Record < TabType , any > = {
160162 chain : { } ,
163+ qr_bulk : { } ,
161164 users : {
162165 id : crypto . randomUUID ( ) ,
163166 walletAddress : '' ,
@@ -202,11 +205,12 @@ export default function AdminDashboard() {
202205
203206 // 删除
204207 const handleDelete = async ( item : any ) => {
205- if ( ! confirm ( '确定要删除吗? 此操作不可恢复! ' ) ) return ;
208+ if ( ! confirm ( '确定要删除吗? 此操作不可恢复! ' ) ) return ;
206209
207210 try {
208211 const endpoints : Record < TabType , string > = {
209212 chain : '' ,
213+ qr_bulk : '' ,
210214 users : `/api/admin/users/${ item . id } ` ,
211215 routes : `/api/admin/routes/${ item . id } ` ,
212216 pois : `/api/admin/pois/${ item . id } ` ,
@@ -235,6 +239,7 @@ export default function AdminDashboard() {
235239 try {
236240 const endpoints : Record < TabType , string > = {
237241 chain : '' ,
242+ qr_bulk : '' ,
238243 users : modalType === 'create' ? '/api/admin/users' : `/api/admin/users/${ currentId } ` ,
239244 routes : modalType === 'create' ? '/api/admin/routes' : `/api/admin/routes/${ currentId } ` ,
240245 pois : modalType === 'create' ? '/api/admin/pois' : `/api/admin/pois/${ currentId } ` ,
@@ -269,6 +274,7 @@ export default function AdminDashboard() {
269274 const getModalFields = ( ) => {
270275 const fieldsMap : Record < TabType , any [ ] > = {
271276 chain : [ ] ,
277+ qr_bulk : [ ] ,
272278 users : [
273279 { name : 'id' , label : '用户ID' , type : 'text' , required : true , disabled : modalType === 'update' } ,
274280 { name : 'walletAddress' , label : '钱包地址' , type : 'text' , required : true , disabled : modalType === 'update' } ,
@@ -336,6 +342,7 @@ export default function AdminDashboard() {
336342 const getTableColumns = ( ) => {
337343 const columnsMap : Record < TabType , any [ ] > = {
338344 chain : [ ] ,
345+ qr_bulk : [ ] ,
339346 users : [
340347 { key : 'avatar' , label : '头像' , render : ( val : string ) => (
341348 < img src = { val || '/default-avatar.png' } alt = "avatar" className = "w-10 h-10 rounded-full border-2 border-emerald-200" />
@@ -423,6 +430,7 @@ export default function AdminDashboard() {
423430 { id : 'users' , label : '用户管理' , icon : '👥' } ,
424431 { id : 'routes' , label : '路线管理' , icon : '🗺️' } ,
425432 { id : 'pois' , label : '打卡点管理' , icon : '📍' } ,
433+ { id : 'qr_bulk' , label : '打卡点二维码' , icon : '🔳' } ,
426434 { id : 'checkins' , label : '打卡记录' , icon : '✅' } ,
427435 { id : 'vouchers' , label : 'NFT凭证' , icon : '🎨' }
428436 ] ;
@@ -456,8 +464,15 @@ export default function AdminDashboard() {
456464 { /* 内容区域 */ }
457465 { activeTab === 'chain' ? (
458466 < ChainStats />
467+ ) : activeTab === 'qr_bulk' ? (
468+ < QRBulkGenerator
469+ pois = { pois }
470+ loading = { loading }
471+ error = { error }
472+ onRefresh = { ( ) => fetchData ( 'pois' ) }
473+ />
459474 ) : (
460- < AdminTable
475+ < AdminTable < User | Route | POI | Checkin | Voucher >
461476 title = { tabs . find ( t => t . id === activeTab ) ?. label || '' }
462477 icon = { tabs . find ( t => t . id === activeTab ) ?. icon || '' }
463478 data = {
@@ -482,6 +497,7 @@ export default function AdminDashboard() {
482497 onDelete = { handleDelete }
483498 onRefresh = { ( ) => fetchData ( activeTab ) }
484499 addButtonText = "新增"
500+ showQRButton = { activeTab === 'pois' }
485501 />
486502 ) }
487503
0 commit comments