如果用户未经身份验证,我需要将用户重定向到登录页面。我需要类似route.beforeEachVue.js 的东西,理想情况下:
sapper.beforeRouteChange((to, from, next) => {
const isAuth = "[some session or token check]";
if (!isAuth) {
next('/login')
}
next()
})
Run Code Online (Sandbox Code Playgroud)
我发现了Sapper - protected routes (route guard)这个问题,但我认为这不足以满足我的需求。如果令牌或身份验证在运行时发生变化怎么办?或者它是否被反应性覆盖?
编辑 1:我认为Sapper GitHub 上的这个问题解决了我的问题。
我们希望避免在我们的 svelte/sapper 应用程序中出现不受支持的浏览器的问题。
我想警告用户我们用 Sapper/Svelte 编写的应用程序与 Internet Explorer 不兼容。它可以是简单的纯文本消息或重定向到某个错误页面。
现在我有这个代码
<head>
...
<!-- IE10+ will switch to IE9 behaviour and will respect IE HTML conditional tags -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
...
</head>
<body>
<![if !IE]>
<div id='sapper'>%sapper.html%</div>
%sapper.scripts%
<![endif]>
<!--[if IE]>
<h1 style="color: #333; font-family: 'Arial'; font-size: 18px; padding: 24px 18px; text-align: center;">
We do not support Internet Explorer.
</h1>
<p style="font-size: 46px; text-align: center; padding: 12px 0;">:/</p>
<![endif]-->
</body>
Run Code Online (Sandbox Code Playgroud)
在template.html文件中。这是否足以检测所有 IE …