mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
feat: 新增多语言README并优化文档结构
新增德语、俄语、韩语、繁体中文多语言README,英文与简体中文README同步优化,统一下载链接与徽章样式,完善多语言入口。提升国际化支持与文档可读性。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Planet, DebrisField, NPC } from '@/types/game'
|
||||
import { decryptData, encryptData } from './crypto'
|
||||
import { generatePlanetTemperature } from '@/logic/planetLogic'
|
||||
import pkg from '../../package.json'
|
||||
|
||||
/**
|
||||
@@ -99,6 +100,41 @@ export const migrateGameData = (): void => {
|
||||
needsSave = true
|
||||
}
|
||||
|
||||
// 迁移温度数据:为没有温度的星球生成温度
|
||||
// 玩家星球
|
||||
if (oldData.player?.planets && Array.isArray(oldData.player.planets)) {
|
||||
oldData.player.planets.forEach((planet: Planet) => {
|
||||
// 月球不需要温度
|
||||
if (!planet.isMoon && !planet.temperature) {
|
||||
planet.temperature = generatePlanetTemperature(planet.position.position)
|
||||
needsSave = true
|
||||
}
|
||||
})
|
||||
if (needsSave) {
|
||||
console.log('[Migration] Added temperature to player planets')
|
||||
}
|
||||
}
|
||||
|
||||
// NPC星球
|
||||
if (oldData.npcs && Array.isArray(oldData.npcs)) {
|
||||
let npcPlanetMigrated = false
|
||||
oldData.npcs.forEach((npc: NPC) => {
|
||||
if (npc.planets && Array.isArray(npc.planets)) {
|
||||
npc.planets.forEach((planet: Planet) => {
|
||||
// 月球不需要温度
|
||||
if (!planet.isMoon && !planet.temperature) {
|
||||
planet.temperature = generatePlanetTemperature(planet.position.position)
|
||||
needsSave = true
|
||||
npcPlanetMigrated = true
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
if (npcPlanetMigrated) {
|
||||
console.log('[Migration] Added temperature to NPC planets')
|
||||
}
|
||||
}
|
||||
|
||||
// 迁移 player.diplomaticRelations 到 npc.relations
|
||||
// 旧版本使用 player.diplomaticRelations[npcId] 存储玩家对NPC的关系
|
||||
// 新版本统一使用 npc.relations[playerId] 存储NPC对玩家的关系
|
||||
@@ -160,6 +196,10 @@ export const migrateGameData = (): void => {
|
||||
Object.entries(oldPlanets).forEach(([key, planet]) => {
|
||||
// 只迁移非玩家星球
|
||||
if (!playerPlanetIds.has(planet.id)) {
|
||||
// 为没有温度的星球生成温度
|
||||
if (!planet.isMoon && !planet.temperature) {
|
||||
planet.temperature = generatePlanetTemperature(planet.position.position)
|
||||
}
|
||||
universeData.planets[key] = planet
|
||||
}
|
||||
})
|
||||
@@ -178,6 +218,36 @@ export const migrateGameData = (): void => {
|
||||
localStorage.setItem(universeStorageKey, encryptData(universeData))
|
||||
}
|
||||
|
||||
// 检查并更新已存在的 universeStore 数据中的星球温度
|
||||
const existingUniverseData = localStorage.getItem(universeStorageKey)
|
||||
if (existingUniverseData) {
|
||||
try {
|
||||
let universeData: { planets: Record<string, Planet>; debrisFields: Record<string, DebrisField> }
|
||||
try {
|
||||
universeData = decryptData(existingUniverseData)
|
||||
} catch {
|
||||
universeData = JSON.parse(existingUniverseData)
|
||||
}
|
||||
|
||||
let universePlanetMigrated = false
|
||||
if (universeData.planets) {
|
||||
Object.values(universeData.planets).forEach((planet: Planet) => {
|
||||
if (!planet.isMoon && !planet.temperature) {
|
||||
planet.temperature = generatePlanetTemperature(planet.position.position)
|
||||
universePlanetMigrated = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (universePlanetMigrated) {
|
||||
localStorage.setItem(universeStorageKey, encryptData(universeData))
|
||||
console.log('[Migration] Added temperature to universe planets')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Migration] Failed to migrate universe planets temperature:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有任何数据被修改,保存gameStore数据
|
||||
if (needsSave) {
|
||||
localStorage.setItem(storageKey, encryptData(oldData))
|
||||
|
||||
@@ -9,10 +9,10 @@ export interface VersionInfo {
|
||||
// 检查GitHub最新版本
|
||||
export const checkLatestVersion = async (lastCheckTime: number, updateCheckTime: (time: number) => void): Promise<VersionInfo | null> => {
|
||||
const now = Date.now()
|
||||
const fiveMinutes = 5 * 60 * 1000 // 5分钟
|
||||
const oneHour = 60 * 60 * 1000 // 1小时
|
||||
|
||||
// 如果距离上次检查不到5分钟,跳过
|
||||
if (now - lastCheckTime < fiveMinutes) {
|
||||
// 如果距离上次检查不到1小时,跳过
|
||||
if (now - lastCheckTime < oneHour) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ export const checkLatestVersion = async (lastCheckTime: number, updateCheckTime:
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否可以进行版本检查(距离上次检查是否超过5分钟)
|
||||
// 检查是否可以进行版本检查(距离上次检查是否超过1小时)
|
||||
export const canCheckVersion = (lastCheckTime: number): boolean => {
|
||||
const now = Date.now()
|
||||
const fiveMinutes = 5 * 60 * 1000 // 5分钟
|
||||
return now - lastCheckTime >= fiveMinutes
|
||||
const oneHour = 60 * 60 * 1000 // 1小时
|
||||
return now - lastCheckTime >= oneHour
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user