@zfqh/uniapp 0.2.31 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.3.0](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.32...@zfqh/uniapp@0.3.0) (2026-07-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * 增加permission组件 ([0161786](http://10.10.10.16/caoben/front-end/commits/0161786fb3d1ec98ff4fb3251ce4c05adc11e14c))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.2.32](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.31...@zfqh/uniapp@0.2.32) (2026-07-07)
18
+
19
+ **Note:** Version bump only for package @zfqh/uniapp
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.2.31](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.30...@zfqh/uniapp@0.2.31) (2026-07-02)
7
26
 
8
27
  **Note:** Version bump only for package @zfqh/uniapp
@@ -0,0 +1,61 @@
1
+ # g-permission 权限控制
2
+
3
+ ::: tip 组件名
4
+ `g-permission`
5
+
6
+ 发布路径:`@zfqh/uniapp/lib/components/g-permission/g-permission.vue`
7
+ :::
8
+
9
+ 根据当前用户的菜单权限(`state.app.info.perms`)条件渲染插槽内容,用于按权限控制按钮、菜单项等 UI 元素的显示。
10
+
11
+ ## 平台兼容性
12
+
13
+ | App(vue) | App(nvue) | H5 | 小程序 | Vue 2 | Vue 3 |
14
+ | --- | --- | --- | --- | --- | --- |
15
+ | √ | √ | √ | √ | - | √ |
16
+
17
+ ## 使用前提
18
+
19
+ - 已安装并注册 `@zfqh/uniapp` 插件。
20
+ - 已按 [项目接入](./usage) 配置 easycom,或手动从构建产物导入组件。
21
+ - Store 中已注册 `app` 模块(提供 `state.app.info.perms` 数据)。
22
+
23
+ ## 工作原理
24
+
25
+ 组件从 `uni.$store.state.app.info.perms` 读取权限列表,筛选 `isSelect` 为 `true` 的项,判断其 `menuName` 是否与 `include` 匹配。`include` 支持传入单个字符串或字符串数组,满足任一匹配即渲染插槽内容,否则不渲染。
26
+
27
+ 权限数据为异步加载,`perms` 变化时组件会自动重新计算,响应权限更新。
28
+
29
+ ## 基本使用
30
+
31
+ ```vue
32
+ <template>
33
+ <!-- 单个权限 -->
34
+ <g-permission include="门店二维码">
35
+ <button>门店二维码</button>
36
+ </g-permission>
37
+
38
+ <!-- 多个权限(满足任一即显示) -->
39
+ <g-permission :include="['会员管理']">
40
+ <button>管理功能</button>
41
+ </g-permission>
42
+ </template>
43
+ ```
44
+
45
+ ## API
46
+
47
+ ### Props
48
+
49
+ | 属性 | 类型 | 默认值 | 必填 | 说明 |
50
+ | --- | --- | --- | --- | --- |
51
+ | `include` | `String \| Array` | - | 是 | 需要匹配的权限名称(`menuName`),支持单个字符串或字符串数组。 |
52
+
53
+ ### Events
54
+
55
+ 无。
56
+
57
+ ### Slots
58
+
59
+ | 插槽 | 说明 |
60
+ | --- | --- |
61
+ | `default` | 有权限时渲染的内容。 |
@@ -78,6 +78,7 @@ Options API 组件可使用 `this.$store`。普通 TS 模块中使用 `uni.$stor
78
78
  | [`g-popup`](./g-popup) | 通用弹窗,封装 uv-popup 的标题、内容、底部按钮、关闭、确认和样式配置。 |
79
79
  | [`g-mask`](./g-mask) | 遮罩层组件,支持层级、缩放动画、点击关闭能力和默认插槽内容。 |
80
80
  | [`g-float`](./g-float) | 悬浮操作按钮,滚动时可自动淡出,点击后可跳转或抛出 goto 事件。 |
81
+ | [`g-permission`](./g-permission) | 权限控制组件,根据 `perms` 中 `isSelect` 为 true 的 `menuName` 条件渲染插槽内容。 |
81
82
  | [`g-permission-popup`](./g-permission-popup) | 权限申请辅助弹层,监听 requestPermission 事件展示授权原因。 |
82
83
  | [`g-back-button`](./g-back-button) | 自定义返回/首页按钮,适合透明导航栏、沉浸式页面或小程序胶囊左侧区域。 |
83
84
 
@@ -39,7 +39,7 @@
39
39
  | 基础展示 | `g-icon`、`g-dot-text`、`g-money`、`g-more`、`g-skeleton`、`g-skeleton-view` | 图标、状态文本、金额、查看更多、骨架屏。 |
40
40
  | 表单输入 | `g-search`、`g-checkbox-list`、`g-tag-editor`、`g-upload` | 搜索、选择、标签编辑、文件上传。 |
41
41
  | 图片布局 | `g-grid-image`、`g-grid-swiper`、`g-waterfall`、`g-render-image` | 图片网格、宫格轮播、瀑布流、海报渲染。 |
42
- | 弹层反馈 | `g-mask`、`g-popup`、`g-permission-popup`、`g-float` | 遮罩、弹窗、权限提示、悬浮入口。 |
42
+ | 弹层反馈 | `g-mask`、`g-popup`、`g-permission`、`g-permission-popup`、`g-float` | 遮罩、弹窗、权限控制、权限提示、悬浮入口。 |
43
43
  | 分享 | `g-share-view`、`g-share-photo`、`g-share-weixin` | 分享面板、保存图片、微信分享。 |
44
44
  | 音视频/图表 | `g-trtc`、`g-trtc-room`、`g-trtc-tui`、`g-polyline-view`、`g-polyline-chat`、`g-timer` | TRTC、TUI 通话、折线展示、计时器。 |
45
45
  | 调试 | `g-back-button` | 自定义返回/首页按钮。 |
@@ -0,0 +1,25 @@
1
+ <template>
2
+ <slot v-if="hasPermission"></slot>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ props: {
8
+ include: {
9
+ type: [String, Array],
10
+ required: true,
11
+ },
12
+ },
13
+ computed: {
14
+ permNames() {
15
+ const perms = this.$store?.state?.app?.info?.perms || [];
16
+ // 只取 isSelect 为 true 的 menuName
17
+ return perms.filter(p => p.isSelect).map(p => p.menuName);
18
+ },
19
+ hasPermission() {
20
+ const list = Array.isArray(this.include) ? this.include : [this.include];
21
+ return list.some(v => this.permNames.includes(v));
22
+ },
23
+ },
24
+ };
25
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zfqh/uniapp",
3
- "version": "0.2.31",
3
+ "version": "0.3.0",
4
4
  "description": "uniapp公共模块",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -46,5 +46,5 @@
46
46
  "@types/qs": "^6.9.16",
47
47
  "@types/url-parse": "^1.4.11"
48
48
  },
49
- "gitHead": "2cecb9d1420fd349d575a04d61b8d72b6d083d91"
49
+ "gitHead": "2527c90194ae48b8d23817b248f53cd6435fd3a0"
50
50
  }