|
|
|
@ -1,21 +1,21 @@
@@ -1,21 +1,21 @@
|
|
|
|
|
<template> |
|
|
|
|
<Tooltip :infos="[t('archive.0')]" width="12rem"> |
|
|
|
|
<Tooltip :infos="[at('menu.0')]" width="12rem"> |
|
|
|
|
<img class="menu-img" :src="menu_icons.exportGame" @click="showMenu"> |
|
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
<Dialog :title="t('archive.0')" v-model="showArchive" top="4rem" left='8%' @close="state.curMenu = null"> |
|
|
|
|
<Dialog :title="at('menu.0')" v-model="showArchive" top="4rem" left='8%' @close="state.curMenu = null"> |
|
|
|
|
<div class="archive"> |
|
|
|
|
<span class="tip">* {{ t('archive.1') }}</span> |
|
|
|
|
<span class="tip">* {{ at('menu.1') }}</span> |
|
|
|
|
<textarea class="textarea" v-model="archive"></textarea> |
|
|
|
|
</div> |
|
|
|
|
<div class="footer"> |
|
|
|
|
<button class="button" @click="copyArchive(archive)">{{ t('copyArchive.0') }}</button> |
|
|
|
|
<button class="button" @click="pasteArchive">{{ t('pasteArchive.0') }}</button> |
|
|
|
|
<button class="button" @click="importArchive">{{ t('importArchive.0') }}</button> |
|
|
|
|
<button class="button" @click="copyArchive(archive)">{{ at('copy.0') }}</button> |
|
|
|
|
<button class="button" @click="pasteArchive">{{ at('paste.0') }}</button> |
|
|
|
|
<button class="button" @click="importArchive">{{ at('import.0') }}</button> |
|
|
|
|
</div> |
|
|
|
|
<div class="footer"> |
|
|
|
|
<button class="button" @click="uploadArchive">{{ t('uploadArchive') }}</button> |
|
|
|
|
<button class="button" @click="downArchive">{{ t('downArchive') }}</button> |
|
|
|
|
<button class="button" @click="uploadArchive">{{ at('upload') }}</button> |
|
|
|
|
<button class="button" @click="downArchive">{{ at('down') }}</button> |
|
|
|
|
</div> |
|
|
|
|
</Dialog> |
|
|
|
|
|
|
|
|
@ -27,10 +27,12 @@ import { computed, onMounted, ref, onBeforeUnmount } from "vue";
@@ -27,10 +27,12 @@ import { computed, onMounted, ref, onBeforeUnmount } from "vue";
|
|
|
|
|
import { useI18n } from "vue3-i18n"; |
|
|
|
|
import { Tooltip, Dialog } from "@/components" |
|
|
|
|
import { menu_icons } from "@/config"; |
|
|
|
|
import { getArchive, AES_CBC_ENCRYPT, AES_CBC_DECRYPT, checkImportArchive, saveArchive, replace, archive_version, MD5 } from "@/tool"; |
|
|
|
|
import { getArchive, AES_CBC_ENCRYPT, AES_CBC_DECRYPT, checkImportArchive, saveArchive, replace, archive_version, MD5, checkArchive } from "@/tool"; |
|
|
|
|
import * as API from "@/api"; |
|
|
|
|
import { createt } from "@/config/i18n"; |
|
|
|
|
|
|
|
|
|
const { t } = useI18n(); |
|
|
|
|
// const { t } = useI18n(); |
|
|
|
|
const at = createt('archive.'); |
|
|
|
|
const { state, commit, dispatch } = useStore(); |
|
|
|
|
const showArchive = computed(() => { |
|
|
|
|
return state.curMenu == 'archive'; |
|
|
|
@ -62,10 +64,10 @@ const showMenu = () => {
@@ -62,10 +64,10 @@ const showMenu = () => {
|
|
|
|
|
const copyArchive = (archive) => { |
|
|
|
|
if (navigator.clipboard && window.isSecureContext) { |
|
|
|
|
navigator.clipboard.writeText(archive).then(() => { |
|
|
|
|
commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' }) |
|
|
|
|
commit('set_sys_info', { msg: at('copy.1'), type: 'win' }) |
|
|
|
|
showMenu(); |
|
|
|
|
}).catch(() => { |
|
|
|
|
commit('set_sys_info', { msg: t('copyArchive.2'), type: 'waring' }) |
|
|
|
|
commit('set_sys_info', { msg: at('copy.2'), type: 'waring' }) |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const textField = document.createElement("textarea"); |
|
|
|
@ -74,7 +76,7 @@ const copyArchive = (archive) => {
@@ -74,7 +76,7 @@ const copyArchive = (archive) => {
|
|
|
|
|
textField.select(); |
|
|
|
|
document.execCommand("copy"); |
|
|
|
|
textField.remove(); |
|
|
|
|
commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' }) |
|
|
|
|
commit('set_sys_info', { msg: at('copy.1'), type: 'win' }) |
|
|
|
|
showMenu(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -112,10 +114,10 @@ const pasteArchive = () => {
@@ -112,10 +114,10 @@ const pasteArchive = () => {
|
|
|
|
|
if (result.state === 'granted') { |
|
|
|
|
navigator.clipboard.readText().then(text => { |
|
|
|
|
archive.value = text; |
|
|
|
|
commit('set_sys_info', { msg: t('pasteArchive.1'), type: 'win' }) |
|
|
|
|
commit('set_sys_info', { msg: at('paste.1'), type: 'win' }) |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
commit('set_sys_info', { msg: t('pasteArchive.2'), type: 'waring' }) |
|
|
|
|
commit('set_sys_info', { msg: at('paste.2'), type: 'waring' }) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -124,29 +126,40 @@ const importArchive = async () => {
@@ -124,29 +126,40 @@ const importArchive = async () => {
|
|
|
|
|
try { |
|
|
|
|
const data = JSON.parse(AES_CBC_DECRYPT(archive.value, key)); |
|
|
|
|
if (!data || data == 'undfind') { |
|
|
|
|
commit('set_sys_info', { msg: t('loadEmpty'), type: 'warning' }); |
|
|
|
|
commit('set_sys_info', { msg: at('empty'), type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
if (data.version != archive_version) { |
|
|
|
|
commit('set_sys_info', { msg: t('importArchive.3'), type: 'warning' }); |
|
|
|
|
commit('set_sys_info', { msg: at('import.3'), type: 'warning' }); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
await checkImportArchive(data); |
|
|
|
|
await dispatch('loadGame', data); |
|
|
|
|
if (state.experiential) { |
|
|
|
|
commit('set_sys_info', { msg: replace(t('experiential.0'), [data.experientialTime]), type: 'win' }); |
|
|
|
|
const time = data.experientialTime || 10; |
|
|
|
|
clearTimeout(timeOut); |
|
|
|
|
timeOut = setTimeout(() => { |
|
|
|
|
commit('set_sys_info', { msg: replace(t('experiential.2'), [data.experientialTime]), type: 'warning' }); |
|
|
|
|
dispatch('loadGame'); |
|
|
|
|
}, time * 60 * 100); |
|
|
|
|
} else { |
|
|
|
|
saveArchive(state); |
|
|
|
|
} |
|
|
|
|
showMenu(); |
|
|
|
|
const flag = data.flag || state.archiveFlag; |
|
|
|
|
console.log(flag); |
|
|
|
|
|
|
|
|
|
checkArchive(flag).then(async rsp => { |
|
|
|
|
if (!rsp) { |
|
|
|
|
commit('set_sys_info', { msg: at('check.0'), type: 'warning' }); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
await dispatch('loadGame', data); |
|
|
|
|
if (state.experiential) { |
|
|
|
|
commit('set_sys_info', { msg: replace(at('experiential.0'), [data.experientialTime]), type: 'win' }); |
|
|
|
|
const time = data.experientialTime || 10; |
|
|
|
|
clearTimeout(timeOut); |
|
|
|
|
timeOut = setTimeout(() => { |
|
|
|
|
commit('set_sys_info', { msg: replace(at('experiential.2'), [data.experientialTime]), type: 'warning' }); |
|
|
|
|
dispatch('loadGame'); |
|
|
|
|
}, time * 60 * 100); |
|
|
|
|
} else { |
|
|
|
|
saveArchive(state); |
|
|
|
|
} |
|
|
|
|
showMenu(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// await checkImportArchive(data); |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.log(error); |
|
|
|
|
commit('set_sys_info', { msg: t('loadError'), type: 'warning' }); |
|
|
|
|
commit('set_sys_info', { msg: at('error'), type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|