@hlw-uni/mp-vue 1.0.21 → 1.0.23

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.
@@ -70,19 +70,60 @@
70
70
  </template>
71
71
 
72
72
  <script setup lang="ts">
73
+ /**
74
+ * HlwMenu 菜单组件
75
+ *
76
+ * 支持列表模式和宫格模式,数据驱动,适用于个人中心、设置页等场景。
77
+ *
78
+ * @example 列表模式
79
+ * ```vue
80
+ * <hlw-menu title="我的服务" :items="menuItems" @click="handleClick" />
81
+ * ```
82
+ *
83
+ * @example 宫格模式
84
+ * ```vue
85
+ * <hlw-menu mode="grid" :columns="4" :items="gridItems" @click="handleClick" />
86
+ * ```
87
+ *
88
+ * @example 无边框
89
+ * ```vue
90
+ * <hlw-menu :items="menuItems" :border="false" />
91
+ * ```
92
+ */
93
+
73
94
  import { computed } from "vue";
74
95
  import type { HlwMenuItem } from "./types";
75
96
  export type { HlwMenuItem } from "./types";
76
97
 
77
98
  interface Props {
99
+ /**
100
+ * 菜单项数据列表。
101
+ * 每项可设置图标、文字、跳转路径、右侧标签、右侧纯文字、加载状态等。
102
+ * 设置 `visible: false` 可隐藏某一项。
103
+ */
78
104
  items: HlwMenuItem[];
79
- /** 标题 */
105
+ /**
106
+ * 卡片标题,显示在菜单上方,标题下方带虚线分割。
107
+ * 不传则不显示标题区域。
108
+ * @default ""
109
+ */
80
110
  title?: string;
81
- /** 布局模式,默认 list */
111
+ /**
112
+ * 布局模式。
113
+ * - `list`:列表模式,左侧图标 + 文字,右侧可显示标签 / 纯文字 / 加载状态 + 箭头
114
+ * - `grid`:宫格模式,图标居中 + 文字在下方,支持右上角角标
115
+ * @default "list"
116
+ */
82
117
  mode?: "list" | "grid";
83
- /** 宫格列数,默认 4 */
118
+ /**
119
+ * 宫格模式每行列数,仅 `mode="grid"` 时生效。
120
+ * @default 4
121
+ */
84
122
  columns?: number;
85
- /** 是否显示外边框,默认 true */
123
+ /**
124
+ * 是否显示卡片外边框。
125
+ * @default true
126
+ */
86
127
  border?: boolean;
87
128
  }
88
129
 
@@ -94,6 +135,11 @@ const props = withDefaults(defineProps<Props>(), {
94
135
  });
95
136
 
96
137
  const emit = defineEmits<{
138
+ /**
139
+ * 点击无跳转路径的菜单项时触发。
140
+ * 有 `url` 的项由 `navigator` 自行跳转,不触发此事件。
141
+ * @param item 被点击的菜单项
142
+ */
97
143
  click: [item: HlwMenuItem];
98
144
  }>();
99
145
 
@@ -1,25 +1,55 @@
1
+ /** 图标主题色,对应预设的背景色 + 前景色组合 */
1
2
  export type HlwMenuIconTheme = "orange" | "purple" | "cyan" | "emerald" | "slate" | "wechat" | "rose" | "blue" | "red";
3
+
4
+ /** 标签 / 角标的主题色 */
2
5
  export type HlwMenuTagTheme = "orange" | "red" | "wechat" | "rose" | "blue";
3
6
 
4
7
  export interface HlwMenuItem {
5
- /** 图标 class,如 'i-fa6-solid-gear' */
8
+ /**
9
+ * 图标的 CSS class,使用 UnoCSS / iconify 图标名。
10
+ * @example "i-fa6-solid-gear"
11
+ */
6
12
  icon: string;
7
- /** 图标主题色 */
13
+ /**
14
+ * 图标背景色主题。不传默认使用 `slate`(灰色)。
15
+ * @default "slate"
16
+ */
8
17
  iconTheme?: HlwMenuIconTheme;
9
- /** 菜单文字 */
18
+ /** 菜单项文字 */
10
19
  label: string;
11
- /** 跳转路径,有值则用 navigator 包裹 */
20
+ /**
21
+ * 跳转路径。有值时使用 `<navigator>` 包裹,点击直接跳转,不触发 `click` 事件。
22
+ * @example "/pages/setting/index"
23
+ */
12
24
  url?: string;
13
- /** 右侧纯文字说明(列表模式),如版本号、状态文字 */
25
+ /**
26
+ * 右侧纯文字说明,仅列表模式显示。适合展示版本号、状态等辅助信息。
27
+ * @example "v1.2.0"
28
+ */
14
29
  value?: string;
15
- /** 右侧标签文字(列表模式)/ 角标文字(宫格模式) */
30
+ /**
31
+ * 右侧彩色标签文字(列表模式)或图标右上角角标文字(宫格模式)。
32
+ * @example "NEW"
33
+ */
16
34
  tag?: string;
17
- /** 标签主题色 */
35
+ /**
36
+ * 标签 / 角标的主题色。不传默认 `rose`(红色)。
37
+ * @default "rose"
38
+ */
18
39
  tagTheme?: HlwMenuTagTheme;
19
- /** 标签是否闪烁 */
40
+ /**
41
+ * 标签是否呼吸闪烁动画,用于吸引用户注意。
42
+ * @default false
43
+ */
20
44
  tagPulse?: boolean;
21
- /** 加载中状态(列表模式) */
45
+ /**
46
+ * 显示加载中转圈图标,仅列表模式生效。适合异步操作进行中的状态。
47
+ * @default false
48
+ */
22
49
  loading?: boolean;
23
- /** 是否显示,默认 true */
50
+ /**
51
+ * 是否渲染该菜单项。`false` 时从列表中隐藏,不占位。
52
+ * @default true
53
+ */
24
54
  visible?: boolean;
25
55
  }
