detect browser refresh? reroute to entry point?
-
My app is an SPA. When a user refreshes the page after clicking around and winding up on a path other than the root , the resulting page is messed up. Is there a way to detect the refresh? For example, even the slide-out menu of my default layout is empty as the user’s credentials seem to be lost. I think it’s vuex losing its data. I’m considering compiling to Electron so there isn’t a refresh button, but in an organization of 50,000 employees, it’s easier for me to publish a web app rather than deploy an exe.
-
@rconstantine I can think of at least three ways to cope with this:
-
there are those vuex plugins whose can serialize vuex state to the browsers indexedb and at the first access they load state from indexeddb. this alone just handles your problem. Just a quick results from google to show what is the mechanism:
https://netterminalmachine.com/blog/2018/persisting-a-vuex-store-to-indexed-db
https://github.com/abradley2/vuex-vip
https://github.com/championswimmer/vuex-persist#readme -
there is a vuexorm which in its own way makes your SPA “better” and more resiliant.
https://vuex-orm.github.io/vuex-orm/guide/prologue/what-is-vuex-orm.html -
there are psychological ways of interface building (“barriers”, “directional intents”) where user just do not wants to drag from the top resulting in page refresh. User is lead to believe, that she does not need to drag and drag and drag to the top of the page. It’s a job for a good designer obviously.
-
-
Thanks for the reply. I’ll check these options out.