mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 16:05:12 +08:00
feat: 添加了浏览器通知和页面内通知
暂包含建造完成和科研完成
This commit is contained in:
@@ -41,12 +41,31 @@ export const useGameStore = defineStore('game', {
|
||||
giftRejectedNotifications: [],
|
||||
points: 0,
|
||||
isGMEnabled: false, // 明确设置 GM 模式默认为 false
|
||||
lastVersionCheckTime: 0 // 最后一次检查版本的时间戳,默认为0
|
||||
lastVersionCheckTime: 0, // 最后一次检查版本的时间戳,默认为0
|
||||
notificationSettings: {
|
||||
browser: false,
|
||||
inApp: true,
|
||||
suppressInFocus: false,
|
||||
types: {
|
||||
construction: true,
|
||||
research: true
|
||||
}
|
||||
}
|
||||
} as Player,
|
||||
currentPlanetId: '',
|
||||
isDark: '',
|
||||
locale: 'zh-CN' as Locale
|
||||
}),
|
||||
actions: {
|
||||
async requestBrowserPermission(): Promise<boolean> {
|
||||
if (!('Notification' in window)) return false
|
||||
|
||||
if (Notification.permission === 'granted') return true
|
||||
|
||||
const permission = await Notification.requestPermission()
|
||||
return permission === 'granted'
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
currentPlanet(): Planet | undefined {
|
||||
return this.player.planets.find(p => p.id === this.currentPlanetId)
|
||||
|
||||
Reference in New Issue
Block a user