package/src/index.ts CHANGED
@@ -2,14 +2,12 @@
2
2
  * @hlw-uni/mp-vue — Vue 组件库统一导出
3
3
  */
4
4
 
5
- export { default as HlwAd } from './components/hlw-ad/index.vue';
6
- export { default as HlwAvatar } from './components/hlw-avatar/index.vue';
7
- export { default as HlwCard } from './components/hlw-card/index.vue';
8
- export { default as HlwEmpty } from './components/hlw-empty/index.vue';
9
- export { default as HlwHeader } from './components/hlw-header/index.vue';
10
- export { default as HlwLoading } from './components/hlw-loading/index.vue';
11
- export { default as HlwMenu } from './components/hlw-menu/index.vue';
12
- export type { HlwMenuItem } from './components/hlw-menu/types';
13
- export { default as HlwMenuList } from './components/hlw-menu-list/index.vue';
14
- export { default as HlwPage } from './components/hlw-page/index.vue';
15
- export type { MenuItem } from './components/hlw-menu-list/types';
5
+ export { default as HlwAd } from "./components/hlw-ad/index.vue";
6
+ export { default as HlwAvatar } from "./components/hlw-avatar/index.vue";
7
+ export { default as HlwCard } from "./components/hlw-card/index.vue";
8
+ export { default as HlwEmpty } from "./components/hlw-empty/index.vue";
9
+ export { default as HlwHeader } from "./components/hlw-header/index.vue";
10
+ export { default as HlwLoading } from "./components/hlw-loading/index.vue";
11
+ export { default as HlwMenu } from "./components/hlw-menu/index.vue";
12
+ export type { HlwMenuItem } from "./components/hlw-menu/types";
13
+ export { default as HlwPage } from "./components/hlw-page/index.vue";
@@ -1,8 +0,0 @@
1
- export interface MenuItem {
2
- key: string;
3
- label: string;
4
- icon?: string;
5
- value?: string;
6
- url?: string;
7
- action?: () => void;
8
- }
@@ -1,94 +0,0 @@
1
- <template>
2
- <view class="hlw-menu-list">
3
- <view
4
- v-for="item in items"
5
- :key="item.key"
6
- class="hlw-menu-list__item"
7
- @tap="onTap(item)"
8
- >
9
- <view class="hlw-menu-list__left">
10
- <text v-if="item.icon" class="hlw-menu-list__icon">{{ item.icon }}</text>
11
- <text class="hlw-menu-list__label">{{ item.label }}</text>
12
- </view>
13
- <view class="hlw-menu-list__right">
14
- <text v-if="item.value" class="hlw-menu-list__value">{{ item.value }}</text>
15
- <text class="hlw-menu-list__arrow">›</text>
16
- </view>
17
- </view>
18
- </view>
19
- </template>
20
-
21
- <script setup lang="ts">
22
- import type { MenuItem } from './types';
23
-
24
- const props = defineProps<{
25
- items: MenuItem[];
26
- }>();
27
-
28
- const emit = defineEmits<{
29
- (e: 'click', item: MenuItem): void;
30
- }>();
31
-
32
- function onTap(item: MenuItem) {
33
- if (item.url) {
34
- uni.navigateTo({ url: item.url });
35
- } else if (item.action) {
36
- item.action();
37
- }
38
- emit('click', item);
39
- }
40
- </script>
41
-
42
- <style scoped>
43
- .hlw-menu-list {
44
- background: #fff;
45
- border-radius: 16rpx;
46
- overflow: hidden;
47
- }
48
-
49
- .hlw-menu-list__item {
50
- display: flex;
51
- align-items: center;
52
- justify-content: space-between;
53
- padding: 28rpx 32rpx;
54
- border-bottom: 1rpx solid #f5f5f5;
55
- }
56
-
57
- .hlw-menu-list__item:last-child {
58
- border-bottom: none;
59
- }
60
-
61
- .hlw-menu-list__left {
62
- display: flex;
63
- align-items: center;
64
- gap: 16rpx;
65
- }
66
-
67
- .hlw-menu-list__icon {
68
- font-size: 36rpx;
69
- width: 44rpx;
70
- text-align: center;
71
- }
72
-
73
- .hlw-menu-list__label {
74
- font-size: 30rpx;
75
- color: #333;
76
- }
77
-
78
- .hlw-menu-list__right {
79
- display: flex;
80
- align-items: center;
81
- gap: 8rpx;
82
- }
83
-
84
- .hlw-menu-list__value {
85
- font-size: 28rpx;
86
- color: #999;
87
- }
88
-
89
- .hlw-menu-list__arrow {
90
- font-size: 36rpx;
91
- color: #ccc;
92
- line-height: 1;
93
- }
94
- </style>
@@ -1,8 +0,0 @@
1
- export interface MenuItem {
2
- key: string;
3
- label: string;
4
- icon?: string;
5
- value?: string;
6
- url?: string;
7
- action?: () => void;
8
- }