优化: 前端插件优化
parent
8340ef2d56
commit
7bbb33344f
|
@ -2,7 +2,7 @@ import layoutHeaderAside from '@/layout/header-aside'
|
|||
import { checkPlugins } from '@/views/plugins/index.js'
|
||||
// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
|
||||
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
|
||||
|
||||
const pluginImport = require('@/libs/util.import.plugin')
|
||||
/**
|
||||
* 在主框架内显示
|
||||
*/
|
||||
|
@ -189,11 +189,12 @@ const frameOut = [
|
|||
/**
|
||||
* 第三方登录
|
||||
*/
|
||||
if (checkPlugins('third-party-login')) {
|
||||
const pluginsType = checkPlugins('third-party-login')
|
||||
if (pluginsType) {
|
||||
frameOut.push({
|
||||
path: '/thirdPartyLogin',
|
||||
name: 'login',
|
||||
component: _import('plugins/third-party-login/src/login/index')
|
||||
component: pluginsType === 'local' ? _import('plugins/third-party-login/src/login/index') : pluginImport('third-party-login/src/login/index')
|
||||
})
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import Vue from 'vue'
|
||||
|
||||
function importAll (r) {
|
||||
const __modules = []
|
||||
r.keys().forEach(key => {
|
||||
|
@ -11,10 +9,19 @@ function importAll (r) {
|
|||
}
|
||||
|
||||
export const checkPlugins = async function install (pluginName) {
|
||||
if (!window.pluginsAll) {
|
||||
plugins(Vue)
|
||||
let pluginsList
|
||||
pluginsList = importAll(require.context('./', true, /index\.js$/))
|
||||
if (pluginsList && pluginsList.indexOf(pluginName) !== -1) {
|
||||
// 本地插件
|
||||
return 'local'
|
||||
}
|
||||
return (window.pluginsAll && window.pluginsAll.indexOf(pluginName) !== -1)
|
||||
pluginsList = importAll(require.context('@great-dream/', true, /index\.js$/))
|
||||
if (pluginsList && pluginsList.indexOf(pluginName) !== -1) {
|
||||
// node_modules 封装插件
|
||||
return 'plugins'
|
||||
}
|
||||
// 未找到插件
|
||||
return undefined
|
||||
}
|
||||
|
||||
export const plugins = async function install (Vue, options) {
|
||||
|
|
Loading…
Reference in New Issue