@yqg/permission 1.0.4-beta.0 → 1.0.5-beta.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.
Files changed (38) hide show
  1. package/.arcconfig +8 -0
  2. package/.husky/commit-msg +20 -0
  3. package/.husky/pre-commit +4 -0
  4. package/README.md +126 -3
  5. package/arcanist/.phutil_module_cache +1 -0
  6. package/arcanist/__phutil_library_init__.php +3 -0
  7. package/arcanist/__phutil_library_map__.php +18 -0
  8. package/arcanist/lint/engine/YqgWebDiffLintEngine.php +68 -0
  9. package/commitlint.config.js +32 -0
  10. package/dist/{apply-modal-C7hVR1xJ.js → apply-modal-CzowWeBJ.js} +1231 -1216
  11. package/dist/card.png +0 -0
  12. package/dist/{checkbox-item-Bf_S20_z.js → checkbox-item-zQ0rw1If.js} +405 -418
  13. package/dist/dialog.png +0 -0
  14. package/dist/image.png +0 -0
  15. package/dist/{index-B0kTXjfX.js → index-DA6ClyIX.js} +2 -2
  16. package/dist/index.js +2 -2
  17. package/dist/index.umd.cjs +45 -45
  18. package/dist/{yqg-permission-CbkviMn9.js → yqg-permission-BrJJoGxC.js} +444 -427
  19. package/eslint.config.js +26 -0
  20. package/package.json +10 -4
  21. package/public/card.png +0 -0
  22. package/public/dialog.png +0 -0
  23. package/public/image.png +0 -0
  24. package/src/App.vue +1 -1
  25. package/src/axios/axios.ts +1 -1
  26. package/src/components/apply-modal.vue +17 -4
  27. package/src/components/approval-steps.vue +10 -8
  28. package/src/components/checkbox-item.vue +5 -18
  29. package/src/components/success-modal.vue +16 -7
  30. package/src/components/yqg-permission.vue +27 -15
  31. package/src/i18n/zh-CH.ts +4 -1
  32. package/src/main.ts +1 -1
  33. package/src/typings/index.d.ts +1 -0
  34. package/src/yqg-permission/index.ts +2 -2
  35. package/tsconfig.app.json +10 -1
  36. package/tsconfig.json +2 -2
  37. package/dist/vite.svg +0 -1
  38. package/public/vite.svg +0 -1
package/.arcconfig ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "project.name": "yqg-permission",
3
+ "phabricator.uri": "https://code.yangqianguan.com/",
4
+ "phutil_libraries": {
5
+ "libcustom": "./arcanist"
6
+ },
7
+ "lint.engine": "YqgWebDiffLintEngine"
8
+ }
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ echo "Running commit-msg hook"
5
+ pnpm commitlint --edit "$1"
6
+
7
+ # 定义前缀
8
+ PREFIX="[yqg-permission]"
9
+
10
+ # 读取提交信息文件路径
11
+ COMMIT_MSG_FILE=$1
12
+ COMMIT_MSG=$(cat $COMMIT_MSG_FILE)
13
+
14
+ echo "$COMMIT_MSG" | grep -q "$PREFIX"
15
+ # 检查提交信息是否已经包含前缀
16
+ if ! echo "$COMMIT_MSG" | grep -q -F "$PREFIX"; then
17
+ # 添加前缀并写回提交信息文件
18
+ echo "$PREFIX $COMMIT_MSG" > $COMMIT_MSG_FILE
19
+ echo "Prefix added: $PREFIX $COMMIT_MSG" # 调试信息
20
+ fi
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ pnpm lint-staged
package/README.md CHANGED
@@ -1,5 +1,128 @@
1
- # Vue 3 + TypeScript + Vite
1
+ ## Vue 3 + TypeScript + Vite
2
2
 
3
- This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3
+ # 申请权限弹窗
4
4
 
