const AUTH_KEY = 'auth_client_side'

const setAuth = () => {
    if (sessionStorage) {
        sessionStorage.setItem(AUTH_KEY, '1');
    }
}

const isAuth = () => {
    if (sessionStorage) {
        return sessionStorage.getItem(AUTH_KEY) === '1';
    } else {
        return false;
    }
}

export default ({
    Vue, // the version of Vue being used in the VuePress app
    options, // the options for the root Vue instance
    router, // the router instance for the app
    siteData, // site metadata
    isServer // is this enhancement applied in server-rendering or client
}) => {
    router.beforeEach((to, from, next) => {
        if (siteData.themeConfig.protected.paths.includes(to.path)) {
            if (isAuth() || prompt() == siteData.themeConfig.protected.pass) {
                setAuth()
                next()
            } else {
                next("/")
            }
        } else {
            next()
        }
    })
}
@@ -58,35 +58,19 @@
 %3E %7B%0A    
-if (sessionStorage)
+try
  %7B%0A     
@@ -112,24 +112,40 @@
  '1');%0A    %7D
+ catch (err) %7B %7D
 %0A%7D%0A%0Aconst is
@@ -167,27 +167,11 @@
     
-if (sessionStorage)
+try
  %7B%0A 
@@ -228,28 +228,35 @@
  '1';%0A    %7D 
-else
+catch (err)
  %7B%0A        r
@@ -266,17 +266,16 @@
 rn false
-;
 %0A    %7D%0A%7D

Test sessionStorage