feat: 初始化项目结构与核心功能

引入项目基础目录结构,包含多语言支持、主要页面与组件、核心游戏逻辑、UI 组件库、加密与本地持久化、自动化 Docker 构建流程、GitHub issue 模板(中英文)、README(中英文)、LICENSE 及开发配置文件。实现 OGame 单机版主要功能模块,为后续开发和扩展奠定基础。
This commit is contained in:
谦君
2025-12-11 14:49:25 +08:00
commit 705ee8c3db
178 changed files with 17258 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import { computed } from 'vue'
import { useGameStore } from '@/stores/gameStore'
import { locales, type Locale } from '@/locales'
export const useI18n = () => {
const gameStore = useGameStore()
const currentLocale = computed(() => gameStore.locale)
const messages = computed(() => locales[currentLocale.value])
// 获取翻译文本的辅助函数
const t = (key: string): string => {
const keys = key.split('.')
let value: any = messages.value
for (const k of keys) {
if (value && typeof value === 'object' && k in value) {
value = value[k]
} else {
return key // 如果找不到翻译,返回原始 key
}
}
return typeof value === 'string' ? value : key
}
const setLocale = (locale: Locale) => {
gameStore.locale = locale
}
return {
t,
locale: currentLocale,
setLocale,
messages
}
}