im-ui-mobile 0.0.38 → 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.
@@ -1,24 +1,19 @@
1
1
  <template>
2
- <view class="im-chat" :class="[`im-chat--${type}`]" @click="handleClick">
3
- <view class="im-chat__avatar">
2
+ <view class="im-sample" :class="[`im-sample--${type}`]" @click="handleClick">
3
+ <view class="im-sample__avatar">
4
4
  <view class="avatar-fallback">
5
- <!-- <image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill" /> -->
6
5
  <u-avatar v-if="avatar" :src="avatar" />
7
6
  <text v-else class="avatar-text">{{ displayName }}</text>
8
7
  </view>
9
8
  </view>
10
- <view class="im-chat__content">
11
- <view class="im-chat__header">
12
- <text class="im-chat__name">{{ name }}</text>
13
- <text class="im-chat__time">{{ time }}</text>
9
+ <view class="im-sample__content">
10
+ <view class="im-sample__header">
11
+ <text class="im-sample__name">{{ name }}</text>
12
+ <text class="im-sample__time">{{ time }}</text>
14
13
  </view>
15
- <view class="im-chat__message">
16
- <text class="im-chat__text">{{ lastMessage }}</text>
14
+ <view class="im-sample__message">
15
+ <text class="im-sample__text">{{ lastMessage }}</text>
17
16
  <u-badge v-if="unreadCount > 0" :max="99" :value="unreadCount" />
18
-
19
- <!-- <view v-if="unreadCount > 0" class="badge-fallback">
20
- <text class="badge-text">{{ displayUnreadCount }}</text>
21
- </view> -->
22
17
  </view>
23
18
  </view>
24
19
  </view>
@@ -91,7 +86,7 @@ const handleClick = (event: Event) => {
91
86
  </script>
92
87
 
93
88
  <style lang="scss" scoped>
94
- .im-chat {
89
+ .im-sample {
95
90
  display: flex;
96
91
  padding: 24rpx 32rpx;
97
92
  transition: background-color 0.3s;
@@ -149,7 +144,7 @@ const handleClick = (event: Event) => {
149
144
  flex: 1;
150
145
 
151
146
  /* 群聊样式 */
152
- .im-chat--group &::before {
147
+ .im-sample--group &::before {
153
148
  content: "👥 ";
154
149
  }
155
150
  }
package/index.js CHANGED
@@ -1,12 +1,55 @@
1
1
  import { UViewPlusPlugin } from './plugins/uview-plus.js'
2
- import ImChat from './components/im-chat/im-chat.vue'
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
- ImChat
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "im-ui-mobile",
3
- "version": "0.0.38",
3
+ "version": "0.0.40",
4
4
  "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -4,11 +4,26 @@ export const UViewPlusPlugin = {
4
4
  install(app) {
5
5
  // 安装 uview-plus
6
6
  app.use(uviewPlus)
7
-
7
+
8
8
  // 注册一些常用的 uview-plus 组件作为全局组件
9
9
  app.component('UButton', uviewPlus.Button)
10
10
  app.component('UInput', uviewPlus.Input)
11
11
  app.component('UAvatar', uviewPlus.Avatar)
12
12
  app.component('UBadge', uviewPlus.Badge)
13
+ app.component('UIcon', uviewPlus.Icon)
14
+ app.component('UPopup', uviewPlus.Popup)
15
+ app.component('USearch', uviewPlus.Search)
16
+ app.component('UIndexList', uviewPlus.IndexList)
17
+ app.component('UIndexItem', uviewPlus.IndexItem)
18
+ app.component('UCard', uviewPlus.Card)
19
+ app.component('UTabs', uviewPlus.Tabs)
20
+ app.component('UParse', uviewPlus.Parse)
21
+ app.component('ULink', uviewPlus.Link)
22
+ app.component('UUpload', uviewPlus.Upload)
23
+ app.component('ULineProgress', uviewPlus.LineProgress)
24
+ app.component('UModal', uviewPlus.Modal)
25
+ app.component('UTag', uviewPlus.Tag)
26
+ app.component('UForm', uviewPlus.Form)
27
+ app.component('UFormItem', uviewPlus.FormItem)
13
28
  }
14
29
  }
@@ -1,6 +1,6 @@
1
1
  import { AllowedComponentProps, VNodeProps } from './_common'
2
2
 
3
- declare interface ChatProps {
3
+ declare interface SampleProps {
4
4
  type: string
5
5
  avatar: string
6
6
  name: string
@@ -9,12 +9,12 @@ declare interface ChatProps {
9
9
  unreadCount: number
10
10
  }
11
11
 
12
- declare interface _Chat {
12
+ declare interface _Sample {
13
13
  new(): {
14
14
  $props: AllowedComponentProps &
15
15
  VNodeProps &
16
- ChatProps
16
+ SampleProps
17
17
  }
18
18
  }
19
19
 
20
- export declare const Chat: _Chat
20
+ export declare const Sample: _Sample
@@ -1,6 +1,6 @@
1
1
  declare module 'vue' {
2
2
  export interface GlobalComponents {
3
- ['im-chat']: typeof import('./components/chat')['Chat']
3
+ ['im-sample']: typeof import('./components/sample')['Sample']
4
4
  }
5
5
  }
6
6