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 = '';
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();
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,
});
import {router} from 'san-router';
import HomePage from './Home';
router.add({
target: '#content',
rule: '/welcome',
Component: HomePage
});
import {router} from 'san-router';
import Scalar from './Scalars';
router.add({
target: '#content',
rule: '/',
Component: Scalar,
});
router.add({
target: '#content',
rule: '/scalars',
Component: Scalar,
});
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});
router.start();
}
import {router} from 'san-router';
import Images from './Images';
router.add({
target: '#content',
rule: '/images',
Component: Images,
});
import {router} from 'san-router';
import Audio from './Audio';
router.add({
target: '#content',
rule: '/audio',
Component: Audio,
});