mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-02-27 04:42:49 +08:00
magic-api中的component 可以用于mb-form,单独magic-import.js
This commit is contained in:
parent
4400acd4e1
commit
d4108c8e49
@ -9,7 +9,7 @@
|
|||||||
<el-col v-for="(col,j) in row.cols" :key="j" :span="col.span" v-bind="col.colProps">
|
<el-col v-for="(col,j) in row.cols" :key="j" :span="col.span" v-bind="col.colProps">
|
||||||
<el-form-item :label="col.label" :label-width="col.labelWidth" :prop="col.name" v-bind="col.formItemProps">
|
<el-form-item :label="col.label" :label-width="col.labelWidth" :prop="col.name" v-bind="col.formItemProps">
|
||||||
<component
|
<component
|
||||||
:is="!col.component ? 'mb-input' : col.component.startsWith('el-') ? col.component : 'mb-' + col.component"
|
:is="!col.component ? 'mb-input' : col.component.startsWith('el-') || $global.dynamicComponentNames.indexOf(col.component) != -1 ? col.component : 'mb-' + col.component"
|
||||||
v-model="formData[col.name]"
|
v-model="formData[col.name]"
|
||||||
:item-label="col.label"
|
:item-label="col.label"
|
||||||
v-bind="col.props"
|
v-bind="col.props"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import * as vue from 'vue'
|
|
||||||
import {createApp} from 'vue'
|
import {createApp} from 'vue'
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
import ElementPlus from 'element-plus'
|
import ElementPlus from 'element-plus'
|
||||||
@ -14,13 +13,7 @@ import hasPermission from './scripts/hasPermission'
|
|||||||
import { appComponent } from './scripts/dynamicComponent'
|
import { appComponent } from './scripts/dynamicComponent'
|
||||||
import '@/permission'
|
import '@/permission'
|
||||||
import global from '@/scripts/global.js'
|
import global from '@/scripts/global.js'
|
||||||
const libs = {
|
import '@/scripts/magic-import'
|
||||||
vue,
|
|
||||||
'element-plus': ElementPlus
|
|
||||||
}
|
|
||||||
window.___magic__import__ = function(lib, name){
|
|
||||||
return (libs[lib] || {})[name]
|
|
||||||
}
|
|
||||||
app.use(globalProperties)
|
app.use(globalProperties)
|
||||||
|
|
||||||
var loadDynamicComponent = false
|
var loadDynamicComponent = false
|
||||||
@ -37,6 +30,7 @@ router.beforeEach(async (to, from) => {
|
|||||||
})
|
})
|
||||||
await app.config.globalProperties.$post('/system/component/list').then((res) => {
|
await app.config.globalProperties.$post('/system/component/list').then((res) => {
|
||||||
res.data.forEach(it => {
|
res.data.forEach(it => {
|
||||||
|
global.dynamicComponentNames.push(it.name)
|
||||||
appComponent(app, it)
|
appComponent(app, it)
|
||||||
})
|
})
|
||||||
loading.close()
|
loading.close()
|
||||||
|
@ -10,5 +10,6 @@ export default {
|
|||||||
},
|
},
|
||||||
baseApi: import.meta.env.VITE_APP_BASE_API,
|
baseApi: import.meta.env.VITE_APP_BASE_API,
|
||||||
visitedViews: reactive([]),
|
visitedViews: reactive([]),
|
||||||
tabValue: ref('')
|
tabValue: ref(''),
|
||||||
|
dynamicComponentNames: []
|
||||||
}
|
}
|
||||||
|
10
magic-boot-ui/src/scripts/magic-import.js
Normal file
10
magic-boot-ui/src/scripts/magic-import.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import * as vue from "vue";
|
||||||
|
import ElementPlus from "element-plus";
|
||||||
|
|
||||||
|
const libs = {
|
||||||
|
vue,
|
||||||
|
'element-plus': ElementPlus
|
||||||
|
}
|
||||||
|
window.___magic__import__ = function(lib, name){
|
||||||
|
return (libs[lib] || {})[name]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user