diff --git a/frontend/src/store/pendingUpload.js b/frontend/src/store/pendingUpload.js index cf8602de..54934002 100644 --- a/frontend/src/store/pendingUpload.js +++ b/frontend/src/store/pendingUpload.js @@ -1,15 +1,16 @@ /** - * 临时存储待上传的文件和需求 - * 用于首页点击启动引擎后立即跳转,在Process页面再进行API调用 + * Temporary storage for files and simulation requirement. + * - simulationRequirement: persisted to sessionStorage (survives refresh within the tab) + * - files: in-memory only (File objects are not JSON-serializable) */ import { reactive } from 'vue' const state = reactive({ files: [], - simulationRequirement: '', - isPending: false, + simulationRequirement: sessionStorage.getItem('pendingRequirement') || '', + isPending: sessionStorage.getItem('pendingIsPending') === 'true', importOntologyMode: false, - ontologyFile: null + ontologyFile: null, }) export function setPendingUpload(files, requirement, importOntologyMode = false, ontologyFile = null) { @@ -18,6 +19,8 @@ export function setPendingUpload(files, requirement, importOntologyMode = false, state.isPending = true state.importOntologyMode = importOntologyMode state.ontologyFile = ontologyFile + sessionStorage.setItem('pendingRequirement', requirement) + sessionStorage.setItem('pendingIsPending', 'true') } export function getPendingUpload() { @@ -26,7 +29,7 @@ export function getPendingUpload() { simulationRequirement: state.simulationRequirement, isPending: state.isPending, importOntologyMode: state.importOntologyMode, - ontologyFile: state.ontologyFile + ontologyFile: state.ontologyFile, } } @@ -36,6 +39,8 @@ export function clearPendingUpload() { state.isPending = false state.importOntologyMode = false state.ontologyFile = null + sessionStorage.removeItem('pendingRequirement') + sessionStorage.removeItem('pendingIsPending') } export default state diff --git a/frontend/src/views/MainView.vue b/frontend/src/views/MainView.vue index 8681f899..2781d36b 100644 --- a/frontend/src/views/MainView.vue +++ b/frontend/src/views/MainView.vue @@ -197,9 +197,16 @@ const initProject = async () => { const handleNewProject = async () => { const pending = getPendingUpload() - if (!pending.isPending || pending.files.length === 0) { - error.value = 'No pending files found.' - addLog('Error: No pending files found for new project.') + + if (!pending.isPending) { + return // not a new-project session + } + + if (pending.files.length === 0) { + error.value = t('error.filesLostAfterRefresh') + addLog(t('error.filesLostAfterRefresh')) + clearPendingUpload() + setTimeout(() => router.push('/'), 3000) return } diff --git a/locales/ca.json b/locales/ca.json index e963bfb0..0169a508 100644 --- a/locales/ca.json +++ b/locales/ca.json @@ -706,5 +706,8 @@ "submit": "Entrar", "loading": "Autenticant...", "invalidCredentials": "Usuari o contrasenya incorrectes" + }, + "error": { + "filesLostAfterRefresh": "Els fitxers s'han perdut en refrescar la pàgina. Redirigint a l'inici per tornar a seleccionar-los…" } } \ No newline at end of file diff --git a/locales/en.json b/locales/en.json index 3b18b8ea..0fe2671d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -707,5 +707,8 @@ "submit": "Enter", "loading": "Authenticating...", "invalidCredentials": "Invalid username or password" + }, + "error": { + "filesLostAfterRefresh": "Files were lost after page refresh. Redirecting to home to re-select files…" } } \ No newline at end of file diff --git a/locales/es.json b/locales/es.json index fd93b409..5d2d312b 100644 --- a/locales/es.json +++ b/locales/es.json @@ -706,5 +706,8 @@ "submit": "Entrar", "loading": "Autenticando...", "invalidCredentials": "Usuario o contraseña incorrectos" + }, + "error": { + "filesLostAfterRefresh": "Los archivos se perdieron al refrescar la página. Redirigiendo al inicio para volver a seleccionarlos…" } } \ No newline at end of file diff --git a/locales/zh.json b/locales/zh.json index 32650e66..ed473c4a 100644 --- a/locales/zh.json +++ b/locales/zh.json @@ -707,5 +707,8 @@ "submit": "登录", "loading": "验证中...", "invalidCredentials": "用户名或密码错误" + }, + "error": { + "filesLostAfterRefresh": "刷新页面后文件丢失,正在跳转到首页重新选择文件…" } } \ No newline at end of file