dynamic react router
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Styles from 'config/styles';
|
||||
import Templates from 'config/templates';
|
||||
import {hashHistory} from 'react-router';
|
||||
import app from './../../app';
|
||||
|
||||
Promise.all([
|
||||
@@ -7,5 +8,5 @@ Promise.all([
|
||||
Styles.sync()
|
||||
]).then(()=>{
|
||||
jQuery('#compiling_layouts').remove();
|
||||
app();
|
||||
app(hashHistory);
|
||||
});
|
||||
|
||||
@@ -11,11 +11,6 @@ const TEMPLATE_ROUTES = Object.freeze({
|
||||
power: 'dashboard/power/power.rt'
|
||||
});
|
||||
|
||||
const COMPONENTS = {
|
||||
Power: Power,
|
||||
Energy: Energy
|
||||
};
|
||||
|
||||
var TEMPLATES = {};
|
||||
|
||||
class Templates {
|
||||
@@ -40,16 +35,14 @@ class Templates {
|
||||
url: TEMPLATE_ROUTES[view]
|
||||
}).done((template)=>{
|
||||
var code = rt.convertTemplateToReact(template, {modules: 'none', name: view}),
|
||||
context = {};
|
||||
code = code.replace('var '+view+' = ', 'context.'+view+' = ');
|
||||
eval_context = {};
|
||||
code = code.replace('var ' + view + ' = ', 'eval_context.' + view + ' = ');
|
||||
new Function('with(this){ ' + code + ' } ').call({
|
||||
Energy: Energy,
|
||||
Power: Power,
|
||||
context: context,
|
||||
eval_context: eval_context,
|
||||
'_': _,
|
||||
'React': React
|
||||
});
|
||||
TEMPLATES[view] = context[view];
|
||||
TEMPLATES[view] = eval_context[view];
|
||||
fnResolve();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user