feat: 添加了浏览器通知和页面内通知

暂包含建造完成和科研完成
This commit is contained in:
StarsEnd
2025-12-18 01:34:29 +08:00
parent 2e3ac1231f
commit e8590d54c7
10 changed files with 327 additions and 11 deletions

View File

@@ -122,7 +122,8 @@ export const createBuildQueueItem = (buildingType: BuildingType, targetLevel: nu
export const completeBuildQueue = (
planet: Planet,
now: number,
onPointsEarned?: (points: number, type: 'building' | 'ship' | 'defense', itemType: string, level?: number, quantity?: number) => void
onPointsEarned?: (points: number, type: 'building' | 'ship' | 'defense', itemType: string, level?: number, quantity?: number) => void,
onCompleted?: (type: 'building' | 'ship' | 'defense' | 'demolish', itemType: string, level?: number, quantity?: number) => void
): void => {
planet.buildQueue = planet.buildQueue.filter(item => {
if (now >= item.endTime) {
@@ -137,6 +138,10 @@ export const completeBuildQueue = (
const points = pointsLogic.calculateBuildingPoints(item.itemType as BuildingType, oldLevel, newLevel)
onPointsEarned(points, 'building', item.itemType, newLevel)
}
if (onCompleted) {
onCompleted('building', item.itemType, newLevel)
}
} else if (item.type === 'ship') {
const shipType = item.itemType as ShipType
const quantity = item.quantity || 0