mirror of https://github.com/rancher/dashboard.git
28 lines
443 B
JavaScript
28 lines
443 B
JavaScript
import { normalizeType } from './normalize';
|
|
|
|
const cache = {};
|
|
|
|
export function lookup(type) {
|
|
type = normalizeType(type).replace(/\//g, '');
|
|
|
|
let impl = cache[type];
|
|
|
|
if ( impl ) {
|
|
return impl.default;
|
|
} else if ( typeof impl !== 'undefined' ) {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
impl = require(`@/models/${ type }`);
|
|
cache[type] = impl;
|
|
|
|
return impl.default;
|
|
} catch (e) {
|
|
}
|
|
|
|
cache[type] = null;
|
|
|
|
return null;
|
|
}
|