Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
attached() {
const that = this;
// 错误提示
window.addEventListener('error', this.handleError.bind(this), false);
// 添加路由
router.add({
rule: '/:type/:id',
handler(e) {
// console.log(e); // eslint-disable-line
}
});
// 路由监听
router.listen(e => {
const query = e.query;
if (e.path === '/') {
that.handleRedirect({key: defaultPath});
that.data.set('currentPath', defaultPath);
}
else {
that.data.set('currentPath', e.path);
document.getElementById('content').innerHTML = '';
that.data.set('content', '');
if (query.type === 'docs') {
import(
/* webpackChunkName: "docs" */
`@docs/${query.id}.md?exportType=html`
).then(({default: html}) => {
that.data.set('content', html);
}).catch(e => {
function bootstrap() {
axios.defaults.validateStatus = function (status) {
return status >= 200 && status < 500;
};
(new Header).attach(document.getElementById('header'));
(new Footer).attach(document.getElementById('footer'));
router.listen(e => {
store.dispatch(ActionTypes.ERRORS_CLEAR);
store.dispatch(UserActionTypes.GET);
});
router.add({rule: '/', Component: Home});
router.add({rule: '/tag/:tag', Component: Home});
router.add({rule: '/my-feed', Component: Home});
router.add({rule: '/login', Component: Login});
router.add({rule: '/register', Component: Register});
router.add({rule: '/settings', Component: Setting});
router.add({rule: '/profile/:user', Component: ProfileMy});
router.add({rule: '/profile/:user/favorites', Component: ProfileFavorited});
router.add({rule: '/editor', Component: ArticleEdit});
router.add({rule: '/editor/:slug', Component: ArticleEdit});
router.add({rule: '/article/:slug', Component: ArticleView});