mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 07:55:11 +08:00
feat: 支持Android端导出到Documents并多语言提示
Android端数据导出改为直接保存至Documents目录,导出成功后弹出带路径的多语言提示。引入@capacitor/status-bar与@capawesome/capacitor-file-picker依赖,主入口设置原生状态栏颜色与样式。各语言包补充导出成功带路径提示文案。
This commit is contained in:
@@ -850,6 +850,7 @@ export default {
|
||||
export: 'Exportieren',
|
||||
exporting: 'Exportieren...',
|
||||
exportSuccess: 'Export erfolgreich',
|
||||
exportSuccessWithPath: 'Export erfolgreich, Datei gespeichert unter: {path}',
|
||||
exportFailed: 'Export fehlgeschlagen, bitte erneut versuchen',
|
||||
importData: 'Daten importieren',
|
||||
importDataDesc: 'Spielfortschritt aus JSON-Datei wiederherstellen',
|
||||
|
||||
@@ -886,6 +886,7 @@ export default {
|
||||
export: 'Export',
|
||||
exporting: 'Exporting...',
|
||||
exportSuccess: 'Export successful',
|
||||
exportSuccessWithPath: 'Export successful, file saved to: {path}',
|
||||
exportFailed: 'Export failed, please try again',
|
||||
importData: 'Import Data',
|
||||
importDataDesc: 'Restore game progress from JSON file',
|
||||
|
||||
@@ -844,6 +844,7 @@ export default {
|
||||
export: 'エクスポート',
|
||||
exporting: 'エクスポート中...',
|
||||
exportSuccess: 'エクスポート成功',
|
||||
exportSuccessWithPath: 'エクスポート成功、ファイルの保存先:{path}',
|
||||
exportFailed: 'エクスポートに失敗しました。もう一度お試しください',
|
||||
importData: 'データインポート',
|
||||
importDataDesc: 'JSONファイルからゲームの進行状況を復元',
|
||||
|
||||
@@ -845,6 +845,7 @@ export default {
|
||||
export: '내보내기',
|
||||
exporting: '내보내는 중...',
|
||||
exportSuccess: '내보내기 성공',
|
||||
exportSuccessWithPath: '내보내기 성공, 파일 저장 위치: {path}',
|
||||
exportFailed: '내보내기 실패, 다시 시도해주세요',
|
||||
importData: '데이터 가져오기',
|
||||
importDataDesc: 'JSON 파일에서 게임 진행 상황 복원',
|
||||
|
||||
@@ -851,6 +851,7 @@ export default {
|
||||
export: 'Экспорт',
|
||||
exporting: 'Экспорт...',
|
||||
exportSuccess: 'Экспорт успешен',
|
||||
exportSuccessWithPath: 'Экспорт успешен, файл сохранен в: {path}',
|
||||
exportFailed: 'Экспорт не удался, попробуйте еще раз',
|
||||
importData: 'Импорт данных',
|
||||
importDataDesc: 'Восстановить прогресс игры из JSON файла',
|
||||
|
||||
@@ -873,6 +873,7 @@ export default {
|
||||
export: '导出',
|
||||
exporting: '导出中...',
|
||||
exportSuccess: '导出成功',
|
||||
exportSuccessWithPath: '导出成功,文件已保存到:{path}',
|
||||
exportFailed: '导出失败,请重试',
|
||||
importData: '导入数据',
|
||||
importDataDesc: '从JSON文件恢复游戏进度',
|
||||
|
||||
@@ -846,6 +846,7 @@ export default {
|
||||
export: '匯出',
|
||||
exporting: '匯出中...',
|
||||
exportSuccess: '匯出成功',
|
||||
exportSuccessWithPath: '匯出成功,檔案已儲存到:{path}',
|
||||
exportFailed: '匯出失敗,請重試',
|
||||
importData: '匯入資料',
|
||||
importDataDesc: '從JSON檔案恢復遊戲進度',
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import { StatusBar, Style } from '@capacitor/status-bar'
|
||||
import './style.css'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
// Android 设置状态栏
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
StatusBar.setBackgroundColor({ color: '#1a1a2e' })
|
||||
StatusBar.setStyle({ style: Style.Dark })
|
||||
StatusBar.setOverlaysWebView({ overlay: false })
|
||||
}
|
||||
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
|
||||
|
||||
@@ -334,8 +334,7 @@
|
||||
import { saveAs } from 'file-saver'
|
||||
import { toast } from 'vue-sonner'
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem'
|
||||
import { Share } from '@capacitor/share'
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem'
|
||||
import pkg from '../../package.json'
|
||||
import { checkLatestVersion, canCheckVersion } from '@/utils/versionCheck'
|
||||
import type { VersionInfo } from '@/utils/versionCheck'
|
||||
@@ -527,20 +526,16 @@
|
||||
const fileName = `${pkg.name}-${new Date().toISOString().slice(0, 10)}-${Date.now()}.json`
|
||||
const jsonString = JSON.stringify(exportData, null, 2)
|
||||
|
||||
// Android 使用 Capacitor Filesystem + Share
|
||||
// Android 保存到 Documents 目录
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
// 写入文件到缓存目录
|
||||
const result = await Filesystem.writeFile({
|
||||
path: fileName,
|
||||
data: jsonString,
|
||||
directory: Directory.Cache
|
||||
})
|
||||
// 分享文件让用户选择保存位置
|
||||
await Share.share({
|
||||
title: t('settings.exportData'),
|
||||
url: result.uri,
|
||||
dialogTitle: t('settings.exportData')
|
||||
directory: Directory.Documents,
|
||||
encoding: Encoding.UTF8
|
||||
})
|
||||
toast.success(t('settings.exportSuccessWithPath', { path: result.uri }))
|
||||
return
|
||||
} else {
|
||||
// Web 使用 file-saver
|
||||
saveAs(new Blob([jsonString], { type: 'application/json' }), fileName)
|
||||
|
||||
Reference in New Issue
Block a user