im-ui-mobile 0.0.39 → 0.0.40
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/index.js +48 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
import { UViewPlusPlugin } from './plugins/uview-plus.js'
|
|
2
|
-
import ImChat from './components/im-
|
|
2
|
+
// import ImChat from './components/im-sample/im-sample.vue'
|
|
3
3
|
|
|
4
4
|
// 重要:为组件添加名称,以支持开发环境
|
|
5
|
-
ImChat.name = 'ImChat'
|
|
5
|
+
// ImChat.name = 'ImChat'
|
|
6
6
|
|
|
7
|
-
const components = [
|
|
8
|
-
|
|
9
|
-
]
|
|
7
|
+
// const components = [
|
|
8
|
+
// ImChat
|
|
9
|
+
// ]
|
|
10
|
+
|
|
11
|
+
// #ifdef APP || H5
|
|
12
|
+
const importFn = import.meta.glob('./components/im-*/im-*.vue', { eager: true })
|
|
13
|
+
const components = [];
|
|
14
|
+
|
|
15
|
+
// 批量注册全局组件
|
|
16
|
+
for (const key in importFn) {
|
|
17
|
+
const component = importFn[key].default;
|
|
18
|
+
|
|
19
|
+
// 1. 从文件路径中提取组件名(更可靠的方法)
|
|
20
|
+
const fileName = key.split('/').pop(); // 获取文件名,如 im-button.vue
|
|
21
|
+
const componentName = fileName
|
|
22
|
+
.replace('.vue', '') // 去掉 .vue 后缀
|
|
23
|
+
.replace(/\b\w/g, l => l.toUpperCase()) // 首字母大写,如 ImButton
|
|
24
|
+
|
|
25
|
+
// 或者使用 kebab-case 转 PascalCase 的通用方法
|
|
26
|
+
const toPascalCase = (str) => {
|
|
27
|
+
return str
|
|
28
|
+
.replace(/im-/, '') // 去掉 im- 前缀
|
|
29
|
+
.split('-')
|
|
30
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
31
|
+
.join('');
|
|
32
|
+
}
|
|
33
|
+
const pascalName = 'Im' + toPascalCase(fileName.replace('.vue', ''));
|
|
34
|
+
|
|
35
|
+
// 2. 正确的安装方法
|
|
36
|
+
if (component) {
|
|
37
|
+
// 如果组件本身没有 name,给它设置一个
|
|
38
|
+
if (!component.name) {
|
|
39
|
+
component.name = pascalName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 添加 install 方法
|
|
43
|
+
// component.install = function (app) {
|
|
44
|
+
// app.component(component.name || pascalName, component);
|
|
45
|
+
// };
|
|
46
|
+
|
|
47
|
+
// 添加到组件列表
|
|
48
|
+
components.push(component);
|
|
49
|
+
console.log(`注册组件: ${component.name || pascalName}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// #endif
|
|
10
53
|
|
|
11
54
|
const install = (app) => {
|
|
12
55
|
// 安装 uview-plus
|