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 = '';
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 => {
require('font-awesome/css/font-awesome.min.css')
require('./main.css')
// actions
import './todo/action'
import './category/action'
// route
import List from './todo/List'
import Form from './todo/Form'
import AddCategory from './category/Add'
import EditCategory from './category/Edit'
import {router} from 'san-router'
router.add({rule: '/', Component: List, target: '#app'});
router.add({rule: '/todos/category/:category', Component: List, target: '#app'});
router.add({rule: '/add', Component: Form, target: '#app'});
router.add({rule: '/edit/:id', Component: Form, target: '#app'});
router.add({rule: '/category/add', Component: AddCategory, target: '#app'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#app'});
// start
router.start();
import List from './todo/List'
import Form from './todo/Form'
import AddCategory from './category/Add'
import EditCategory from './category/Edit'
import {router} from 'san-router'
router.add({rule: '/', Component: List, target: '#app'});
router.add({rule: '/todos/category/:category', Component: List, target: '#app'});
router.add({rule: '/add', Component: Form, target: '#app'});
router.add({rule: '/edit/:id', Component: Form, target: '#app'});
router.add({rule: '/category/add', Component: AddCategory, target: '#app'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#app'});
// start
router.start();
import List from './todo/List'
import Form from './todo/Form'
import AddCategory from './category/Add'
import EditCategory from './category/Edit'
import {router} from 'san-router'
router.add({rule: '/', Component: List, target: '#app'});
router.add({rule: '/todos/category/:category', Component: List, target: '#app'});
router.add({rule: '/add', Component: Form, target: '#app'});
router.add({rule: '/edit/:id', Component: Form, target: '#app'});
router.add({rule: '/category/add', Component: AddCategory, target: '#app'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#app'});
// start
router.start();
import List from './todo/List'
import Form from './todo/Form'
import AddCategory from './category/Add'
import EditCategory from './category/Edit'
import {router} from 'san-router'
router.add({rule: '/', Component: List, target: '#app'});
router.add({rule: '/todos/category/:category', Component: List, target: '#app'});
router.add({rule: '/add', Component: Form, target: '#app'});
router.add({rule: '/edit/:id', Component: Form, target: '#app'});
router.add({rule: '/category/add', Component: AddCategory, target: '#app'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#app'});
// start
router.start()
toggleFollow() {
if (!this.data.get('isAuthenticated')) {
router.locator.redirect('/login');
return;
}
let author = this.data.get('article.author');
this.actions[author.following ? 'unfollow' : 'follow'](author.username)
.then(data => {
this.actions.setAuthor(data.profile);
console.log(data.profile)
});
},
define(function (require) {
var List = require('./todo/List-perf');
var Form = require('./todo/Form');
var AddCategory = require('./category/Add');
var EditCategory = require('./category/Edit');
var router = require('san-router').router;
router.add({rule: '/', Component: List, target: '#wrap'});
router.add({rule: '/todos/category/:category', Component: List, target: '#wrap'});
router.add({rule: '/add', Component: Form, target: '#wrap'});
router.add({rule: '/edit/:id', Component: Form, target: '#wrap'});
router.add({rule: '/category/add', Component: AddCategory, target: '#wrap'});
router.add({rule: '/category/edit', Component: EditCategory, target: '#wrap'});
return {
init: function () {
router.start();
}
};
});
import {router} from 'san-router';
import Graph from './Graph';
router.add({
target: '#content',
rule: '/graphs',
Component: Graph,
});
import {router} from 'san-router';
import Histogram from './Histogram';
router.add({
target: '#content',
rule: '/histograms',
Component: Histogram,
});