imatrix-ui 2.9.21-boe01-rc3 → 2.9.21-boe01-rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +45 -0
- package/lib/index.js +39 -0
- package/package.json +1 -1
- package/src/plugins.js +12 -5
- package/lib/src/plugins.js +0 -18
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// iMatrix-UI 组件库入口文件 (CommonJS)
|
|
2
|
+
// 优先推荐直接使用组件文件路径引入,避免加载大包
|
|
3
|
+
|
|
4
|
+
// 全量引入对象(延迟加载)
|
|
5
|
+
const FullLibrary = {
|
|
6
|
+
install(Vue, opts = {}) {
|
|
7
|
+
// 只有在真正使用 Vue.use() 时才加载全量包
|
|
8
|
+
try {
|
|
9
|
+
const SuperUI = require('./super-ui.umd.min.js')
|
|
10
|
+
if (SuperUI && SuperUI.default && SuperUI.default.install) {
|
|
11
|
+
SuperUI.default.install(Vue, opts)
|
|
12
|
+
} else if (SuperUI && SuperUI.install) {
|
|
13
|
+
SuperUI.install(Vue, opts)
|
|
14
|
+
} else {
|
|
15
|
+
console.warn('iMatrix-UI: 无法找到安装方法,请检查super-ui.umd.min.js文件')
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('iMatrix-UI: 加载全量包失败', error.message)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 尝试导出按需引入的组件
|
|
24
|
+
try {
|
|
25
|
+
const components = require('./components.js')
|
|
26
|
+
if (components) {
|
|
27
|
+
Object.assign(module.exports, components)
|
|
28
|
+
}
|
|
29
|
+
} catch (e) {
|
|
30
|
+
// components.js 可能是ES模块格式,提供备用方案
|
|
31
|
+
console.warn('iMatrix-UI: 无法加载components.js,请直接使用组件路径引入')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 默认导出
|
|
35
|
+
module.exports = FullLibrary
|
|
36
|
+
module.exports.default = FullLibrary
|
|
37
|
+
|
|
38
|
+
// 添加版本信息
|
|
39
|
+
try {
|
|
40
|
+
const pkg = require('../package.json')
|
|
41
|
+
module.exports.version = pkg.version
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// 忽略版本信息获取失败
|
|
44
|
+
}
|
|
45
|
+
module.exports.description = '推荐使用: require("imatrix-ui/lib/组件名/组件名.umd.min.js") 来按需引入组件'
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// iMatrix-UI 组件库入口文件 (ES Module)
|
|
2
|
+
// 按需引入优先,全量引入按需加载
|
|
3
|
+
|
|
4
|
+
// 导出所有组件供按需引入
|
|
5
|
+
export * from './components.js'
|
|
6
|
+
|
|
7
|
+
// 全量引入对象(延迟加载)
|
|
8
|
+
const FullLibrary = {
|
|
9
|
+
install(Vue, opts = {}) {
|
|
10
|
+
// 只有在真正使用 Vue.use() 时才动态加载全量包
|
|
11
|
+
const loadFullLibrary = async () => {
|
|
12
|
+
try {
|
|
13
|
+
const SuperUI = await import('./super-ui.umd.min.js')
|
|
14
|
+
if (SuperUI && SuperUI.default && SuperUI.default.install) {
|
|
15
|
+
SuperUI.default.install(Vue, opts)
|
|
16
|
+
} else if (SuperUI && SuperUI.install) {
|
|
17
|
+
SuperUI.install(Vue, opts)
|
|
18
|
+
}
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// 降级到同步加载
|
|
21
|
+
try {
|
|
22
|
+
const SuperUI = require('./super-ui.umd.min.js')
|
|
23
|
+
if (SuperUI && SuperUI.default && SuperUI.default.install) {
|
|
24
|
+
SuperUI.default.install(Vue, opts)
|
|
25
|
+
} else if (SuperUI && SuperUI.install) {
|
|
26
|
+
SuperUI.install(Vue, opts)
|
|
27
|
+
}
|
|
28
|
+
} catch (syncError) {
|
|
29
|
+
console.error('iMatrix-UI: 无法加载全量包', syncError)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
loadFullLibrary()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 默认导出全量安装器
|
|
39
|
+
export default FullLibrary
|
package/package.json
CHANGED
package/src/plugins.js
CHANGED
|
@@ -7,12 +7,19 @@ import ElementUI from 'element-ui'
|
|
|
7
7
|
import 'element-ui/lib/theme-chalk/index.css'
|
|
8
8
|
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// 注意:在构建组件库时,不应该引入自己
|
|
11
|
+
// 这个文件主要用于开发环境,实际使用时应该由用户自行配置
|
|
12
|
+
// import SuperUI from 'imatrix-ui' // 避免循环引用
|
|
13
|
+
// import 'imatrix-ui/lib/super-ui.css'
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
+
// 改为引入本地的组件库入口(仅开发时使用)
|
|
16
|
+
// import SuperUI from '../packages/index.js'
|
|
17
|
+
|
|
18
|
+
// 权限相关
|
|
19
|
+
// import 'imatrix-ui/src/permission' // permission control
|
|
20
|
+
import './permission' // 改为相对路径,避免循环引用
|
|
21
|
+
import permission from './directives/permission'
|
|
15
22
|
|
|
16
23
|
Vue.use(ElementUI, { locale })
|
|
17
|
-
Vue.use(SuperUI)
|
|
24
|
+
// Vue.use(SuperUI) // 注释掉,避免循环引用
|
|
18
25
|
permission.install(Vue)
|
package/lib/src/plugins.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
|
|
3
|
-
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
|
|
4
|
-
import './styles/index.scss' // global css
|
|
5
|
-
|
|
6
|
-
import ElementUI from 'element-ui'
|
|
7
|
-
import 'element-ui/lib/theme-chalk/index.css'
|
|
8
|
-
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
|
|
9
|
-
|
|
10
|
-
import SuperUI from 'imatrix-ui'
|
|
11
|
-
import 'imatrix-ui/lib/super-ui.css'
|
|
12
|
-
|
|
13
|
-
import 'imatrix-ui/src/permission' // permission control
|
|
14
|
-
import permission from 'imatrix-ui/src/directives/permission'
|
|
15
|
-
|
|
16
|
-
Vue.use(ElementUI, { locale })
|
|
17
|
-
Vue.use(SuperUI)
|
|
18
|
-
permission.install(Vue)
|