5
- Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
5
+ 给业务方提供的申请权限的弹窗组件
6
+ ![默认组件](./public/card.png)
7
+ ![申请弹窗](./public/dialog.png)
8
+
9
+
10
+ ### [Demo URL](https://crane-test.yangqianguan.com/role)
11
+
12
+ ### [接入文档](https://wiki.fintopia.tech/pages/viewpage.action?pageId=117280979)
13
+
14
+ ## Table of Contents
15
+
16
+ - [Installation](#installation)
17
+ - [Install with npm](#install-with-npm)
18
+ - [Use inline script directly](#use-inline-script-directly)
19
+ - [Usage](#usage)
20
+ - [Config](#config)
21
+ - [FAQ](#FAQ)
22
+ - [Browser Support](#browser-support)
23
+ - [Acknowledgement](#acknowledgement)
24
+
25
+ ### Installation
26
+
27
+ #### Install with npm
28
+
29
+ ```bash
30
+ $ npm install @yqg/permission
31
+ ```
32
+
33
+ #### Install with yarn
34
+
35
+ ```bash
36
+ $ yarn add @yqg/permission
37
+ ```
38
+
39
+ #### Install with install
40
+
41
+ ```bash
42
+ $ pnpm install @yqg/permission
43
+ ```
44
+
45
+
46
+ ### Usage
47
+
48
+ step1: 在入口文件(main.js/index.js/app.ts/)引入@yag/permission,并调用start方法注册。
49
+ [See example](./src/main.ts)
50
+
51
+ ```js
52
+ import yqgPermission from './yqg-permission';
53
+ yqgPermission.start();
54
+ //支持定义组件标签名,默认为‘<yqg-permission></yqg-permission>’
55
+ yqgPermission.start({tagName: 'my-element'});
56
+
57
+ ```
58
+
59
+ step2: 像原生标签一样进行使用
60
+ [See example](./src/App.ts)
61
+
62
+ ```js
63
+ <yqg-permission
64
+ workNumber="05184"
65
+ businessCode="PPDL"
66
+ :permissions="['permissionCode1, permissionCode2']"
67
+ :color="'red'"
68
+ :locale="'zh-CN'"
69
+ @success="() => {console.log('请求成功')}"
70
+ >
71
+ </yqg-permission>
72
+
73
+ ```
74
+ ### 配置说明
75
+
76
+ 支持自定义标签:yqgPermission.start({tagName: 'my-element'});
77
+
78
+ ### yqg-permission 组件参数说明
79
+
80
+ | 参数项 | 是否必传 | 说明 | 类型 | 默认值 |
81
+ | -------------- | -------- | ------------------ | ------------------ | -------- |
82
+ | `work-number` | 是 | 当前登陆人工号 | string | '' |
83
+ | `business-code` | 是 | 系统的权限code | string | '' |
84
+ | `permissions` | 是 | 当前页面下所有权限点 | string[]或string | [] |
85
+ | `color` | 否 | 主题色(同antd) | string | #1677ff |
86
+ | `locale` | 否 | 当前语言类型(同i18n) | string | zn-CH |
87
+ | `success` | 否 | 申请成功时回调函数(vue)| Function | ()=> {} |
88
+ | `type` | 否 | 组件类型 | string | default |
89
+
90
+
91
+ ### type 参数说明
92
+
93
+ type = "default": 默认展示图+按钮组件,点击可弹出弹窗
94
+ type = "text": 展示‘申请权限’文案,点击可弹出弹窗
95
+ type = "custom": 支持自定义组件,以slot的方式添加自定义组件,点击自定义组件可弹出弹窗,例如:
96
+ ```js
97
+ <yqg-permission
98
+ workNumber="05184"
99
+ businessCode="PPDL"
100
+ :permissions="['permissionCode1, permissionCode2']"
101
+ :color="'red'"
102
+ :locale="'zh-CN'"
103
+ type="custom"
104
+ @success="() => {console.log('请求成功')}"
105
+ >
106
+ <div>自定义按钮</div>
107
+ </yqg-permission>
108
+
109
+ ```
110
+
111
+
112
+ ### Browser Support
113
+
114
+ 因为该npm包底层使用webComponent中customElements.define,所以仅支持customElements.define的浏览器
115
+ ![浏览器customElements支持现状](./public/image.png)
116
+
117
+ ### NPM scripts
118
+
119
+ - `pnpm install`: 安装依赖
120
+ - `pnpm dev`: 启动项目
121
+ - `pnpm build`: 编译项目
122
+ - `npm publish`: 发布项目
123
+
124
+ ### todo
125
+ todo:优化项 react中成功回调、多语言
126
+
127
+ ### 问题反馈
128
+ -------
@@ -0,0 +1 @@
1
+ {"__symbol_cache_version__":11,"0861795cb7fca1601b342f4e44fe1aed":{"have":{"class":{"YqgWebDiffLintEngine":13}},"need":{"class":{"ArcanistLintEngine":42,"ExecFuture":1832,"PhutilConsole":1780}},"xmap":{"YqgWebDiffLintEngine":["ArcanistLintEngine"]}}}
@@ -0,0 +1,3 @@
1
+ <?php
2
+
3
+ phutil_register_library('libcustom', __FILE__);
@@ -0,0 +1,18 @@
1
+ <?php
2
+
3
+ /**
4
+ * This file is automatically generated. Use 'arc liberate' to rebuild it.
5
+ *
6
+ * @generated
7
+ * @phutil-library-version 2
8
+ */
9
+ phutil_register_library_map(array(
10
+ '__library_version__' => 2,
11
+ 'class' => array(
12
+ 'YqgWebDiffLintEngine' => 'lint/engine/YqgWebDiffLintEngine.php',
13
+ ),
14
+ 'function' => array(),
15
+ 'xmap' => array(
16
+ 'YqgWebDiffLintEngine' => 'ArcanistLintEngine',
17
+ ),
18
+ ));
@@ -0,0 +1,68 @@
1
+ <?php
2
+
3
+ class YqgWebDiffLintEngine extends ArcanistLintEngine
4
+ {
5
+ /** @Override */
6
+ public function buildLinters()
7
+ {
8
+ // Filter the affected paths.
9
+ $paths = $this->getPaths();
10
+ foreach ($paths as $key => $path) {
11
+ if (!$this->pathExists($path)) {
12
+ // Don't lint removed files. In more complex linters it is sometimes
13
+ // appropriate to lint removed files so you can raise a warning like
14
+ // "you deleted X, but forgot to delete Y!", but most linters do not
15
+ // operate correctly on removed files.
16
+ unset($paths[$key]);
17
+ continue;
18
+ }
19
+
20
+ $disk = $this->getFilePathOnDisk($path);
21
+ if (is_dir($disk)) {
22
+ // Don't lint directories. (In SVN, they can be directly modified by
23
+ // changing properties on them, and may appear as modified paths.)
24
+ unset($paths[$key]);
25
+ continue;
26
+ }
27
+ }
28
+
29
+ $command = '';
30
+ $patterns = array(
31
+ '/\.(jsx?|tsx?|vue?|ts?)$/' => 'pnpm eslint',
32
+ // '/\.(less|s?css)$/' => 'npx stylelint --fix' // 理论上暂时不用 style lint
33
+ );
34
+
35
+ foreach ($patterns as $pattern => $lintCommand) {
36
+ $matchedPaths = preg_grep($pattern, $paths);
37
+ if (count($matchedPaths) > 0) {
38
+ if (strlen($command)) {
39
+ $command .= ' && \\';
40
+ }
41
+
42
+ $command .= $lintCommand . ' ' . join(' ', $matchedPaths);
43
+ }
44
+ }
45
+
46
+ $root = $this->getWorkingCopy()->getProjectRoot();
47
+ $console = PhutilConsole::getConsole();
48
+
49
+ $future = new ExecFuture($command);
50
+ $future->setCWD($root . "/");
51
+ list($exitcode, $stdout, $stderr) = $future->resolve();
52
+ $console->writeOut($stdout);
53
+ $console->writeOut($stderr);
54
+ $console->writeOut("\n");
55
+
56
+ if ($exitcode != 0) {
57
+ $console->writeOut("All code in any code-base should look like a single person typed it, no matter how many people contributed. --idiomatic.js\n");
58
+ $console->writeOut("无论有多少人在维护,所有在代码仓库中的代码理应看起来像同一个人写的。 --idiomatic.js\n");
59
+ $console->writeOut("https://github.com/rwaldron/idiomatic.js/tree/master/translations/zh_CN\n");
60
+ throw new Exception("Keep it in mind!");
61
+ } else {
62
+ $console->writeOut("All code are clean, you did a great job!\n");
63
+ }
64
+
65
+ return;
66
+ }
67
+
68
+ }
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ plugins: [
4
+ {
5
+ rules: {
6
+ yqgPermission: (parsed) => {
7
+ const { type, subject } = parsed;
8
+ if (type === null && subject === null) {
9
+ return [false, "commit message 格式应该类似 'type: subject' "];
10
+ }
11
+
12
+ if (!['feat', 'fix', 'patch', 'style', 'refactor', 'perf', 'test', 'build', 'chore', 'script'].includes(type)) {
13
+ return [false, 'type 应该为 feat, fix, patch, style, refactor, perf, test, build, chore, script 中的一个'];
14
+ }
15
+ return [true, ''];
16
+ },
17
+ },
18
+ },
19
+ ],
20
+ rules: {
21
+ yqgPermission: [2, 'always'],
22
+ 'header-max-length': [2, 'always', 200],
23
+ 'body-max-line-length': [2, 'always', 500],
24
+ 'footer-max-line-length': [2, 'always', 500],
25
+ },
26
+ parserPreset: {
27
+ parserOpts: {
28
+ headerPattern: /^(?:\[(.+?)\] )?(.+?): (.+?)$/,
29
+ headerCorrespondence: ['prefix', 'type', 'subject'],
30
+ },
31
+ },
32
+ };