@@ -27,6 +27,7 @@ import { useToast } from 'primevue/usetoast'
2727import * as vue from ' vue'
2828import * as vueusecore from ' @vueuse/core'
2929
30+ import { SHORT_DELAY , TOAST_LIFE } from ' ../../constants'
3031import { electronAPI } from ' ../../electronAPI'
3132import * as locAPI from ' ../../libopencor/locAPI'
3233
@@ -51,9 +52,6 @@ function handleAction(action: string): void {
5152 const actionName = index !== - 1 ? action .substring (0 , index ) : action
5253 const actionArguments = index !== - 1 ? action .substring (index + 1 ) : ' '
5354
54- console .log (` actionName: >${actionName }< ` )
55- console .log (` actionArguments: >${actionArguments }< ` )
56-
5755 if (isAction (actionName , ' openAboutDialog' )) {
5856 onAbout ()
5957 } else if (isAction (actionName , ' openSettingsDialog' )) {
@@ -68,6 +66,13 @@ function handleAction(action: string): void {
6866 for (const filePath of filePaths ) {
6967 openFile (filePath )
7068 }
69+ } else {
70+ toast .add ({
71+ severity: ' error' ,
72+ summary: ' Handling an action' ,
73+ detail: action + ' \n\n The action could not be handled.' ,
74+ life: TOAST_LIFE
75+ })
7176 }
7277 }
7378}
@@ -115,7 +120,7 @@ electronAPI?.onCheckForUpdates(() => {
115120 severity: ' info' ,
116121 summary: ' Check for updates' ,
117122 detail: ' The Check for updates dialog has yet to be implemented.' ,
118- life: common . toastLife
123+ life: TOAST_LIFE
119124 })
120125})
121126
@@ -142,7 +147,7 @@ function onSettings(): void {
142147 severity: ' info' ,
143148 summary: ' Settings' ,
144149 detail: ' The Settings dialog has yet to be implemented.' ,
145- life: common . toastLife
150+ life: TOAST_LIFE
146151 })
147152}
148153
@@ -180,7 +185,7 @@ function openFile(fileOrFilePath: string | File): void {
180185 (fileType === locAPI .FileType .UnknownFile
181186 ? ' Only CellML files, SED-ML files, and COMBINE archives are supported.'
182187 : ' The file could not be retrieved.' ),
183- life: common . toastLife
188+ life: TOAST_LIFE
184189 })
185190 } else {
186191 contentsRef .value ?.addFile (file )
@@ -199,7 +204,7 @@ function openFile(fileOrFilePath: string | File): void {
199204 severity: ' error' ,
200205 summary: ' Opening a file' ,
201206 detail: filePath + ' \n\n ' + (error instanceof Error ? error .message : String (error )),
202- life: common . toastLife
207+ life: TOAST_LIFE
203208 })
204209 })
205210}
@@ -277,37 +282,28 @@ function onResetAll(): void {
277282
278283// Things that need to be done when the component is mounted.
279284
280- const url = vueusecore .useStorage (' url ' , ' ' )
285+ const action = vueusecore .useStorage (' action ' , ' ' )
281286
282287vue .onMounted (() => {
283- // Check whether the URL contains an OpenCOR action, but with a bit of a delay to ensure that our background (with the
284- // OpenCOR logo) is properly rendered .
288+ // Handle the action, if any. We handle the action with a bit of a delay to give our background (with the OpenCOR
289+ // logo) time to be renderered .
285290 // Note: to use vue.nextTick() doesn't do the trick, so we have no choice but to use setTimeout().
286291
287292 setTimeout (() => {
288- console .log (` window.location.pathname: >${window .location .pathname }< ` )
289-
290293 if (electronAPI === undefined ) {
291- console .log (` window.location.pathname: >${window .location .pathname }< ` )
292-
293- console .log (' window.location.pathname starts with https://' )
294- if (window .location .pathname !== ' /' ) {
295- console .log (` window.location.pathname: >${window .location .pathname }< ` )
296- console .log (' OLD url:' , url .value )
297- url .value = window .location .pathname
298- console .log (' NEW url:' , url .value )
299-
300- window .location .pathname = ' /'
301- } else {
302- console .log (` window.location.pathname: >${window .location .pathname }< ` )
303- console .log (' CRT url:' , url .value .substring (1 ))
294+ if (window .location .search !== ' ' ) {
295+ action .value = window .location .search .substring (1 )
304296
305- handleAction (url .value .substring (1 ))
297+ window .location .search = ' '
298+ } else if (action .value !== ' ' ) {
299+ setTimeout (() => {
300+ handleAction (action .value )
306301
307- url .value = ' '
302+ action .value = ' '
303+ }, SHORT_DELAY )
308304 }
309305 }
310- }, 0 )
306+ }, SHORT_DELAY )
311307})
312308 </script >
313309
0 commit comments