@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.
- package/.arcconfig +8 -0
- package/.husky/commit-msg +20 -0
- package/.husky/pre-commit +4 -0
- package/README.md +126 -3
- package/arcanist/.phutil_module_cache +1 -0
- package/arcanist/__phutil_library_init__.php +3 -0
- package/arcanist/__phutil_library_map__.php +18 -0
- package/arcanist/lint/engine/YqgWebDiffLintEngine.php +68 -0
- package/commitlint.config.js +32 -0
- package/dist/{apply-modal-C7hVR1xJ.js → apply-modal-CzowWeBJ.js} +1231 -1216
- package/dist/card.png +0 -0
- package/dist/{checkbox-item-Bf_S20_z.js → checkbox-item-zQ0rw1If.js} +405 -418
- package/dist/dialog.png +0 -0
- package/dist/image.png +0 -0
- package/dist/{index-B0kTXjfX.js → index-DA6ClyIX.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.cjs +45 -45
- package/dist/{yqg-permission-CbkviMn9.js → yqg-permission-BrJJoGxC.js} +444 -427
- package/eslint.config.js +26 -0
- package/package.json +10 -4
- package/public/card.png +0 -0
- package/public/dialog.png +0 -0
- package/public/image.png +0 -0
- package/src/App.vue +1 -1
- package/src/axios/axios.ts +1 -1
- package/src/components/apply-modal.vue +17 -4
- package/src/components/approval-steps.vue +10 -8
- package/src/components/checkbox-item.vue +5 -18
- package/src/components/success-modal.vue +16 -7
- package/src/components/yqg-permission.vue +27 -15
- package/src/i18n/zh-CH.ts +4 -1
- package/src/main.ts +1 -1
- package/src/typings/index.d.ts +1 -0
- package/src/yqg-permission/index.ts +2 -2
- package/tsconfig.app.json +10 -1
- package/tsconfig.json +2 -2
- package/dist/vite.svg +0 -1
- package/public/vite.svg +0 -1
package/.arcconfig
ADDED
|
@@ -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
|
package/README.md
CHANGED
|
@@ -1,5 +1,128 @@
|
|
|
1
|
-
|
|
1
|
+
## Vue 3 + TypeScript + Vite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# 申请权限弹窗
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
给业务方提供的申请权限的弹窗组件
|
|
6
|
+

|
|
7
|
+

|
|
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
|
+

|
|
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,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
|
+
};
|