Enhance market module with new chat and events features
- Introduce chat module with components, services, and composables for real-time messaging. - Implement events module with API service, components, and ticket purchasing functionality. - Update app configuration to include new modules and their respective settings. - Refactor existing components to integrate with the new chat and events features. - Enhance market store and services to support new functionalities and improve order management. - Update routing to accommodate new views for chat and events, ensuring seamless navigation.
This commit is contained in:
parent
519a9003d4
commit
e40ac91417
46 changed files with 6305 additions and 3264 deletions
116
src/modules/events/index.ts
Normal file
116
src/modules/events/index.ts
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
import type { App } from 'vue'
|
||||
import type { ModulePlugin } from '@/core/types'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { container } from '@/core/di-container'
|
||||
import { eventBus } from '@/core/event-bus'
|
||||
|
||||
// Import components and services
|
||||
import PurchaseTicketDialog from './components/PurchaseTicketDialog.vue'
|
||||
import { EventsApiService, type EventsApiConfig } from './services/events-api'
|
||||
import { useEvents, EVENTS_API_TOKEN } from './composables/useEvents'
|
||||
|
||||
export interface EventsModuleConfig {
|
||||
apiConfig: EventsApiConfig
|
||||
ticketValidationEndpoint?: string
|
||||
maxTicketsPerUser?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Events Module Plugin
|
||||
* Provides event management and ticket purchasing functionality
|
||||
*/
|
||||
export const eventsModule: ModulePlugin = {
|
||||
name: 'events',
|
||||
version: '1.0.0',
|
||||
dependencies: ['base'],
|
||||
|
||||
async install(app: App, options?: { config?: EventsModuleConfig }) {
|
||||
console.log('🎫 Installing events module...')
|
||||
|
||||
const config = options?.config
|
||||
if (!config) {
|
||||
throw new Error('Events module requires configuration')
|
||||
}
|
||||
|
||||
// Create and register events API service
|
||||
const eventsApiService = new EventsApiService(config.apiConfig)
|
||||
container.provide(EVENTS_API_TOKEN, eventsApiService)
|
||||
|
||||
// Register global components
|
||||
app.component('PurchaseTicketDialog', PurchaseTicketDialog)
|
||||
|
||||
// Set up event listeners for integration with other modules
|
||||
setupEventListeners()
|
||||
|
||||
console.log('✅ Events module installed successfully')
|
||||
},
|
||||
|
||||
async uninstall() {
|
||||
console.log('🗑️ Uninstalling events module...')
|
||||
|
||||
// Clean up services
|
||||
container.remove(EVENTS_API_TOKEN)
|
||||
|
||||
console.log('✅ Events module uninstalled')
|
||||
},
|
||||
|
||||
routes: [
|
||||
{
|
||||
path: '/events',
|
||||
name: 'events',
|
||||
component: () => import('./views/EventsPage.vue'),
|
||||
meta: {
|
||||
title: 'Events',
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/my-tickets',
|
||||
name: 'my-tickets',
|
||||
component: () => import('./views/MyTicketsPage.vue'),
|
||||
meta: {
|
||||
title: 'My Tickets',
|
||||
requiresAuth: true
|
||||
}
|
||||
}
|
||||
] as RouteRecordRaw[],
|
||||
|
||||
components: {
|
||||
PurchaseTicketDialog
|
||||
},
|
||||
|
||||
composables: {
|
||||
useEvents
|
||||
},
|
||||
|
||||
services: {
|
||||
eventsApi: EVENTS_API_TOKEN
|
||||
}
|
||||
}
|
||||
|
||||
// Set up event listeners for integration with other modules
|
||||
function setupEventListeners() {
|
||||
// Listen for auth events
|
||||
eventBus.on('auth:logout', () => {
|
||||
// Clear any cached event data if needed
|
||||
console.log('Events module: user logged out, clearing cache')
|
||||
})
|
||||
|
||||
// Listen for payment events from other modules
|
||||
eventBus.on('payment:completed', (event) => {
|
||||
console.log('Events module: payment completed', event.data)
|
||||
// Could refresh events or ticket status here
|
||||
})
|
||||
|
||||
// Emit events for other modules
|
||||
eventBus.on('events:ticket-purchased', (event) => {
|
||||
console.log('Ticket purchased:', event.data)
|
||||
// Other modules can listen to this event
|
||||
})
|
||||
}
|
||||
|
||||
export default eventsModule
|
||||
|
||||
// Re-export types and composables for external use
|
||||
export type { Event, Ticket } from './types/event'
|
||||
export { useEvents } from './composables/useEvents'
|
||||
Loading…
Add table
Add a link
Reference in a new issue